[MPlayer-cvslog] r34652 - trunk/libao2/ao_pulse.c

iive subversion at mplayerhq.hu
Sat Feb 4 00:11:48 CET 2012


Author: iive
Date: Sat Feb  4 00:11:48 2012
New Revision: 34652

Log:
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.

Modified:
   trunk/libao2/ao_pulse.c

Modified: trunk/libao2/ao_pulse.c
==============================================================================
--- trunk/libao2/ao_pulse.c	Fri Feb  3 21:33:32 2012	(r34651)
+++ trunk/libao2/ao_pulse.c	Sat Feb  4 00:11:48 2012	(r34652)
@@ -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 @@ fail:
 /** 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));
     }


More information about the MPlayer-cvslog mailing list