[vlc-devel] [PATCH 1/2] playlist: add no inherit flag for editable playlists (refs #16923)

Francois Cartegnie fcvlcdev at free.fr
Sun May 8 16:01:15 CEST 2016


Avoids copying some sd specific playlist flags on
playlist item duplication. (ex RO flag from SD which
makes current playlist item as non deletable)

Not setting the inheritable flag by default avoids
changing the item creation api to clear flags.
---
 include/vlc_playlist.h | 1 +
 src/playlist/engine.c  | 4 ++--
 src/playlist/tree.c    | 5 +++++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 5f716bc..4363405 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -152,6 +152,7 @@ typedef enum {
     PLAYLIST_REMOVE_FLAG       = 0x0010,  /**< Remove this item at the end */
     PLAYLIST_EXPANDED_FLAG     = 0x0020,  /**< Expanded node */
     PLAYLIST_SUBITEM_STOP_FLAG = 0x0040,  /**< Must playlist stop if the item gets subitems ?*/
+    PLAYLIST_NO_INHERIT_FLAG   = 0x0080,  /**< Childs must not inherit flags from parent node */
 } playlist_item_flags_e;
 
 /** Playlist status */
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 6000a37..97f9e11 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -237,10 +237,10 @@ playlist_t *playlist_Create( vlc_object_t *p_parent )
     root = playlist_NodeCreate( p_playlist, NULL, NULL,
                                 PLAYLIST_END, 0, NULL );
     playing = playlist_NodeCreate( p_playlist, _( "Playlist" ), root,
-                                   PLAYLIST_END, PLAYLIST_RO_FLAG, NULL );
+                                   PLAYLIST_END, PLAYLIST_RO_FLAG | PLAYLIST_NO_INHERIT_FLAG, NULL );
     if( var_InheritBool( p_parent, "media-library") )
         ml = playlist_NodeCreate( p_playlist, _( "Media Library" ), root,
-                                  PLAYLIST_END, PLAYLIST_RO_FLAG, NULL );
+                                  PLAYLIST_END, PLAYLIST_RO_FLAG | PLAYLIST_NO_INHERIT_FLAG, NULL );
     else
         ml = NULL;
     PL_UNLOCK;
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index d991162..e44e7a8 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -222,6 +222,11 @@ int playlist_NodeInsert( playlist_t *p_playlist,
                  i_position,
                  p_item );
     p_item->p_parent = p_parent;
+
+    /* Inherit special flags from parent (sd cases) */
+    if( ( p_parent->i_flags & PLAYLIST_NO_INHERIT_FLAG ) == 0 )
+        p_item->i_flags |= (p_parent->i_flags & (PLAYLIST_RO_FLAG | PLAYLIST_SKIP_FLAG));
+
     return VLC_SUCCESS;
 }
 
-- 
2.5.5



More information about the vlc-devel mailing list