[vlc-devel] [PATCH] input: check run-time against demuxer timeline (fixes #15814)

Rémi Denis-Courmont remi at remlab.net
Wed Nov 4 21:48:17 CET 2015


The "run-time" parameter was measured in terms of how long the input
thread had actually been playing, i.e. the real time since the thread
was created minus the real time spent in paused state.

This is a bit odd. It does not make much sense when transcoding, and
also seems rather counter-intuitive when playing a non-nominal rate.

This patch changes the run-time variable to match the demuxer time, as
does the start-time and the stop-time.
---
 src/input/input.c          | 32 ++++++++++++++++----------------
 src/input/input_internal.h |  1 -
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 70ff07b..c3303ef 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -311,7 +311,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     p_input->p->i_start = 0;
     p_input->p->i_time  = 0;
     p_input->p->i_stop  = 0;
-    p_input->p->i_run   = 0;
     p_input->p->i_title = 0;
     p_input->p->title = NULL;
     p_input->p->i_title_offset = p_input->p->i_seekpoint_offset = 0;
@@ -527,14 +526,13 @@ bool input_Stopped( input_thread_t *input )
  * MainLoopDemux
  * It asks the demuxer to demux some data
  */
-static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed, mtime_t i_start_mdate )
+static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed )
 {
     int i_ret;
 
     *pb_changed = false;
 
-    if( ( p_input->p->i_stop > 0 && p_input->p->i_time >= p_input->p->i_stop ) ||
-        ( p_input->p->i_run > 0 && i_start_mdate+p_input->p->i_run < mdate() ) )
+    if( p_input->p->i_stop > 0 && p_input->p->i_time >= p_input->p->i_stop )
         i_ret = 0; /* EOF */
     else
         i_ret = demux_Demux( p_input->p->master->p_demux );
@@ -572,7 +570,7 @@ static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed, mtime_t i_
         SlaveDemux( p_input );
 }
 
-static int MainLoopTryRepeat( input_thread_t *p_input, mtime_t *pi_start_mdate )
+static int MainLoopTryRepeat( input_thread_t *p_input )
 {
     int i_repeat = var_GetInteger( p_input, "input-repeat" );
     if( i_repeat <= 0 )
@@ -613,8 +611,6 @@ static int MainLoopTryRepeat( input_thread_t *p_input, mtime_t *pi_start_mdate )
         input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &val );
     }
 
-    /* */
-    *pi_start_mdate = mdate();
     return VLC_SUCCESS;
 }
 
@@ -658,12 +654,11 @@ static void MainLoopStatistics( input_thread_t *p_input )
  */
 static void MainLoop( input_thread_t *p_input, bool b_interactive )
 {
-    mtime_t i_start_mdate = mdate();
     mtime_t i_intf_update = 0;
     mtime_t i_last_seek_mdate = 0;
 
     if( b_interactive && var_InheritBool( p_input, "start-paused" ) )
-        ControlPause( p_input, i_start_mdate );
+        ControlPause( p_input, mdate() );
 
     bool b_pause_after_eof = b_interactive &&
                              var_InheritBool( p_input, "play-and-pause" );
@@ -685,7 +680,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
             {
                 bool b_force_update = false;
 
-                MainLoopDemux( p_input, &b_force_update, i_start_mdate );
+                MainLoopDemux( p_input, &b_force_update );
 
                 if( p_input->p->master->p_demux->pf_demux != NULL )
                     i_wakeup = es_out_GetWakeup( p_input->p->p_es_out );
@@ -710,7 +705,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
             }
             else
             {
-                if( MainLoopTryRepeat( p_input, &i_start_mdate ) )
+                if( MainLoopTryRepeat( p_input ) )
                     break;
             }
 
@@ -883,12 +878,17 @@ static void StartTitle( input_thread_t * p_input )
                                      * var_GetFloat( p_input, "start-time" ));
     p_input->p->i_stop  = llroundf(1000000.f
                                      * var_GetFloat( p_input, "stop-time" ));
-    p_input->p->i_run   = llroundf(1000000.f
-                                     * var_GetFloat( p_input, "run-time" ));
-    if( p_input->p->i_run < 0 )
+    if( p_input->p->i_stop <= 0 )
     {
-        msg_Warn( p_input, "invalid run-time ignored" );
-        p_input->p->i_run = 0;
+        p_input->p->i_stop = llroundf(1000000.f
+                                     * var_GetFloat( p_input, "run-time" ));
+        if( p_input->p->i_stop < 0 )
+        {
+            msg_Warn( p_input, "invalid run-time ignored" );
+            p_input->p->i_stop = 0;
+        }
+        else
+            p_input->p->i_stop += p_input->p->i_start;
     }
 
     if( p_input->p->i_start > 0 )
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 0020144..bab69bf 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -96,7 +96,6 @@ struct input_thread_private_t
     /* Playtime configuration and state */
     int64_t     i_start;    /* :start-time,0 by default */
     int64_t     i_stop;     /* :stop-time, 0 if none */
-    int64_t     i_run;      /* :run-time, 0 if none */
     int64_t     i_time;     /* Current time */
     bool        b_fast_seek;/* :input-fast-seek */
 
-- 
2.6.2



More information about the vlc-devel mailing list