changeset 34696:f2c90c9dd61c

Add suboption parsing support to ao_pulse and add an option to override auto-detection of broken pause detection.
author reimar
date Sat, 03 Mar 2012 14:03:18 +0000
parents f7cef684f2a0
children ac6b38cd0d45
files DOCS/man/en/mplayer.1 libao2/ao_pulse.c
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Sat Mar 03 13:44:46 2012 +0000
+++ b/DOCS/man/en/mplayer.1	Sat Mar 03 14:03:18 2012 +0000
@@ -3115,10 +3115,14 @@
 PulseAudio audio output driver
 .PD 0
 .RSs
-.IPs "[<host>][:<output sink>]"
+.IPs "[<host>[:<output sink>[:broken_pause]]]"
 Specify the host and optionally output sink to use.
 An empty <host> string uses a local connection, "localhost"
 uses network transfer (most likely not what you want).
+You can also explicitly force the workaround for broken
+pause functionality (default: autodetected).
+To only enable that without specifying a host/sink the
+syntax is \-ao pulse:::broken_pause
 .RE
 .PD 1
 .
--- a/libao2/ao_pulse.c	Sat Mar 03 13:44:46 2012 +0000
+++ b/libao2/ao_pulse.c	Sat Mar 03 14:03:18 2012 +0000
@@ -30,6 +30,7 @@
 #include "mp_msg.h"
 #include "audio_out.h"
 #include "audio_out_internal.h"
+#include "subopt-helper.h"
 
 #define PULSE_CLIENT_NAME "MPlayer"
 
@@ -134,6 +135,11 @@
     {AF_FORMAT_UNKNOWN, 0}
 };
 
+static const opt_t subopts[] = {
+    {"broken_pause", OPT_ARG_BOOL, &broken_pause, NULL},
+    {NULL}
+};
+
 static int init(int rate_hz, int channels, int format, int flags) {
     struct pa_sample_spec ss;
     struct pa_channel_map map;
@@ -143,22 +149,31 @@
     char *sink = NULL;
     const char *version = pa_get_library_version();
 
+    broken_pause = -1;
     if (ao_subdevice) {
+        char *opts;
         devarg = strdup(ao_subdevice);
         sink = strchr(devarg, ':');
         if (sink) *sink++ = 0;
         if (devarg[0]) host = devarg;
+        opts = strchr(sink, ':');
+        if (opts) {
+            *opts++ = 0;
+            if (!sink[0]) sink = NULL;
+            if (subopt_parse(opts, subopts))
+                goto fail;
+        }
     }
 
-    broken_pause = 0;
     // not sure which versions are affected, assume 0.9.11* to 0.9.14*
     // known bad: 0.9.14, 0.9.13
     // known good: 0.9.9, 0.9.10, 0.9.15
     // to test: pause, wait ca. 5 seconds framestep and see if MPlayer hangs somewhen
-    if (strncmp(version, "0.9.1", 5) == 0 && version[5] >= '1' && version[5] <= '4') {
+    if (broken_pause == -1)
+        broken_pause = strncmp(version, "0.9.1", 5) == 0 && version[5] >= '1' && version[5] <= '4';
+    if (broken_pause) {
         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;