Commit b98a2ef1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ALSA: correct S/PDIF start timing (fixes #6565)

This is completely untested, but it seems logical.
(cherry picked from commit 89d23df7)
parent 1dd7d2ab
......@@ -562,22 +562,30 @@ static void Play (audio_output_t *aout, block_t *block)
if (state != SND_PCM_STATE_RUNNING)
{
delay = block->i_pts - (mdate () + delay);
if (delay > 0 && aout->format.i_format != VLC_CODEC_SPDIFL)
if (delay > 0)
{
if (aout->format.i_format != VLC_CODEC_SPDIFL)
{
frames = (delay * aout->format.i_rate) / CLOCK_FREQ;
msg_Dbg (aout, "prepending %ld zeroes", frames);
void *pad = calloc (frames, aout->format.i_bytes_per_frame);
if (likely(pad != NULL))
void *z = calloc (frames, aout->format.i_bytes_per_frame);
if (likely(z != NULL))
{
snd_pcm_writei (pcm, pad, frames);
free (pad);
snd_pcm_writei (pcm, z, frames);
free (z);
delay = 0;
}
}
/* Lame fallback if zero padding does not work */
if (delay > 0)
mwait (block->i_pts - delay);
{
msg_Dbg (aout, "deferring start (%"PRId64" us)", delay);
msleep (delay);
}
}
else
msg_Dbg (aout, "starting late (%"PRId64" us)", delay);
}
else
aout_TimeReport (aout, block->i_pts - delay);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment