Mercurial > mplayer.hg
changeset 34564:96019b1174b8
Workaround a bug in Pulse Audio (http://pulseaudio.org/ticket/866)
that causes 2 second delay while trying to drain the current stream.
It seems that if we wait for the data to be played before calling
the pa_stream_drain function, it would not block for the whole
duration of its internal buffer, thus avoid the 2 seconds delay.
The code of this workaround is already used in ao_jack and ao_sdl.
Special thanks to Rune Heggtveit <pblc heggtveit n>
who did all the heavy lifting in finding a working solution.
author | iive |
---|---|
date | Fri, 03 Feb 2012 23:11:48 +0000 |
parents | e659a561af75 |
children | 25acb5f98cb4 |
files | libao2/ao_pulse.c |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libao2/ao_pulse.c Fri Feb 03 20:33:32 2012 +0000 +++ b/libao2/ao_pulse.c Fri Feb 03 23:11:48 2012 +0000 @@ -26,6 +26,7 @@ #include "config.h" #include "libaf/af_format.h" +#include "osdep/timer.h" #include "mp_msg.h" #include "audio_out.h" #include "audio_out_internal.h" @@ -249,6 +250,10 @@ /** Destroy libao driver */ static void uninit(int immed) { if (stream && !immed) { + /* Workaround the bug in pa_stream_drain that causes + a delay of 2 second if the buffer is not empty */ + usec_sleep(get_delay() * 1000 * 1000); + pa_threaded_mainloop_lock(mainloop); waitop(pa_stream_drain(stream, success_cb, NULL)); }