[vlc-commits] lib: add helper for playlist startup

Rémi Denis-Courmont git at videolan.org
Tue Jan 7 23:07:58 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jan  7 23:26:35 2014 +0200| [c39376d370292b469bb9c5ad49ebc6f76626c825] | committer: Rémi Denis-Courmont

lib: add helper for playlist startup

Also remove a useless and unsynchronized test.

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

 lib/libvlc_internal.h     |    1 +
 lib/playlist.c            |    8 +-------
 src/interface/interface.c |   13 +++++++++++++
 src/libvlccore.sym        |    1 +
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lib/libvlc_internal.h b/lib/libvlc_internal.h
index 760649e..64585a7 100644
--- a/lib/libvlc_internal.h
+++ b/lib/libvlc_internal.h
@@ -49,6 +49,7 @@ VLC_API void libvlc_InternalCleanup( libvlc_int_t * );
 VLC_API void libvlc_InternalDestroy( libvlc_int_t * );
 
 VLC_API int libvlc_InternalAddIntf( libvlc_int_t *, const char * );
+VLC_API void libvlc_InternalPlay( libvlc_int_t * );
 VLC_API void libvlc_InternalWait( libvlc_int_t * );
 VLC_API void libvlc_SetExitHandler( libvlc_int_t *, void (*) (void *), void * );
 
diff --git a/lib/playlist.c b/lib/playlist.c
index 03bce9b..c0e610f 100644
--- a/lib/playlist.c
+++ b/lib/playlist.c
@@ -41,14 +41,8 @@
 void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
                            int i_options, char **ppsz_options )
 {
-    playlist_t *pl = pl_Get (p_instance->p_libvlc_int);
+    libvlc_InternalPlay( p_instance->p_libvlc_int );
     VLC_UNUSED(i_id); VLC_UNUSED(i_options); VLC_UNUSED(ppsz_options);
-
-    assert( pl );
-    if( !var_GetBool( pl, "playlist-autostart" )
-     || pl->items.i_size == 0 )
-        return;
-    playlist_Control( pl, PLAYLIST_PLAY, false );
 }
 
 int libvlc_add_intf( libvlc_instance_t *p_instance, const char *name )
diff --git a/src/interface/interface.c b/src/interface/interface.c
index 83b5297..35446c0 100644
--- a/src/interface/interface.c
+++ b/src/interface/interface.c
@@ -46,6 +46,7 @@
 #include <vlc_playlist.h>
 #include "libvlc.h"
 #include "playlist/playlist_internal.h"
+#include "../lib/libvlc_internal.h"
 
 static int AddIntfCallback( vlc_object_t *, char const *,
                             vlc_value_t , vlc_value_t , void * );
@@ -174,6 +175,18 @@ void intf_InsertItem(libvlc_int_t *libvlc, const char *mrl, unsigned optc,
                     0, -1, optc, optv, flags, true, pl_Unlocked);
 }
 
+void libvlc_InternalPlay(libvlc_int_t *libvlc)
+{
+    playlist_t *pl;
+
+    vlc_mutex_lock(&lock);
+    pl = libvlc_priv(libvlc)->playlist;
+    vlc_mutex_unlock(&lock);
+
+    if (pl != NULL && var_GetBool(pl, "playlist-autostart"))
+        playlist_Control(pl, PLAYLIST_PLAY, false);
+}
+
 /**
  * Stops and destroys all interfaces
  * @param p_libvlc the LibVLC instance
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 5a7c56a..14e26e3 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -224,6 +224,7 @@ input_Close
 intf_Create
 IsUTF8
 libvlc_InternalAddIntf
+libvlc_InternalPlay
 libvlc_InternalCleanup
 libvlc_InternalCreate
 libvlc_InternalDestroy



More information about the vlc-commits mailing list