summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-05 19:52:05 +0100
committerwm4 <wm4@nowhere>2016-01-05 19:52:05 +0100
commitc1002f6a28dc7419c28b47826353e321733681e3 (patch)
treeabf03d9658cef556277390d46e8e503931ef5895
parent861c126b086fb72c8b7bb4c6552241054d8b74b3 (diff)
downloadmpv-c1002f6a28dc7419c28b47826353e321733681e3.tar.bz2
mpv-c1002f6a28dc7419c28b47826353e321733681e3.tar.xz
ao_pulse: attempt to fall back to an arbitrary sample format
Normally, PulseAudio accepts any combination of sample format, sample rate, channel count/map. Sometimes it does not. For example, the channel rate or channel count have fixed maximum values. We should not fail fatally in such cases, but attempt to fall back to a working format. We could just send pass an "unset" format to Pulse, but this is not too attractive. Pulse could use a format which we do not support, and also doing so much for an obscure corner case is not reasonable. So just pick a format that is very likely supported. This still could fail at runtime (the stream could fail instead of going to the ready state), but this sounds also too complicated. In particular, it doesn't look like pulse will tell us the cause of the stream failure. (Or maybe it does - but I didn't find anything.) Last but not least, our fallback could be less dumb, and e.g. try to fix only one of samplerate or channel count first to reduce the loss, but this is also not particularly worthy the effort. Fixes #2654.
-rw-r--r--audio/out/ao_pulse.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index 13813745f9..d553b6700c 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -431,8 +431,13 @@ static int init(struct ao *ao)
goto unlock_and_fail;
if (!set_format(ao, format)) {
- MP_ERR(ao, "Invalid audio format\n");
- goto unlock_and_fail;
+ ao->channels = (struct mp_chmap) MP_CHMAP_INIT_STEREO;
+ ao->samplerate = 48000;
+ ao->format = AF_FORMAT_FLOAT;
+ if (!set_format(ao, format)) {
+ MP_ERR(ao, "Invalid audio format\n");
+ goto unlock_and_fail;
+ }
}
if (!(priv->stream = pa_stream_new_extended(priv->context, "audio stream",