[vlc-devel] [PATCH] added start playback in paused mode (#2936)

Aleksandr Pasechnik al at megamicron.net
Fri Mar 13 03:49:52 CET 2015


Added a boolean Playlist preference called start-pause.

Setting the preference causes the src/input/input.c Run function to call the
ControlPause function after Init finishes successfully.
---
 src/input/input.c   | 9 +++++++++
 src/libvlc-module.c | 6 ++++++
 2 files changed, 15 insertions(+)

diff --git a/src/input/input.c b/src/input/input.c
index 7de30ec..cf39a98 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -72,6 +72,7 @@ static inline int ControlPop( input_thread_t *, int *, vlc_value_t *, mtime_t i_
 static void       ControlRelease( int i_type, vlc_value_t val );
 static bool       ControlIsSeekRequest( int i_type );
 static bool       Control( input_thread_t *, int, vlc_value_t );
+static void       ControlPause( input_thread_t *, mtime_t );
 
 static int  UpdateTitleSeekpointFromDemux( input_thread_t * );
 static void UpdateGenericFromDemux( input_thread_t * );
@@ -518,6 +519,14 @@ static void *Run( void *obj )
 
     if( !Init( p_input ) )
     {
+        bool b_start_paused = var_InheritBool( p_input, "start-paused" );
+        msg_Dbg( p_input, "decided that start-paused is %d", b_start_paused );
+        if( b_start_paused )
+        {
+            const mtime_t i_control_date = mdate();
+            ControlPause( p_input, i_control_date );
+        }
+
         MainLoop( p_input, true ); /* FIXME it can be wrong (like with VLM) */
 
         /* Clean up */
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 31037b4..6e2da2c 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1122,6 +1122,10 @@ static const char *const ppsz_prefres[] = {
 #define PAP_LONGTEXT N_( \
     "Pause each item in the playlist on the last frame." )
 
+#define SP_TEXT N_("Start paused")
+#define SP_LONGTEXT N_( \
+    "Pause each item in the playlist on the first frame." )
+
 #define AUTOSTART_TEXT N_( "Auto start" )
 #define AUTOSTART_LONGTEXT N_( "Automatically start playing the playlist " \
                 "content once it's loaded." )
@@ -1983,6 +1987,8 @@ vlc_module_begin ()
         change_safe()
     add_bool( "play-and-pause", 0, PAP_TEXT, PAP_LONGTEXT, true )
         change_safe()
+    add_bool( "start-paused", 0, SP_TEXT, SP_LONGTEXT, false )
+        change_safe()
     add_bool( "playlist-autostart", true,
               AUTOSTART_TEXT, AUTOSTART_LONGTEXT, false )
     add_bool( "playlist-cork", true, CORK_TEXT, CORK_LONGTEXT, false )
-- 
2.3.2




More information about the vlc-devel mailing list