[vlc-devel] [PATCH v3 2/6] clock: add vlc_clock_main_SetInputDrift
Thomas Guillem
thomas at gllm.fr
Mon Mar 15 12:18:59 UTC 2021
Hello,
First, thanks for your reviews,
On Mon, Mar 15, 2021, at 12:06, Denis Charmet wrote:
> 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.
Indeed, that is basically what I want to do when the input is not paced (like livestreams): going back to the VLC 3.0 behavior because it is not working currently with VLC 4.0.
How can we handle clock drift differently (or in a better way)?
Best,
>
>
> > + (clock->delay - main_clock->delay) * rate;
> > }
> >
> > static vlc_tick_t vlc_clock_master_to_system_locked(vlc_clock_t
> > *clock,
> > @@ -282,7 +285,7 @@ static vlc_tick_t
> > vlc_clock_master_to_system_locked(vlc_clock_t *clock,
> > system = vlc_clock_monotonic_to_system_locked(clock, now, ts,
> > rate);
> > }
> >
> > - return system + clock->delay * rate;
> > + return system + main_clock->input_drift + clock->delay * rate;
> > }
> >
> > static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,
> > @@ -370,6 +373,7 @@ vlc_clock_main_t *vlc_clock_main_New(void)
> > main_clock->master = NULL;
> > main_clock->rc = 1;
> >
> > + main_clock->input_drift = 0;
> > main_clock->coeff = 1.0f;
> > main_clock->rate = 1.0f;
> > main_clock->offset = VLC_TICK_INVALID;
> > @@ -439,6 +443,13 @@ void vlc_clock_main_SetDejitter(vlc_clock_main_t
> > *main_clock,
> > vlc_mutex_unlock(&main_clock->lock);
> > }
> >
> > +void vlc_clock_main_SetInputDrift(vlc_clock_main_t *main_clock,
> > double drift)
> > +{
> > + vlc_mutex_lock(&main_clock->lock);
> > + main_clock->input_drift = drift;
> > + vlc_mutex_unlock(&main_clock->lock);
> > +}
> > +
> > void vlc_clock_main_ChangePause(vlc_clock_main_t *main_clock,
> > vlc_tick_t now,
> > bool paused)
> > {
> > diff --git a/src/clock/clock.h b/src/clock/clock.h
> > index f780d448bcc..f628024e057 100644
> > --- a/src/clock/clock.h
> > +++ b/src/clock/clock.h
> > @@ -90,6 +90,14 @@ void vlc_clock_main_SetFirstPcr(vlc_clock_main_t
> > *main_clock,
> > void vlc_clock_main_SetInputDejitter(vlc_clock_main_t *main_clock,
> > vlc_tick_t delay);
> >
> > +/**
> > + * Set the input drift
> > + *
> > + * Set the average drift calculted by the input_clock, it is used to
> > delay all
> > + * output clocks according to this drift.
> > + **/
> > +void vlc_clock_main_SetInputDrift(vlc_clock_main_t *main_clock,
> > double drift);
> > +
> > /**
> > * This function sets the dejitter delay to absorb the clock jitter
> > *
>
> Regards,
> --
> Denis Charmet - TypX
> Le mauvais esprit est un art de vivre
> _______________________________________________
> 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