# HG changeset patch # User reimar # Date 1235052033 0 # Node ID 28fe0787a67c89bc58f57671bfc7c902f2cb8fc0 # Parent 6e90a47a6aaf48a120cbb2ea4a5948159950bb57 Work around a PulseAudio bug that causes MPlayer to hang after unpausing. diff -r 6e90a47a6aaf -r 28fe0787a67c libao2/ao_pulse.c --- a/libao2/ao_pulse.c Thu Feb 19 13:57:14 2009 +0000 +++ b/libao2/ao_pulse.c Thu Feb 19 14:00:33 2009 +0000 @@ -52,6 +52,8 @@ /** A temporary variable to store the current volume */ static pa_cvolume volume; +static int broken_pause; + LIBAO_EXTERN(pulse) #define GENERIC_ERR_MSG(ctx, str) \ @@ -138,6 +140,7 @@ char *devarg = NULL; char *host = NULL; char *sink = NULL; + char *version = pa_get_library_version(); if (ao_subdevice) { devarg = strdup(ao_subdevice); @@ -146,6 +149,17 @@ if (devarg[0]) host = devarg; } + broken_pause = 0; + // not sure which versions are affected, assume 0.9.1* + // known bad: 0.9.14, 0.9.13 + // known good: 0.9.9, 0.9.10 + // to test: pause, wait ca. 5 seconds framestep and see if MPlayer hangs somewhen + if (strncmp(version, "0.9.1", 5) == 0 && strncmp(version, "0.9.10", 6) != 0) { + mp_msg(MSGT_AO, MSGL_WARN, "[pulse] working around probably broken pause functionality,\n" + " see http://www.pulseaudio.org/ticket/440\n"); + broken_pause = 1; + } + ss.channels = channels; ss.rate = rate_hz; @@ -288,6 +302,10 @@ /** Resume the audio stream by uncorking it on the server */ static void audio_resume(void) { + // without this, certain versions will cause an infinite hang because + // pa_stream_writable_size returns 0 always. + // Note that this workaround causes A-V desync after pause + if (broken_pause) reset(); cork(0); }