]> git.sesse.net Git - vlc/commitdiff
Export playlist_Deactivate() and simplify it
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 26 Nov 2012 21:11:05 +0000 (23:11 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 26 Nov 2012 22:05:31 +0000 (00:05 +0200)
Those interfaces that need playlist deactivation can now call it
explicitly.

include/vlc_playlist.h
src/libvlccore.sym
src/playlist/engine.c
src/playlist/playlist_internal.h
src/playlist/thread.c

index d837e7dce112496918cf1099b6347c55ec28bef9..5f58bfd8a49bd32d5a4b46251e5ef04f40289bd1 100644 (file)
@@ -265,6 +265,7 @@ VLC_API playlist_t * pl_Get( vlc_object_t * ) VLC_USED;
 VLC_API void playlist_Lock( playlist_t * );
 VLC_API void playlist_Unlock( playlist_t * );
 VLC_API void playlist_AssertLocked( playlist_t * );
+VLC_API void playlist_Deactivate( playlist_t * );
 
 /**
  * Do a playlist action.
index 04dfbc890f86b05bf038f521014719b6b99281ea..346dad14ec9b98a75ca752f7d8fab375c07ef621 100644 (file)
@@ -324,6 +324,7 @@ playlist_Clear
 playlist_Control
 playlist_CurrentInput
 playlist_CurrentPlayingItem
+playlist_Deactivate
 playlist_DeleteFromInput
 playlist_Export
 playlist_GetNextLeaf
index 44433885f9449ede6c4c9f45cee35f3f1526d2e4..466215f3c9a449a7279f8fa200b1fabb661ffa1f 100644 (file)
@@ -313,13 +313,25 @@ void playlist_Destroy( playlist_t *p_playlist )
     playlist_private_t *p_sys = pl_priv(p_playlist);
 
     msg_Dbg( p_playlist, "destroying" );
+
     if( p_sys->p_preparser )
         playlist_preparser_Delete( p_sys->p_preparser );
     if( p_sys->p_fetcher )
         playlist_fetcher_Delete( p_sys->p_fetcher );
 
-    /* Already cleared when deactivating (if activated anyway) */
-    assert( !p_sys->p_input );
+    /* Release input resources */
+    assert( p_sys->p_input == NULL );
+    input_resource_Release( p_sys->p_input_resource );
+
+    if( p_playlist->p_media_library != NULL )
+        playlist_MLDump( p_playlist );
+
+    PL_LOCK;
+    /* Release the current node */
+    set_current_status_node( p_playlist, NULL );
+    /* Release the current item */
+    set_current_status_item( p_playlist, NULL );
+    PL_UNLOCK;
 
     vlc_cond_destroy( &p_sys->signal );
     vlc_mutex_destroy( &p_sys->lock );
index fedecea411666a7edd0495a511b6cffc6761e352..fa2469ed9d3a1563bda2779bb9076e930abd7c46 100644 (file)
@@ -104,7 +104,6 @@ void playlist_Destroy( playlist_t * );
 
 /* */
 void playlist_Activate( playlist_t * );
-void playlist_Deactivate( playlist_t * );
 void pl_Deactivate (libvlc_int_t *);
 
 /* */
index 053a09aa05f428a92a3ba94057c6cd18428b2b9d..5f22924ed4a1d4f7058f1a0eca6fe4eb4c922597 100644 (file)
@@ -71,38 +71,35 @@ void playlist_Activate( playlist_t *p_playlist )
     msg_Dbg( p_playlist, "playlist threads correctly activated" );
 }
 
+/**
+ * Stops the playlist forever (but do not destroy it yet).
+ * Any input is stopped.
+ * \return Nothing but waits for the playlist to be deactivated.
+ */
 void playlist_Deactivate( playlist_t *p_playlist )
 {
-    /* */
     playlist_private_t *p_sys = pl_priv(p_playlist);
 
-    msg_Dbg( p_playlist, "deactivating the playlist" );
+    if( p_sys->p_input_resource == NULL )
+        return; /* playlist was never activated... */
 
     PL_LOCK;
+    /* WARNING: There is a latent bug. It is assumed that only one thread will
+     * be waiting for playlist deactivation at a time. So far, that works
+     * as playlist_Deactivate() is only ever called while closing an
+     * interface and interfaces are shut down serially by intf_DestroyAll(). */
+    if( p_sys->killed )
+    {
+        PL_UNLOCK;
+        return;
+    }
+
+    msg_Dbg( p_playlist, "deactivating the playlist" );
     p_sys->killed = true;
     vlc_cond_signal( &p_sys->signal );
     PL_UNLOCK;
 
     vlc_join( p_sys->thread, NULL );
-    assert( !p_sys->p_input );
-
-    /* release input resources */
-    input_resource_Release( p_sys->p_input_resource );
-
-    if( var_InheritBool( p_playlist, "media-library" ) )
-        playlist_MLDump( p_playlist );
-
-    PL_LOCK;
-
-    /* Release the current node */
-    set_current_status_node( p_playlist, NULL );
-
-    /* Release the current item */
-    set_current_status_item( p_playlist, NULL );
-
-    PL_UNLOCK;
-
-    msg_Dbg( p_playlist, "playlist correctly deactivated" );
 }
 
 /* */