Commit 24298341 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

playlist: Make sure we don't crash when we delete the currently playing node.

parent c8759b8d
......@@ -373,9 +373,23 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
PLI_NAME( p_playlist->request.p_item ),
PLI_NAME( p_playlist->request.p_node ), i_skip );
/* Make sure the node wasn't deleted */
if( p_playlist->status.p_node &&
p_playlist->status.p_node->i_flags & PLAYLIST_REMOVE_FLAG )
{
PL_DEBUG( "%s was marked for deletion, deleting",
PLI_NAME( p_playlist->status.p_node ) );
playlist_ItemDelete( p_playlist->status.p_node );
/* Don't attempt to reuse that node */
if( p_playlist->status.p_node == p_playlist->request.p_node )
p_playlist->request.p_node = NULL;
p_playlist->status.p_node = NULL;
}
if( p_playlist->request.p_node &&
p_playlist->request.p_node != p_playlist->status.p_node )
{
p_playlist->status.p_node = p_playlist->request.p_node;
p_playlist->b_reset_currently_playing = true;
}
......
......@@ -477,6 +477,15 @@ void playlist_LastLoop( playlist_t *p_playlist )
sout_DeleteInstance( p_sout );
#endif
if( p_playlist->status.p_node &&
p_playlist->status.p_node->i_flags & PLAYLIST_REMOVE_FLAG )
{
PL_DEBUG( "%s was marked for deletion, deleting",
PLI_NAME( p_playlist->status.p_node ) );
playlist_ItemDelete( p_playlist->status.p_node );
p_playlist->status.p_node = NULL;
}
/* Core should have terminated all SDs before the playlist */
/* TODO: It fails to do so when not playing anything -- Courmisch */
playlist_ServicesDiscoveryKillAll( p_playlist );
......
......@@ -171,7 +171,24 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
if( p_root->p_parent )
playlist_NodeRemoveItem( p_playlist, p_root, p_root->p_parent );
playlist_ItemDelete( p_root );
/* Check if it is the current node */
if( p_playlist->status.p_node == p_root )
{
/* Hack we don't call playlist_Control for lock reasons */
p_playlist->request.i_status = PLAYLIST_STOPPED;
p_playlist->request.b_request = true;
p_playlist->request.p_item = NULL;
p_playlist->request.p_node = NULL;
msg_Info( p_playlist, "stopping playback" );
vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
PL_DEBUG( "marking %s for further deletion", PLI_NAME( p_root ) );
p_root->i_flags |= PLAYLIST_REMOVE_FLAG;
}
else
playlist_ItemDelete( p_root );
}
return VLC_SUCCESS;
}
......
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