[vlc-devel] workaround audio drops on openbsd

Rémi Denis-Courmont remi at remlab.net
Tue Apr 16 10:08:16 CEST 2013


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.

> 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?

> +	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...

> -    *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...

>      return 0;
>  }
>  
> @@ -242,6 +247,7 @@ static void Flush (audio_output_t *aout, bool wait)
>      sio_stop (sys->hdl);
>      sys->started = 0;
>      sys->delay = 0;
> +    sys->init_time = mdate ();
>      sio_start (sys->hdl);
>      (void)wait;
>  }
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel

-- 
Rémi Denis-Courmont
Sent from my collocated server



More information about the vlc-devel mailing list