lib: add helper for playlist startup
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 7 Jan 2014 21:26:35 +0000 (23:26 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 7 Jan 2014 22:07:50 +0000 (00:07 +0200)
Also remove a useless and unsynchronized test.

lib/libvlc_internal.h
lib/playlist.c
src/interface/interface.c
src/libvlccore.sym

index 760649e..64585a7 100644 (file)
@@ -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 * );
 
index 03bce9b..c0e610f 100644 (file)
 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 )
index 83b5297..35446c0 100644 (file)
@@ -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
index 5a7c56a..14e26e3 100644 (file)
@@ -224,6 +224,7 @@ input_Close
 intf_Create
 IsUTF8
 libvlc_InternalAddIntf
+libvlc_InternalPlay
 libvlc_InternalCleanup
 libvlc_InternalCreate
 libvlc_InternalDestroy