]> git.sesse.net Git - vlc/blobdiff - src/playlist/engine.c
playlist: wait for preparser end from playlist thread.
[vlc] / src / playlist / engine.c
index 1a39ce50f9ae7faac2f0e70e5c366bd6fe25da35..2aa85d18dde10f3621fdca36d3f598face43d327 100644 (file)
@@ -169,11 +169,14 @@ static void playlist_Destructor( vlc_object_t * p_this )
     playlist_t * p_playlist = (playlist_t *)p_this;
 
     if( p_playlist->p_preparse )
+    {
         vlc_object_release( p_playlist->p_preparse );
+    }
 
     if( p_playlist->p_fetcher )
+    {
         vlc_object_release( p_playlist->p_fetcher );
-
+    }
     msg_Dbg( p_this, "Destroyed" );
 }
 
@@ -501,6 +504,11 @@ void playlist_LastLoop( playlist_t *p_playlist )
     playlist_ServicesDiscoveryKillAll( p_playlist );
     playlist_MLDump( p_playlist );
 
+    vlc_object_kill( p_playlist->p_preparse );
+    vlc_thread_join( p_playlist->p_preparse );
+    vlc_object_kill( p_playlist->p_fetcher );
+    vlc_thread_join( p_playlist->p_fetcher );
+
     PL_LOCK;
     FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->all_items )
         free( p_del->pp_children );
@@ -601,6 +609,13 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
         msleep( (i_activity+1) * 1000 );
         vlc_object_lock( p_obj );
     }
+
+    for( int i = 0; i < p_obj->i_waiting; i++ )
+    {
+        vlc_gc_decref( p_obj->pp_waiting[i] );
+        REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
+    }
+
     vlc_object_unlock( p_obj );
 }
 
@@ -682,6 +697,13 @@ void playlist_FetcherLoop( playlist_fetcher_t *p_obj )
         msleep( (i_activity+1) * 1000 );
         vlc_object_lock( p_obj );
     }
+
+    for( int i = 0; i < p_obj->i_waiting; i++ )
+    {
+        vlc_gc_decref( p_obj->pp_waiting[i] );
+        REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
+    }
+
     vlc_object_unlock( p_obj );
 }