[vlc-commits] [Git][videolan/vlc][master] 7 commits: input: remove normal_time from input_thread_private_t

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Jul 5 10:40:44 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a977de64 by Thomas Guillem at 2023-07-05T10:24:05+00:00
input: remove normal_time from input_thread_private_t

And fix the misleading comment. VLC_TICK_0 was already used in case of failure.

- - - - -
9a0dc2e6 by Thomas Guillem at 2023-07-05T10:24:05+00:00
es_out: move source initialisation

To match with the next commit.

- - - - -
c909a090 by Thomas Guillem at 2023-07-05T10:24:05+00:00
es_out: add input_source_t in es_out->priv_control

cf. 0c0a4d1d4a39c4841340226b16944309a7eb27e0

It will be used to differentiate the master source (in = NULL) from the slave
ones.

- - - - -
46faa855 by Thomas Guillem at 2023-07-05T10:24:05+00:00
input: refactor and add InputSourceStatistics()

- - - - -
a81e949e by Thomas Guillem at 2023-07-05T10:24:05+00:00
es_out: handle SET_TIMES for all sources

Set the source normal time, but only send the event from the main
source.

- - - - -
3cfa2224 by Thomas Guillem at 2023-07-05T10:24:05+00:00
input: update statistics for all sources

- - - - -
70e89784 by Thomas Guillem at 2023-07-05T10:24:05+00:00
es_out: shift with the main source normal time

This fixes synchronization issues when 2 demuxers have a different time
base (like .ts + .srt for example).

Fixes #21999

- - - - -


7 changed files:

- include/vlc_es_out.h
- src/input/es_out.c
- src/input/es_out.h
- src/input/es_out_source.c
- src/input/es_out_timeshift.c
- src/input/input.c
- src/input/input_internal.h


Changes:

=====================================
include/vlc_es_out.h
=====================================
@@ -140,7 +140,7 @@ struct es_out_callbacks
     /**
      * Private control callback, must be NULL for es_out created from modules.
      */
-    int          (*priv_control)(es_out_t *, int query, va_list);
+    int          (*priv_control)(es_out_t *, input_source_t *in, int query, va_list);
 };
 
 struct es_out_t


=====================================
src/input/es_out.c
=====================================
@@ -262,7 +262,7 @@ static void EsOutGlobalMeta( es_out_t *p_out, const vlc_meta_t *p_meta );
 static void EsOutMeta( es_out_t *p_out, const vlc_meta_t *p_meta, const vlc_meta_t *p_progmeta );
 static int EsOutEsUpdateFmt(es_out_t *out, es_out_id_t *es, const es_format_t *fmt);
 static int EsOutControlLocked( es_out_t *out, input_source_t *, int i_query, ... );
-static int EsOutPrivControlLocked( es_out_t *out, int i_query, ... );
+static int EsOutPrivControlLocked( es_out_t *out, input_source_t *, int i_query, ... );
 
 static char *LanguageGetName( const char *psz_code );
 static char *LanguageGetCode( const char *psz_lang );
@@ -718,7 +718,7 @@ static void EsOutUpdateDelayJitter(es_out_t *out)
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
 
     /* Update the clock pts delay only if the extra tracks delay changed */
-    EsOutPrivControlLocked(out, ES_OUT_PRIV_SET_JITTER, p_sys->i_pts_delay,
+    EsOutPrivControlLocked(out, NULL, ES_OUT_PRIV_SET_JITTER, p_sys->i_pts_delay,
                            p_sys->i_pts_jitter, p_sys->i_cr_average);
 }
 
@@ -2911,6 +2911,25 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
 
     vlc_mutex_lock( &p_sys->lock );
 
+    /* Shift all slaves timestamps with the main source normal time. This will
+     * allow to synchronize 2 demuxers with different time bases. Remove the
+     * normal time from the current source and add the main source normal time.
+     * */
+    if( es->id.source != p_sys->main_source )
+    {
+        if( p_block->i_dts != VLC_TICK_INVALID )
+        {
+            p_block->i_dts -= es->id.source->i_normal_time - VLC_TICK_0;
+            p_block->i_dts += p_sys->main_source->i_normal_time - VLC_TICK_0;
+        }
+
+        if( p_block->i_pts != VLC_TICK_INVALID )
+        {
+            p_block->i_pts -= es->id.source->i_normal_time - VLC_TICK_0;
+            p_block->i_pts += p_sys->main_source->i_normal_time - VLC_TICK_0;
+        }
+    }
+
     /* Drop all ESes except the video one in case of next-frame */
     if( p_sys->p_next_frame_es != NULL && p_sys->p_next_frame_es != es )
     {
@@ -3156,7 +3175,10 @@ static int EsOutVaControlLocked( es_out_t *out, input_source_t *source,
                                  int i_query, va_list args )
 {
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
-    assert( source ); /* == p_sys->main_source if the given source is NULL */
+
+    /* Controls from the main source are called with a NULL source */
+    if( !source )
+        source = p_sys->main_source;
 
     switch( i_query )
     {
@@ -3436,7 +3458,7 @@ static int EsOutVaControlLocked( es_out_t *out, input_source_t *source,
                 /* Force a rebufferization when we are too late */
                 EsOutControlLocked( out, source, ES_OUT_RESET_PCR );
 
-                EsOutPrivControlLocked( out, ES_OUT_PRIV_SET_JITTER,
+                EsOutPrivControlLocked( out, source, ES_OUT_PRIV_SET_JITTER,
                                         p_sys->i_pts_delay, i_new_jitter,
                                         p_sys->i_cr_average );
             }
@@ -3663,10 +3685,15 @@ static int EsOutVaControlLocked( es_out_t *out, input_source_t *source,
     }
 }
 
-static int EsOutVaPrivControlLocked( es_out_t *out, int query, va_list args )
+static int EsOutVaPrivControlLocked( es_out_t *out, input_source_t *source,
+                                     int query, va_list args )
 {
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
 
+    /* Controls from the main source are called with a NULL source */
+    if( !source )
+        source = p_sys->main_source;
+
     switch (query)
     {
     case ES_OUT_PRIV_SET_MODE:
@@ -3868,6 +3895,11 @@ static int EsOutVaPrivControlLocked( es_out_t *out, int query, va_list args )
         vlc_tick_t i_normal_time = va_arg( args, vlc_tick_t );
         vlc_tick_t i_length = va_arg( args, vlc_tick_t );
 
+        source->i_normal_time = i_normal_time;
+
+        if( source != p_sys->main_source )
+            return VLC_SUCCESS;
+
         if( !p_sys->b_buffering )
         {
             vlc_tick_t i_delay;
@@ -3985,9 +4017,6 @@ static int EsOutControl( es_out_t *out, input_source_t *source,
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
     int i_ret;
 
-    if( !source )
-        source = p_sys->main_source;
-
     vlc_mutex_lock( &p_sys->lock );
     i_ret = EsOutVaControlLocked( out, source, i_query, args );
     vlc_mutex_unlock( &p_sys->lock );
@@ -3995,22 +4024,23 @@ static int EsOutControl( es_out_t *out, input_source_t *source,
     return i_ret;
 }
 
-static int EsOutPrivControlLocked( es_out_t *out, int i_query, ... )
+static int EsOutPrivControlLocked( es_out_t *out, input_source_t *source, int i_query, ... )
 {
     va_list args;
 
     va_start( args, i_query );
-    int ret = EsOutVaPrivControlLocked( out, i_query, args );
+    int ret = EsOutVaPrivControlLocked( out, source, i_query, args );
     va_end( args );
     return ret;
 }
 
-static int EsOutPrivControl( es_out_t *out, int query, va_list args )
+static int EsOutPrivControl( es_out_t *out, input_source_t *source,
+                             int query, va_list args )
 {
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
 
     vlc_mutex_lock( &p_sys->lock );
-    int ret = EsOutVaPrivControlLocked( out, query, args );
+    int ret = EsOutVaPrivControlLocked( out, source, query, args );
     vlc_mutex_unlock( &p_sys->lock );
 
     return ret;


=====================================
src/input/es_out.h
=====================================
@@ -102,7 +102,7 @@ enum es_out_query_private_e
 static inline int es_out_vaPrivControl( es_out_t *out, int query, va_list args )
 {
     vlc_assert( out->cbs->priv_control );
-    return out->cbs->priv_control( out, query, args );
+    return out->cbs->priv_control( out, NULL, query, args );
 }
 
 static inline int es_out_PrivControl( es_out_t *out, int query, ... )


=====================================
src/input/es_out_source.c
=====================================
@@ -71,6 +71,14 @@ static int EsOutSourceControl(es_out_t *out, input_source_t *in, int query,
     return sys->parent_out->cbs->control(sys->parent_out, sys->in, query, args);
 }
 
+static int EsOutSourcePrivControl(es_out_t *out, input_source_t *in, int query,
+                                  va_list args)
+{
+    assert(in == NULL);
+    es_out_sys_t *sys = container_of(out, es_out_sys_t, out);
+    return sys->parent_out->cbs->priv_control(sys->parent_out, sys->in, query, args);
+}
+
 static void EsOutSourceDestroy(es_out_t *out)
 {
     es_out_sys_t *sys = container_of(out, es_out_sys_t, out);
@@ -88,6 +96,7 @@ es_out_t *input_EsOutSourceNew(es_out_t *parent_out, input_source_t *in)
         .del = EsOutSourceDel,
         .control = EsOutSourceControl,
         .destroy = EsOutSourceDestroy,
+        .priv_control = EsOutSourcePrivControl,
     };
 
     es_out_sys_t *sys = malloc(sizeof(*sys));


=====================================
src/input/es_out_timeshift.c
=====================================
@@ -153,6 +153,7 @@ typedef struct attribute_packed
 {
     ts_cmd_header_t header;
     int  i_query;
+    input_source_t *in;
 
     union
     {
@@ -308,12 +309,13 @@ static int  CmdInitAdd    ( ts_cmd_add_t *, input_source_t *, es_out_id_t *, con
 static void CmdInitSend   ( ts_cmd_send_t *, es_out_id_t *, block_t * );
 static int  CmdInitDel    ( ts_cmd_del_t *, es_out_id_t * );
 static int  CmdInitControl( ts_cmd_control_t *, input_source_t *, int i_query, va_list, bool b_copy );
-static int  CmdInitPrivControl( ts_cmd_privcontrol_t *, int i_query, va_list, bool b_copy );
+static int  CmdInitPrivControl( ts_cmd_privcontrol_t *, input_source_t *, int i_query, va_list, bool b_copy );
 
 /* */
 static void CmdCleanAdd    ( ts_cmd_add_t * );
 static void CmdCleanSend   ( ts_cmd_send_t * );
 static void CmdCleanControl( ts_cmd_control_t * );
+static void CmdCleanPrivControl( ts_cmd_privcontrol_t * );
 
 /* */
 static void CmdExecuteAdd    ( es_out_t *, ts_cmd_add_t * );
@@ -456,6 +458,24 @@ static inline int es_out_in_Control( es_out_t *p_out, input_source_t *in,
     return i_result;
 }
 
+static inline int es_out_in_vaPrivControl( es_out_t *p_out, input_source_t *in,
+                                           int i_query, va_list args)
+{
+    return p_out->cbs->priv_control( p_out, in, i_query, args );
+}
+
+static inline int es_out_in_PrivControl( es_out_t *p_out, input_source_t *in,
+                                         int i_query, ... )
+{
+    va_list args;
+    int     i_result;
+
+    va_start( args, i_query );
+    i_result = es_out_in_vaPrivControl( p_out, in, i_query, args );
+    va_end( args );
+    return i_result;
+}
+
 static int ControlLockedGetEmpty( es_out_t *p_out, input_source_t *in,
                                   bool *pb_empty )
 {
@@ -471,7 +491,7 @@ static int ControlLockedGetEmpty( es_out_t *p_out, input_source_t *in,
 
     return VLC_SUCCESS;
 }
-static int ControlLockedGetWakeup( es_out_t *p_out, vlc_tick_t *pi_wakeup )
+static int ControlLockedGetWakeup( es_out_t *p_out, input_source_t *in, vlc_tick_t *pi_wakeup )
 {
     es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
 
@@ -482,30 +502,37 @@ static int ControlLockedGetWakeup( es_out_t *p_out, vlc_tick_t *pi_wakeup )
     }
     else
     {
-        *pi_wakeup = es_out_GetWakeup( p_sys->p_out );
+        int ret = es_out_in_PrivControl( p_sys->p_out, in, ES_OUT_PRIV_GET_WAKE_UP,
+                                         pi_wakeup );
+        assert( !ret );
     }
 
     return VLC_SUCCESS;
 }
-static int ControlLockedGetBuffering( es_out_t *p_out, bool *pb_buffering )
+static int ControlLockedGetBuffering( es_out_t *p_out, input_source_t *in, bool *pb_buffering )
 {
     es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
 
     if( p_sys->b_delayed )
         *pb_buffering = true;
     else
-        *pb_buffering = es_out_GetBuffering( p_sys->p_out );
+    {
+        int ret = es_out_in_PrivControl( p_sys->p_out, in, ES_OUT_PRIV_GET_BUFFERING,
+                                         pb_buffering );
+        assert( !ret );
+    }
 
     return VLC_SUCCESS;
 }
-static int ControlLockedSetPauseState( es_out_t *p_out, bool b_source_paused, bool b_paused, vlc_tick_t i_date )
+static int ControlLockedSetPauseState( es_out_t *p_out, input_source_t *in, bool b_source_paused, bool b_paused, vlc_tick_t i_date )
 {
     es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
     int i_ret;
 
     if( !p_sys->b_delayed && !b_source_paused == !b_paused )
     {
-        i_ret = es_out_SetPauseState( p_sys->p_out, b_source_paused, b_paused, i_date );
+        i_ret = es_out_in_PrivControl( p_sys->p_out, in, ES_OUT_PRIV_SET_PAUSE_STATE,
+                                       b_source_paused, b_paused, i_date );
     }
     else
     {
@@ -533,14 +560,15 @@ static int ControlLockedSetPauseState( es_out_t *p_out, bool b_source_paused, bo
     }
     return i_ret;
 }
-static int ControlLockedSetRate( es_out_t *p_out, float src_rate, float rate )
+static int ControlLockedSetRate( es_out_t *p_out, input_source_t *in, float src_rate, float rate )
 {
     es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
     int i_ret;
 
     if( !p_sys->b_delayed && src_rate == rate )
     {
-        i_ret = es_out_SetRate( p_sys->p_out, src_rate, rate );
+        i_ret = es_out_in_PrivControl( p_sys->p_out, in, ES_OUT_PRIV_SET_RATE,
+                                       src_rate, rate );
     }
     else
     {
@@ -569,11 +597,11 @@ static int ControlLockedSetRate( es_out_t *p_out, float src_rate, float rate )
     }
     return i_ret;
 }
-static int ControlLockedSetFrameNext( es_out_t *p_out )
+static int ControlLockedSetFrameNext( es_out_t *p_out, input_source_t *in )
 {
     es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
 
-    return es_out_SetFrameNext( p_sys->p_out );
+    return es_out_in_PrivControl( p_sys->p_out, in, ES_OUT_PRIV_SET_FRAME_NEXT );
 }
 
 static int ControlLocked( es_out_t *p_out, input_source_t *in, int i_query,
@@ -707,7 +735,7 @@ static int Control( es_out_t *p_tsout, input_source_t *in, int i_query, va_list
     return i_ret;
 }
 
-static int PrivControlLocked( es_out_t *p_tsout, int i_query, va_list args )
+static int PrivControlLocked( es_out_t *p_tsout, input_source_t *in, int i_query, va_list args )
 {
     es_out_sys_t *p_sys = container_of(p_tsout, es_out_sys_t, out);
 
@@ -720,7 +748,7 @@ static int PrivControlLocked( es_out_t *p_tsout, int i_query, va_list args )
     case ES_OUT_PRIV_SET_EOS:
     {
         ts_cmd_t cmd;
-        if( CmdInitPrivControl( &cmd.privcontrol, i_query, args, p_sys->b_delayed ) )
+        if( CmdInitPrivControl( &cmd.privcontrol, in, i_query, args, p_sys->b_delayed ) )
             return VLC_EGENERIC;
         if( p_sys->b_delayed )
         {
@@ -732,12 +760,12 @@ static int PrivControlLocked( es_out_t *p_tsout, int i_query, va_list args )
     case ES_OUT_PRIV_GET_WAKE_UP: /* TODO ? */
     {
         vlc_tick_t *pi_wakeup = va_arg( args, vlc_tick_t* );
-        return ControlLockedGetWakeup( p_tsout, pi_wakeup );
+        return ControlLockedGetWakeup( p_tsout, in, pi_wakeup );
     }
     case ES_OUT_PRIV_GET_BUFFERING:
     {
         bool *pb_buffering = va_arg( args, bool* );
-        return ControlLockedGetBuffering( p_tsout, pb_buffering );
+        return ControlLockedGetBuffering( p_tsout, in, pb_buffering );
     }
     case ES_OUT_PRIV_SET_PAUSE_STATE:
     {
@@ -745,21 +773,21 @@ static int PrivControlLocked( es_out_t *p_tsout, int i_query, va_list args )
         const bool b_paused = (bool)va_arg( args, int );
         const vlc_tick_t i_date = va_arg( args, vlc_tick_t );
 
-        return ControlLockedSetPauseState( p_tsout, b_source_paused, b_paused, i_date );
+        return ControlLockedSetPauseState( p_tsout, in, b_source_paused, b_paused, i_date );
     }
     case ES_OUT_PRIV_SET_RATE:
     {
         const float src_rate = va_arg( args, double );
         const float rate = va_arg( args, double );
 
-        return ControlLockedSetRate( p_tsout, src_rate, rate );
+        return ControlLockedSetRate( p_tsout, in, src_rate, rate );
     }
     case ES_OUT_PRIV_SET_FRAME_NEXT:
     {
-        return ControlLockedSetFrameNext( p_tsout );
+        return ControlLockedSetFrameNext( p_tsout, in );
     }
     case ES_OUT_PRIV_GET_GROUP_FORCED:
-        return es_out_vaPrivControl( p_sys->p_out, i_query, args );
+        return es_out_in_vaPrivControl( p_sys->p_out, in, i_query, args );
     /* Invalid queries for this es_out level */
     case ES_OUT_PRIV_SET_ES:
     case ES_OUT_PRIV_UNSET_ES:
@@ -777,7 +805,7 @@ static int PrivControlLocked( es_out_t *p_tsout, int i_query, va_list args )
     }
 }
 
-static int PrivControl( es_out_t *p_tsout, int i_query, va_list args )
+static int PrivControl( es_out_t *p_tsout, input_source_t *in, int i_query, va_list args )
 {
     es_out_sys_t *p_sys = container_of(p_tsout, es_out_sys_t, out);
     int i_ret;
@@ -786,7 +814,7 @@ static int PrivControl( es_out_t *p_tsout, int i_query, va_list args )
 
     TsAutoStop( p_tsout );
 
-    i_ret = PrivControlLocked( p_tsout, i_query, args );
+    i_ret = PrivControlLocked( p_tsout, in, i_query, args );
 
     vlc_mutex_unlock( &p_sys->lock );
 
@@ -1206,6 +1234,7 @@ static void *TsRun( void *p_data )
             break;
         case C_PRIVCONTROL:
             CmdExecutePrivControl( p_ts->p_tsout, &cmd.privcontrol );
+            CmdCleanPrivControl( &cmd.privcontrol );
             break;
         case C_DEL:
             CmdExecuteDel( p_ts->p_tsout, &cmd.del );
@@ -1443,6 +1472,7 @@ static void CmdClean( ts_cmd_t *p_cmd )
         CmdCleanControl( &p_cmd->control );
         break;
     case C_PRIVCONTROL:
+        CmdCleanPrivControl( &p_cmd->privcontrol );
         break;
     case C_DEL:
         break;
@@ -1776,13 +1806,17 @@ static void CmdCleanControl( ts_cmd_control_t *p_cmd )
     }
 }
 
-static int CmdInitPrivControl( ts_cmd_privcontrol_t *p_cmd, int i_query, va_list args, bool b_copy )
+static int CmdInitPrivControl( ts_cmd_privcontrol_t *p_cmd, input_source_t *in, int i_query, va_list args, bool b_copy )
 {
-    VLC_UNUSED( b_copy );
     p_cmd->header.i_type = C_PRIVCONTROL;
     p_cmd->header.i_date = vlc_tick_now();
     p_cmd->i_query = i_query;
 
+    if( b_copy )
+        p_cmd->in = in ? input_source_Hold( in ) : NULL;
+    else
+        p_cmd->in = in;
+
     switch( i_query )
     {
     /* Pass-through control */
@@ -1825,24 +1859,31 @@ static int CmdExecutePrivControl( es_out_t *p_tsout, ts_cmd_privcontrol_t *p_cmd
 {
     es_out_sys_t *p_sys = container_of(p_tsout, es_out_sys_t, out);
     const int i_query = p_cmd->i_query;
+    input_source_t *in = p_cmd->in;
 
     switch( i_query )
     {
     /* Pass-through control */
     case ES_OUT_PRIV_SET_MODE:    /* arg1= int                            */
-        return es_out_PrivControl( p_sys->p_out, i_query, p_cmd->u.i_int );
+        return es_out_in_PrivControl( p_sys->p_out, in, i_query, p_cmd->u.i_int );
     case ES_OUT_PRIV_SET_JITTER:
-        return es_out_PrivControl( p_sys->p_out, i_query, p_cmd->u.jitter.i_pts_delay,
-                                   p_cmd->u.jitter.i_pts_jitter,
-                                   p_cmd->u.jitter.i_cr_average );
+        return es_out_in_PrivControl( p_sys->p_out, in, i_query, p_cmd->u.jitter.i_pts_delay,
+                                      p_cmd->u.jitter.i_pts_jitter,
+                                      p_cmd->u.jitter.i_cr_average );
     case ES_OUT_PRIV_SET_TIMES:
-        return es_out_PrivControl( p_sys->p_out, i_query,
-                                   p_cmd->u.times.f_position,
-                                   p_cmd->u.times.i_time,
-                                   p_cmd->u.times.i_normal_time,
-                                   p_cmd->u.times.i_length );
+        return es_out_in_PrivControl( p_sys->p_out, in, i_query,
+                                      p_cmd->u.times.f_position,
+                                      p_cmd->u.times.i_time,
+                                      p_cmd->u.times.i_normal_time,
+                                      p_cmd->u.times.i_length );
     case ES_OUT_PRIV_SET_EOS: /* no arg */
-        return es_out_PrivControl( p_sys->p_out, i_query );
+        return es_out_in_PrivControl( p_sys->p_out, in, i_query );
     default: vlc_assert_unreachable();
     }
 }
+
+static void CmdCleanPrivControl( ts_cmd_privcontrol_t *p_cmd )
+{
+    if( p_cmd->in )
+        input_source_Release( p_cmd->in );
+}


=====================================
src/input/input.c
=====================================
@@ -269,7 +269,6 @@ input_thread_t *input_Create( vlc_object_t *p_parent,
     priv->is_stopped = false;
     priv->b_recording = false;
     priv->rate = 1.f;
-    priv->normal_time = VLC_TICK_0;
     TAB_INIT( priv->i_attachment, priv->attachment );
     priv->p_sout   = NULL;
     priv->b_out_pace_control = priv->type == INPUT_TYPE_THUMBNAILING;
@@ -566,34 +565,45 @@ static int MainLoopTryRepeat( input_thread_t *p_input )
     return VLC_SUCCESS;
 }
 
-/**
- * Update timing infos and statistics.
- */
-static void MainLoopStatistics( input_thread_t *p_input )
+static void InputSourceStatistics( input_source_t *source, es_out_t *out )
 {
-    input_thread_private_t *priv = input_priv(p_input);
     double f_position = 0.0;
     vlc_tick_t i_time;
     vlc_tick_t i_length;
+    vlc_tick_t i_normal_time;
 
     /* update input status variables */
-    if( demux_Control( priv->master->p_demux,
+    if( demux_Control( source->p_demux,
                        DEMUX_GET_POSITION, &f_position ) )
         f_position = 0.0;
 
-    if( demux_Control( priv->master->p_demux, DEMUX_GET_TIME, &i_time ) )
+    if( demux_Control( source->p_demux, DEMUX_GET_TIME, &i_time ) )
         i_time = VLC_TICK_INVALID;
 
-    if( demux_Control( priv->master->p_demux, DEMUX_GET_LENGTH, &i_length ) )
+    if( demux_Control( source->p_demux, DEMUX_GET_LENGTH, &i_length ) )
         i_length = 0;
 
-    /* In case of failure (not implemented or in case of seek), use the last
-     * normal_time value (that is VLC_TICK_0 by default). */
-    if (demux_Control( priv->master->p_demux, DEMUX_GET_NORMAL_TIME, &priv->normal_time ) != VLC_SUCCESS)
-        priv->normal_time = VLC_TICK_0;
+    /* In case of failure (not implemented or in case of seek), use VLC_TICK_0. */
+    if (demux_Control( source->p_demux, DEMUX_GET_NORMAL_TIME, &i_normal_time ) != VLC_SUCCESS)
+        i_normal_time = VLC_TICK_0;
 
-    es_out_SetTimes( priv->p_es_out, f_position, i_time, priv->normal_time,
-                     i_length );
+    es_out_SetTimes( out, f_position, i_time, i_normal_time, i_length );
+}
+
+/**
+ * Update timing infos and statistics.
+ */
+static void MainLoopStatistics( input_thread_t *p_input )
+{
+    input_thread_private_t *priv = input_priv(p_input);
+
+    InputSourceStatistics( priv->master, priv->p_es_out );
+
+    for( int i = 0; i < priv->i_slave; i++ )
+    {
+        input_source_t *in = priv->slave[i];
+        InputSourceStatistics( in, in->p_slave_es_out );
+    }
 
     if (priv->stats != NULL)
     {
@@ -1298,8 +1308,7 @@ static int Init( input_thread_t * p_input )
     if( i_length == 0 )
         i_length = input_item_GetDuration( priv->p_item );
 
-    input_SendEventTimes( p_input, 0.0, VLC_TICK_INVALID, priv->normal_time,
-                          i_length );
+    input_SendEventTimes( p_input, 0.0, VLC_TICK_INVALID, VLC_TICK_0, i_length );
 
     if( priv->type != INPUT_TYPE_PREPARSING )
     {
@@ -2609,6 +2618,8 @@ static input_source_t *InputSourceNew( const char *psz_mrl )
         vlc_hash_FinishHex( &md5, in->str_id );
     }
 
+    in->i_normal_time = VLC_TICK_0;
+
     return in;
 }
 


=====================================
src/input/input_internal.h
=====================================
@@ -392,6 +392,9 @@ struct input_source_t
     /* */
     vlc_tick_t i_pts_delay;
 
+    /* Read-write protected by es_out.c lock */
+    vlc_tick_t i_normal_time;
+
     bool       b_eof;   /* eof of demuxer */
 
 };
@@ -464,7 +467,6 @@ typedef struct input_thread_private_t
     bool        is_stopped;
     bool        b_recording;
     float       rate;
-    vlc_tick_t  normal_time;
 
     /* Playtime configuration and state */
     vlc_tick_t  i_start;    /* :start-time,0 by default */



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/167ab59642dae748f704d08c7f8be77bf00f1d1a...70e897847cc6d94ba349b8f12ce7fb2c68c414d3

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/167ab59642dae748f704d08c7f8be77bf00f1d1a...70e897847cc6d94ba349b8f12ce7fb2c68c414d3
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list