[vlc-devel] workaround audio drops on openbsd
Alexandre Ratchov
alex at caoua.org
Wed Apr 17 08:35:14 CEST 2013
On Tue, Apr 16, 2013 at 10:08:16AM +0200, Rémi Denis-Courmont wrote:
> On Mon, 15 Apr 2013 22:11:22 +0200, Alexandre Ratchov <alex at caoua.org>
> wrote:
> > Is there a way to "shift" VLC time reference, or to make it use
> > aout->time_get() as clock reference? Other suggestions?
>
> No, that is a unclaimed bounty. Regardless, it is not something to rely
> on; some inputs impose their pace and the audio output must follow.
>
ok
> > diff --git a/modules/audio_output/sndio.c b/modules/audio_output/sndio.c
> > index a60c309..7139e25 100644
> > --- a/modules/audio_output/sndio.c
> > +++ b/modules/audio_output/sndio.c
> > @@ -59,6 +59,7 @@ struct aout_sys_t
> > unsigned rate;
> > unsigned volume;
> > bool mute;
> > + mtime_t init_time, start_time;
> > };
> >
> > /** Initializes an sndio playback stream */
> > @@ -193,6 +194,7 @@ static int Start (audio_output_t *aout,
> > audio_sample_format_t *restrict fmt)
> > sys->delay = 0;
> > sio_onmove (sys->hdl, PositionChanged, aout);
> > sio_start (sys->hdl);
> > + sys->init_time = mdate ();
> > return VLC_SUCCESS;
> >
> > error:
> > @@ -212,6 +214,8 @@ static void PositionChanged (void *arg, int delta)
> > audio_output_t *aout = arg;
> > aout_sys_t *sys = aout->sys;
> >
> > + if (!sys->started)
>
> Why is that condition?
to remember the time when DMA actually started (sys->start_time),
i.e. the mdate() when the first frame hit Joe's ears.
> > + sys->start_time = mdate ();
> > sys->delay -= delta;
> > sys->started = 1;
> > }
> > @@ -222,7 +226,8 @@ static int TimeGet (audio_output_t *aout, mtime_t
> > *restrict delay)
> >
> > if (!sys->started)
> > return -1;
>
> Unfortunately, VLC currently needs to know the latency before playback
> actually starts. You will get a glitch at startup...
Do you mean by latency the time it takes to the last frame written
to hit Joe's ears?
I tried it and it resulted in a endless loop with:
[0x14591f8] main audio output warning: playback too late (351792): up-sampling
[0x14591f8] main audio output warning: playback way too late (352176): flushing
AFAIU, the initial start delay (350ms) triggers corrections, and
this is what I try to avoid.
> > - *delay = (mtime_t)sys->delay * CLOCK_FREQ / sys->rate;
> > + *delay = (mtime_t)sys->delay * CLOCK_FREQ / sys->rate +
> > + sys->init_time - sys->start_time;
>
> Normally, delay interpolation should be more accurate using the current
> time and the time of the last position update rather than the
> initialization time and first update time...
oh, this is not to interpolate the current hw time. This is to
"lie", reporting a constant time shift (init_time - start_time),
equal to the time DMA took to actually start. This is to avoid
triggering corrections systematically.
-- Alexandre
More information about the vlc-devel
mailing list