[vlc-commits] Drain audio output before we claim the buffers are empty

Rémi Denis-Courmont git at videolan.org
Sat Oct 15 11:12:15 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct 13 18:41:01 2011 +0300| [1e1f9d10fe0840d515757a5897014b3a5107e045] | committer: 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).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1e1f9d10fe0840d515757a5897014b3a5107e045
---

 src/audio_output/dec.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 4a47ed1..85b0c15 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -367,13 +367,19 @@ void aout_DecFlush (audio_output_t *aout)
 bool aout_DecIsEmpty (audio_output_t *aout)
 {
     aout_owner_t *owner = aout_owner (aout);
-    mtime_t end_date;
+    mtime_t end_date, now = mdate ();
+    bool empty;
 
     aout_lock (aout);
-    /* FIXME: tell output to drain */
     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);
-    return end_date == VLC_TS_INVALID || end_date <= mdate();
+    return empty;
 }
 
 /**



More information about the vlc-commits mailing list