summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-04 13:10:33 +0200
committerwm4 <wm4@nowhere>2015-06-04 13:10:33 +0200
commitc277c17a930f2df025722405f6c10d4df4f23c99 (patch)
tree3236c38f7e3aefdee11d9e55ab78b50fa4547ad5
parent73401f92ec84ffc04ec4d08bf0e0905824144e2f (diff)
downloadmpv-c277c17a930f2df025722405f6c10d4df4f23c99.tar.bz2
mpv-c277c17a930f2df025722405f6c10d4df4f23c99.tar.xz
ao_alsa: hack against potential spdif failure
-rw-r--r--audio/out/ao_alsa.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 1671373d99..02c6a05e08 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -387,8 +387,23 @@ static int try_open_device(struct ao *ao, const char *device)
MP_VERBOSE(ao, "opening device '%s' => '%s'\n", device, ac3_device);
int err = snd_pcm_open
(&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, 0);
+ if (err < 0) {
+ // Some spdif-capable devices do not accept the AES0 parameter,
+ // and instead require the iec958 pseudo-device (they will play
+ // noise otherwise). Unfortunately, ALSA gives us no way to map
+ // these devices, so try it for the default device only.
+ bstr dev;
+ bstr_split_tok(bstr0(device), ":", &dev, &(bstr){0});
+ if (bstr_equals0(dev, "default")) {
+ ac3_device = append_params(tmp, "iec958", params);
+ MP_VERBOSE(ao, "got error %d; opening iec fallback device '%s'\n",
+ err, ac3_device);
+ err = snd_pcm_open
+ (&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, 0);
+ }
+ }
talloc_free(tmp);
- if (!err)
+ if (err >= 0)
return 0;
}
@@ -419,8 +434,6 @@ static int init_device(struct ao *ao, bool second_try)
int err;
const char *device = "default";
- if (AF_FORMAT_IS_IEC61937(ao->format))
- device = "iec958";
if (ao->device)
device = ao->device;
if (p->cfg_device && p->cfg_device[0])