diff libao2/ao_pulse.c @ 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 583c7cfc6653
children aa10c22f69f4
line wrap: on
line diff
--- 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;