[vlc-devel] commit: Send INPUT_EVENT_ABORT from input thread instead of input_StopThread. ( Laurent Aimar )

git version control git at videolan.org
Thu Mar 12 20:17:06 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu Mar 12 20:13:29 2009 +0100| [f5bea704d5441b857c559014af94bfbb4425d713] | committer: Laurent Aimar 

Send INPUT_EVENT_ABORT from input thread instead of input_StopThread.

It is cleaner to not send event from caller threadand will fix a deadlock in the
playlist code.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f5bea704d5441b857c559014af94bfbb4425d713
---

 src/input/input.c          |   10 ++++++++--
 src/input/input_internal.h |    1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 77965ac..8cae4df 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -209,6 +209,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     vlc_mutex_init( &p_input->p->lock_control );
     vlc_cond_init( &p_input->p->wait_control );
     p_input->p->i_control = 0;
+    p_input->p->b_abort = false;
 
     /* Parse input options */
     vlc_mutex_lock( &p_item->lock );
@@ -436,9 +437,11 @@ void input_StopThread( input_thread_t *p_input, bool b_abort )
      * unlock the control loop */
     ObjectKillChildrens( p_input, VLC_OBJECT(p_input) );
 
+    vlc_mutex_lock( &p_input->p->lock_control );
+    p_input->p->b_abort |= b_abort;
+    vlc_mutex_unlock( &p_input->p->lock_control );
+
     input_ControlPush( p_input, INPUT_CONTROL_SET_DIE, NULL );
-    if( b_abort )
-        input_SendEventAbort( p_input );
 }
 
 input_resource_t *input_DetachResource( input_thread_t *p_input )
@@ -508,7 +511,10 @@ static void *Run( vlc_object_t *p_this )
 
 exit:
     /* Tell we're dead */
+    if( p_input->p->b_abort )
+        input_SendEventAbort( p_input );
     input_SendEventDead( p_input );
+
     vlc_restorecancel( canc );
     return NULL;
 }
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index ee3dbd2..8a1366c 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -165,6 +165,7 @@ struct input_thread_private_t
         int         i_type;
         vlc_value_t val;
     } control[INPUT_CONTROL_FIFO_SIZE];
+    bool b_abort;
 };
 
 /***************************************************************************




More information about the vlc-devel mailing list