[vlc-commits] Converted input to vlc_clone().

Laurent Aimar git at videolan.org
Mon May 23 21:16:29 CEST 2011


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon May 23 19:19:41 2011 +0200| [a47715a1a1480fd3c38b17ac6606a8f3ac3a272f] | committer: Laurent Aimar

Converted input to vlc_clone().

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

 src/input/input.c          |   14 +++++++++-----
 src/input/input_internal.h |    2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index cfbe3cc..8e16682 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -64,7 +64,7 @@
  *****************************************************************************/
 static void Destructor( input_thread_t * p_input );
 
-static  void *Run            ( vlc_object_t *p_this );
+static  void *Run            ( void * );
 
 static input_thread_t * Create  ( vlc_object_t *, input_item_t *,
                                   const char *, bool, input_resource_t * );
@@ -217,7 +217,9 @@ int input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
 int input_Start( input_thread_t *p_input )
 {
     /* Create thread and wait for its readiness. */
-    if( vlc_thread_create( p_input, Run, VLC_THREAD_PRIORITY_INPUT ) )
+    p_input->p->is_running = !vlc_clone( &p_input->p->thread,
+                                         Run, p_input, VLC_THREAD_PRIORITY_INPUT );
+    if( !p_input->p->is_running )
     {
         input_ChangeState( p_input, ERROR_S );
         msg_Err( p_input, "cannot create input thread" );
@@ -257,7 +259,8 @@ void input_Stop( input_thread_t *p_input, bool b_abort )
  */
 int input_Close( input_thread_t *p_input )
 {
-    vlc_thread_join( p_input );
+    if( p_input->p->is_running )
+        vlc_join( p_input->p->thread, NULL );
     vlc_object_release( p_input );
 }
 
@@ -417,6 +420,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     vlc_cond_init( &p_input->p->wait_control );
     p_input->p->i_control = 0;
     p_input->p->b_abort = false;
+    p_input->p->is_running = false;
 
     /* Create Object Variables for private use only */
     input_ConfigVarInit( p_input );
@@ -542,9 +546,9 @@ static void Destructor( input_thread_t * p_input )
  * This is the "normal" thread that spawns the input processing chain,
  * reads the stream, cleans up and waits
  *****************************************************************************/
-static void *Run( vlc_object_t *p_this )
+static void *Run( void *obj )
 {
-    input_thread_t *p_input = (input_thread_t *)p_this;
+    input_thread_t *p_input = (input_thread_t *)obj;
     const int canc = vlc_savecancel();
 
     if( Init( p_input ) )
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index beaa8568..fc787cd 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -164,6 +164,8 @@ struct input_thread_private_t
     input_control_t control[INPUT_CONTROL_FIFO_SIZE];
 
     bool b_abort;
+    bool is_running;
+    vlc_thread_t thread;
 };
 
 /***************************************************************************



More information about the vlc-commits mailing list