Commit 899653e3 authored by Filip Roséen's avatar Filip Roséen Committed by Rémi Denis-Courmont
Browse files

playlist: conditionally stop playlist on deletion of node

This fixes a regression introduced by 1ab80a39

, where playback would
not stop if a node was deleted through user-interaction.

As a solution, a new flag to playlist_NodeDeleteExplicit has been
introduced so that we can conditionally stop playback of a deleted
item if desired (there are cases where we do not want such mechanisms,
such as when dealing with deletions of empty nodes).

fixes: #18350
Signed-off-by: Rémi Denis-Courmont's avatarRémi Denis-Courmont <remi@remlab.net>
parent 7aa4bec7
......@@ -132,6 +132,9 @@ int playlist_NodeInsert(playlist_item_t*, playlist_item_t *, int);
* @{
**/
#define PLAYLIST_DELETE_FORCE 0x01 /**< delete node even if read-only */
#define PLAYLIST_DELETE_STOP_IF_CURRENT 0x02 /**< stop playlist playback if
node is currently the one
played */
/** @} */
/**
......
......@@ -103,7 +103,8 @@ static void playlist_sd_item_removed(services_discovery_t *sd,
becomes empty, delete that node as well */
if (node != sds->node && node->i_children == 1)
item = node;
playlist_NodeDeleteExplicit(p_playlist, item, PLAYLIST_DELETE_FORCE );
playlist_NodeDeleteExplicit(p_playlist, item,
PLAYLIST_DELETE_FORCE | PLAYLIST_DELETE_STOP_IF_CURRENT );
PL_UNLOCK;
}
......@@ -153,7 +154,8 @@ static void playlist_ServicesDiscoveryInternalRemove(playlist_t *playlist,
/* Remove the sd playlist node if it exists */
playlist_Lock(playlist);
if (sds->node != NULL)
playlist_NodeDeleteExplicit(playlist, sds->node, PLAYLIST_DELETE_FORCE );
playlist_NodeDeleteExplicit(playlist, sds->node,
PLAYLIST_DELETE_FORCE | PLAYLIST_DELETE_STOP_IF_CURRENT );
playlist_Unlock(playlist);
free(sds);
......
......@@ -91,7 +91,8 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
*/
void playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root )
{
playlist_NodeDeleteExplicit( p_playlist, p_root, 0 );
playlist_NodeDeleteExplicit( p_playlist, p_root,
PLAYLIST_DELETE_STOP_IF_CURRENT );
}
void playlist_NodeDeleteExplicit( playlist_t *p_playlist,
......@@ -124,6 +125,9 @@ void playlist_NodeDeleteExplicit( playlist_t *p_playlist,
{
/* This item can't be the next one to be played ! */
set_current_status_item( p_playlist, NULL );
if( flags & PLAYLIST_DELETE_STOP_IF_CURRENT )
playlist_Control( p_playlist, PLAYLIST_STOP, pl_Locked );
}
for( i = 0; i < p_playlist->current.i_size; i++ )
......
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