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

Drain audio output before we claim the buffers are empty

This fixes the last bits of audio loss at end of stream... for the
audio output implementing drain (ALSA and PulseAudio so far).
parent 4659c26f
...@@ -367,13 +367,19 @@ void aout_DecFlush (audio_output_t *aout) ...@@ -367,13 +367,19 @@ void aout_DecFlush (audio_output_t *aout)
bool aout_DecIsEmpty (audio_output_t *aout) bool aout_DecIsEmpty (audio_output_t *aout)
{ {
aout_owner_t *owner = aout_owner (aout); aout_owner_t *owner = aout_owner (aout);
mtime_t end_date; mtime_t end_date, now = mdate ();
bool empty;
aout_lock (aout); aout_lock (aout);
/* FIXME: tell output to drain */
end_date = date_Get (&owner->sync.date); end_date = date_Get (&owner->sync.date);
empty = end_date == VLC_TS_INVALID || end_date <= now;
if (empty)
/* The last PTS has elapsed already. So the underlying audio output
* buffer should be empty or almost. Thus draining should be fast
* and will not block the caller too long. */
aout_OutputFlush (aout, true);
aout_unlock (aout); aout_unlock (aout);
return end_date == VLC_TS_INVALID || end_date <= mdate(); return empty;
} }
/** /**
......
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