Commit d32dc564 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Export playlist_Deactivate() and simplify it

Those interfaces that need playlist deactivation can now call it
explicitly.
parent 468c863c
......@@ -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.
......
......@@ -324,6 +324,7 @@ playlist_Clear
playlist_Control
playlist_CurrentInput
playlist_CurrentPlayingItem
playlist_Deactivate
playlist_DeleteFromInput
playlist_Export
playlist_GetNextLeaf
......
......@@ -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 );
......
......@@ -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 *);
/* */
......
......@@ -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" );
}
/* */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment