[vlc-commits] playlist/item: add_subitem_tree: fix next on flat playlist and empty node

Filip Roséen git at videolan.org
Mon May 22 19:59:58 CEST 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Sun May 21 21:34:41 2017 +0200| [c99321fbb36f5ba67a64c7be6ec04da3a05777fa] | committer: Rémi Denis-Courmont

playlist/item: add_subitem_tree: fix next on flat playlist and empty node

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c99321fbb36f5ba67a64c7be6ec04da3a05777fa
---

 src/playlist/item.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/playlist/item.c b/src/playlist/item.c
index a8757c7a11..3f4e782177 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -190,6 +190,34 @@ static void input_item_add_subitem_tree ( const vlc_event_t * p_event,
 
             playlist_ViewPlay( p_playlist, NULL, p_play_item );
         }
+        else if( b_flat && p_playlist->current.i_size > 0 )
+        {
+            /* If the playlist is flat, empty nodes are automatically deleted;
+             * meaning that moving from the current index (the index of a now
+             * removed node) to the next would result in a skip of one entry
+             * (as the empty node is deleted, the logical next item would be
+             * the one that now resides in its place).
+             *
+             * Imagine [ A, B, C, D ], where B (at index 1) is currently being
+             * played and deleted. C is the logically next item, but since the
+             * list now looks like [ A, C, D ], advancing to index 2 would mean
+             * D is played - and not C.
+             *
+             * By positioning the playlist-head at index 0 (A), when the
+             * playlist advance to the next item, C will correctly be played.
+             *
+             * Note: Of course, if the deleted item is at index 0, we should
+             * play whatever item is at position 0 since we cannot advance to
+             * index -1 (as there cannot possibly be any item there).
+             **/
+
+            if( last_pos )
+                ResetCurrentlyPlaying( p_playlist,
+                    ARRAY_VAL( p_playlist->current, last_pos - 1 ) );
+            else
+                playlist_ViewPlay( p_playlist, NULL,
+                    ARRAY_VAL( p_playlist->current, 0 ) );
+        }
     }
 
     PL_UNLOCK;



More information about the vlc-commits mailing list