[vlc-devel] [PATCH 09/12] core: playlist: expose a main playlist instance

Romain Vimont rom1v at videolabs.io
Thu Oct 11 23:14:47 CEST 2018


Store a main instance of the playlist in libvlc, accessible via
vlc_intf_GetMainPlaylist().
---
 include/vlc_interface.h   | 4 ++++
 src/interface/interface.c | 6 ++++++
 src/libvlc.c              | 9 +++++++++
 src/libvlc.h              | 2 ++
 src/libvlccore.sym        | 1 +
 5 files changed, 22 insertions(+)

diff --git a/include/vlc_interface.h b/include/vlc_interface.h
index f56eae598b..c18d32b2e7 100644
--- a/include/vlc_interface.h
+++ b/include/vlc_interface.h
@@ -30,6 +30,7 @@
 extern "C" {
 # endif
 
+typedef struct vlc_playlist vlc_playlist_t;
 typedef struct intf_dialog_args_t intf_dialog_args_t;
 
 /**
@@ -96,6 +97,9 @@ static inline playlist_t *pl_Get( struct intf_thread_t *intf )
     return (playlist_t *)(intf->obj.parent);
 }
 
+VLC_API vlc_playlist_t *
+vlc_intf_GetMainPlaylist(intf_thread_t *intf);
+
 /**
  * Retrieves the current input thread from the playlist.
  * @note The returned object must be released with vlc_object_release().
diff --git a/src/interface/interface.c b/src/interface/interface.c
index 9910463065..3b8696e04e 100644
--- a/src/interface/interface.c
+++ b/src/interface/interface.c
@@ -146,6 +146,12 @@ static playlist_t *intf_GetPlaylist(libvlc_int_t *libvlc)
     return playlist;
 }
 
+vlc_playlist_t *
+vlc_intf_GetMainPlaylist(intf_thread_t *intf)
+{
+    return libvlc_priv(intf->obj.libvlc)->main_playlist;
+}
+
 /**
  * Inserts an item in the playlist.
  *
diff --git a/src/libvlc.c b/src/libvlc.c
index f12f980936..438f958e2e 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -52,6 +52,7 @@
 #include "config/vlc_getopt.h"
 
 #include <vlc_playlist.h>
+#include <vlc_playlist_new.h>
 #include <vlc_interface.h>
 
 #include <vlc_actions.h>
@@ -93,6 +94,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
 
     priv = libvlc_priv (p_libvlc);
     priv->playlist = NULL;
+    priv->main_playlist = NULL;
     priv->p_vlm = NULL;
 
     vlc_ExitInit( &priv->exit );
@@ -276,6 +278,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     }
 #endif
 
+    priv->main_playlist = vlc_playlist_New(VLC_OBJECT(p_libvlc));
+    if (unlikely(!priv->main_playlist))
+        goto error;
+
     /*
      * Load background interfaces
      */
@@ -400,6 +406,9 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     if (priv->parser != NULL)
         input_preparser_Delete(priv->parser);
 
+    if (priv->main_playlist)
+        vlc_playlist_Delete(priv->main_playlist);
+
     libvlc_InternalActionsClean( p_libvlc );
 
     /* Save the configuration */
diff --git a/src/libvlc.h b/src/libvlc.h
index 97faa1d4d8..881f5c7271 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -174,6 +174,7 @@ void vlc_objres_remove(vlc_object_t *obj, void *data,
 typedef struct vlc_dialog_provider vlc_dialog_provider;
 typedef struct vlc_keystore vlc_keystore;
 typedef struct vlc_actions_t vlc_actions_t;
+typedef struct vlc_playlist vlc_playlist_t;
 
 typedef struct libvlc_priv_t
 {
@@ -185,6 +186,7 @@ typedef struct libvlc_priv_t
     vlc_dialog_provider *p_dialog_provider; ///< dialog provider
     vlc_keystore      *p_memory_keystore; ///< memory keystore
     struct playlist_t *playlist; ///< Playlist for interfaces
+    vlc_playlist_t *main_playlist;
     struct input_preparser_t *parser; ///< Input item meta data handler
     vlc_actions_t *actions; ///< Hotkeys handler
     struct vlc_medialibrary_t *p_media_library; ///< Media library instance
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 45119d83d6..ae6019a79d 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -897,3 +897,4 @@ vlc_playlist_Stop
 vlc_playlist_Pause
 vlc_playlist_Resume
 vlc_playlist_Preparse
+vlc_intf_GetMainPlaylist
-- 
2.19.1



More information about the vlc-devel mailing list