]> git.sesse.net Git - vlc/commitdiff
VLM: cleanup VLM threading
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 24 Aug 2008 13:12:42 +0000 (16:12 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Mon, 25 Aug 2008 16:41:45 +0000 (19:41 +0300)
src/input/vlm.c
src/input/vlm_internal.h

index 4a92e60baa6b967ac9a94e2ca71fcda5db430226..c511c7c7edd2fb25173404c856869a761b4b6692 100644 (file)
@@ -62,7 +62,7 @@
  *****************************************************************************/
 
 static void vlm_Destructor( vlm_t *p_vlm );
-static void* Manage( vlc_object_t * );
+static void* Manage( void * );
 static int vlm_MediaVodControl( void *, vod_media_t *, const char *, int, va_list );
 
 /*****************************************************************************
@@ -108,8 +108,7 @@ vlm_t *__vlm_New ( vlc_object_t *p_this )
     p_vlm->p_vod = NULL;
     vlc_object_attach( p_vlm, p_this->p_libvlc );
 
-    if( vlc_thread_create( p_vlm, "vlm thread",
-                           Manage, VLC_THREAD_PRIORITY_LOW, false ) )
+    if( vlc_clone( &p_vlm->thread, Manage, p_vlm, VLC_THREAD_PRIORITY_LOW ) )
     {
         vlc_mutex_destroy( &p_vlm->lock );
         vlc_object_release( p_vlm );
@@ -155,11 +154,6 @@ void vlm_Delete( vlm_t *p_vlm )
      * is serialized against setting libvlc_priv->p_vlm from vlm_New(). */
     var_Get( p_vlm->p_libvlc, "vlm_mutex", &lockval );
     vlc_mutex_lock( lockval.p_address );
-    /* Parental advisory: terrific humongous horrible follows...
-     * This is so that vlc_object_destroy() (from vlc_object_release()) will
-     * NOT join our thread. See also vlm_Destructor().
-     * -- Courmisch, 24/08/2008 */
-    vlc_internals( p_vlm )->b_thread = false;
     vlc_object_release( p_vlm );
     vlc_mutex_unlock( lockval.p_address );
 }
@@ -178,9 +172,8 @@ static void vlm_Destructor( vlm_t *p_vlm )
     TAB_CLEAN( p_vlm->schedule, p_vlm->schedule );
 
     vlc_object_kill( p_vlm );
-    /* Continuation of the vlm_Delete() hack. -- Courmisch */
-    vlc_internals( p_vlm )->b_thread = true;
-    vlc_thread_join( p_vlm );
+    /*vlc_cancel( p_vlm->thread ); */
+    vlc_join( p_vlm->thread, NULL );
     vlc_mutex_destroy( &p_vlm->lock );
 }
 
@@ -309,7 +302,7 @@ static int vlm_MediaVodControl( void *p_private, vod_media_t *p_vod_media,
 /*****************************************************************************
  * Manage:
  *****************************************************************************/
-static void* Manage( vlc_object_t* p_object )
+static void* Manage( void* p_object )
 {
     vlm_t *vlm = (vlm_t*)p_object;
     int i, j;
index a751cf3f81f26a7e77b247d67715ddae334ed79b..670f5a16c828342c3d4e02ff95ec357b7e11867d 100644 (file)
@@ -87,7 +87,8 @@ struct vlm_t
 {
     VLC_COMMON_MEMBERS
 
-    vlc_mutex_t lock;
+    vlc_mutex_t  lock;
+    vlc_thread_t thread;
 
     /* */
     int64_t        i_id;