[vlc-devel] [RFC PATCH] PulseAudio: fix audio drop after an underflow

Rémi Denis-Courmont remi at remlab.net
Fri Apr 17 21:03:27 CEST 2015

It was already pointed out a few weeks ago that this approach is wrong, because underflow can occur during normal playback.

Rémi Denis-Courmont
Sent from my NVIDIA Tegra-powered device

----- Reply message -----
De : "Thomas Guillem" <thomas at gllm.fr>
Pour : <vlc-devel at videolan.org>
Objet : [vlc-devel] [RFC PATCH] PulseAudio: fix audio drop after an underflow
Date : ven., avr. 17, 2015 16:29

This fixes audio drop when the track has a positive delay.

I'm trying to fix an issue with Pulse Audio when changing the audio track
synchronization. Indeed, you can loose audio when you seek after selecting a
positive delay. I think it happens because we wait too long between the last
pa_stream_cork/pa_stream_flush and the first pa_stream_write.

I'm not sure if this is the best way to fix this issue.

An other way to fix this issue is to pause pulse after a flush and start it
again before the next write.

How to reproduce:
$ ./vlc --audio-desync=2500 <video>
Audio will start playing after a delay of 2500ms, but if you seek, you'll loose

modules/audio_output/pulse.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 5947ceb..1284097 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -351,9 +351,13 @@ static void stream_suspended_cb(pa_stream *s, void *userdata)
static void stream_underflow_cb(pa_stream *s, void *userdata)
audio_output_t *aout = userdata;
+    aout_sys_t *sys = aout->sys;

msg_Dbg(aout, "underflow");
-    (void) s;
+    sys->first_pts = VLC_TS_INVALID;
+    pa_stream_set_latency_update_callback(s, NULL, NULL);
+    stream_stop(s, aout);

static int stream_wait(pa_stream *stream, pa_threaded_mainloop *mainloop)

vlc-devel mailing list
To unsubscribe or modify your subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150417/7c0bb6d1/attachment.html>

More information about the vlc-devel mailing list