[vlc-devel] [PATCH 6/8] playlist: conditionally stop playlist on deletion of node

Filip Roséen filip at atch.se
Sun May 21 20:48:16 CEST 2017


This fixes a regression introduced by 1ab80a3, 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
---
 src/playlist/playlist_internal.h  | 3 +++
 src/playlist/services_discovery.c | 6 ++++--
 src/playlist/tree.c               | 6 +++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index 83982d7da0..78b4b5c46d 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -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 */
 /** @} */
 
 /**
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index eb524a093a..b3c6f23ff8 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -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);
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index caaa9e133f..8358932622 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -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++ )
-- 
2.13.0


More information about the vlc-devel mailing list