[vlc-devel] [PATCH v3 2/6] clock: add vlc_clock_main_SetInputDrift

Thomas Guillem thomas at gllm.fr
Tue Mar 16 16:13:23 UTC 2021



On Tue, Mar 16, 2021, at 17:04, Rémi Denis-Courmont wrote:
> Le maanantaina 15. maaliskuuta 2021, 13.06.45 EET Denis Charmet a écrit :
> > On 2021-03-12 16:08, Thomas Guillem wrote:
> > > ---
> > > 
> > >  src/clock/clock.c | 15 +++++++++++++--
> > >  src/clock/clock.h |  8 ++++++++
> > >  2 files changed, 21 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/src/clock/clock.c b/src/clock/clock.c
> > > index cfbb5eb6f6d..0bb2a9fe375 100644
> > > --- a/src/clock/clock.c
> > > +++ b/src/clock/clock.c
> > > @@ -45,6 +45,7 @@ struct vlc_clock_main_t
> > > 
> > >      average_t coeff_avg; /* Moving average to smooth out the instant
> > > 
> > > coeff */
> > > 
> > >      double rate;
> > >      double coeff;
> > > 
> > > +    vlc_tick_t input_drift;
> > > 
> > >      vlc_tick_t offset;
> > >      vlc_tick_t delay;
> > > 
> > > @@ -88,6 +89,7 @@ static vlc_tick_t
> > > main_stream_to_system(vlc_clock_main_t *main_clock,
> > > 
> > >  static void vlc_clock_main_reset(vlc_clock_main_t *main_clock)
> > >  {
> > >  
> > >      AvgReset(&main_clock->coeff_avg);
> > > 
> > > +    main_clock->input_drift = 0;
> > > 
> > >      main_clock->coeff = 1.0f;
> > >      main_clock->rate = 1.0f;
> > >      main_clock->offset = VLC_TICK_INVALID;
> > > 
> > > @@ -266,7 +268,8 @@ static vlc_tick_t
> > > vlc_clock_slave_to_system_locked(vlc_clock_t *clock,
> > > 
> > >          system = vlc_clock_monotonic_to_system_locked(clock, now, ts,
> > > 
> > > rate);
> > > 
> > >      }
> > > 
> > > -    return system + (clock->delay - main_clock->delay) * rate;
> > > +    return system + main_clock->input_drift +
> > 
> > You cannot do that. The whole point of the main clock is to be the
> > reference used to calculate the different drifts of other clocks. The
> > main clock cannot drift it's the monotonic clock if you start doing that
> > you are basically going back to the PCR master of the previous versions.
> 
> I think it's probably even worse than that. Because this adds the drift 
> directly, this will lead to a permanently unstable clock, that on average will 
> be roughly the input clock.

It's an average, so it's not that "unstable".

> 
> I don't expect anything good to come out of that.

It will be used only for inputs with access that can't control the pace (udp, live...) and it's already the case in 3.0.

> 
> -- 
> Rémi Denis-Courmont
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list