comparison 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
comparison
equal deleted inserted replaced
34695:f7cef684f2a0 34696:f2c90c9dd61c
28 #include "libaf/af_format.h" 28 #include "libaf/af_format.h"
29 #include "osdep/timer.h" 29 #include "osdep/timer.h"
30 #include "mp_msg.h" 30 #include "mp_msg.h"
31 #include "audio_out.h" 31 #include "audio_out.h"
32 #include "audio_out_internal.h" 32 #include "audio_out_internal.h"
33 #include "subopt-helper.h"
33 34
34 #define PULSE_CLIENT_NAME "MPlayer" 35 #define PULSE_CLIENT_NAME "MPlayer"
35 36
36 /** General driver info */ 37 /** General driver info */
37 static const ao_info_t info = { 38 static const ao_info_t info = {
132 {AF_FORMAT_MU_LAW, PA_SAMPLE_ULAW}, 133 {AF_FORMAT_MU_LAW, PA_SAMPLE_ULAW},
133 {AF_FORMAT_A_LAW, PA_SAMPLE_ALAW}, 134 {AF_FORMAT_A_LAW, PA_SAMPLE_ALAW},
134 {AF_FORMAT_UNKNOWN, 0} 135 {AF_FORMAT_UNKNOWN, 0}
135 }; 136 };
136 137
138 static const opt_t subopts[] = {
139 {"broken_pause", OPT_ARG_BOOL, &broken_pause, NULL},
140 {NULL}
141 };
142
137 static int init(int rate_hz, int channels, int format, int flags) { 143 static int init(int rate_hz, int channels, int format, int flags) {
138 struct pa_sample_spec ss; 144 struct pa_sample_spec ss;
139 struct pa_channel_map map; 145 struct pa_channel_map map;
140 const struct format_map_s *fmt_map; 146 const struct format_map_s *fmt_map;
141 char *devarg = NULL; 147 char *devarg = NULL;
142 char *host = NULL; 148 char *host = NULL;
143 char *sink = NULL; 149 char *sink = NULL;
144 const char *version = pa_get_library_version(); 150 const char *version = pa_get_library_version();
145 151
152 broken_pause = -1;
146 if (ao_subdevice) { 153 if (ao_subdevice) {
154 char *opts;
147 devarg = strdup(ao_subdevice); 155 devarg = strdup(ao_subdevice);
148 sink = strchr(devarg, ':'); 156 sink = strchr(devarg, ':');
149 if (sink) *sink++ = 0; 157 if (sink) *sink++ = 0;
150 if (devarg[0]) host = devarg; 158 if (devarg[0]) host = devarg;
151 } 159 opts = strchr(sink, ':');
152 160 if (opts) {
153 broken_pause = 0; 161 *opts++ = 0;
162 if (!sink[0]) sink = NULL;
163 if (subopt_parse(opts, subopts))
164 goto fail;
165 }
166 }
167
154 // not sure which versions are affected, assume 0.9.11* to 0.9.14* 168 // not sure which versions are affected, assume 0.9.11* to 0.9.14*
155 // known bad: 0.9.14, 0.9.13 169 // known bad: 0.9.14, 0.9.13
156 // known good: 0.9.9, 0.9.10, 0.9.15 170 // known good: 0.9.9, 0.9.10, 0.9.15
157 // to test: pause, wait ca. 5 seconds framestep and see if MPlayer hangs somewhen 171 // to test: pause, wait ca. 5 seconds framestep and see if MPlayer hangs somewhen
158 if (strncmp(version, "0.9.1", 5) == 0 && version[5] >= '1' && version[5] <= '4') { 172 if (broken_pause == -1)
173 broken_pause = strncmp(version, "0.9.1", 5) == 0 && version[5] >= '1' && version[5] <= '4';
174 if (broken_pause) {
159 mp_msg(MSGT_AO, MSGL_WARN, "[pulse] working around probably broken pause functionality,\n" 175 mp_msg(MSGT_AO, MSGL_WARN, "[pulse] working around probably broken pause functionality,\n"
160 " see http://www.pulseaudio.org/ticket/440\n"); 176 " see http://www.pulseaudio.org/ticket/440\n");
161 broken_pause = 1;
162 } 177 }
163 178
164 ss.channels = channels; 179 ss.channels = channels;
165 ss.rate = rate_hz; 180 ss.rate = rate_hz;
166 181