From b5357e8ba751167832a480ae53d1c54acd1c2f6f Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 7 Oct 2016 17:21:08 +0200 Subject: ao_alsa: try to fallback to "hdmi" before "iec958" for spdif If the "default" device refuses to be opened as spdif device (i.e. it errors due to the AES0 etc. parameters), we were falling back to the iec958 device. This is needed on some systems for smooth operation with PCM vs. spdif. Now change it to try "hdmi" before "iec958", which supposedly helps in other situations. Better suggestions welcome. Apparently kodi does this too, although I didn't check directly. --- audio/out/ao_alsa.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 4d879b1565..90250c9855 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -590,11 +590,16 @@ static int try_open_device(struct ao *ao, const char *device, int mode) 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, mode); + const char *const fallbacks[] = {"hdmi", "iec958", NULL}; + for (int n = 0; fallbacks[n]; n++) { + char *ndev = append_params(tmp, fallbacks[n], params); + MP_VERBOSE(ao, "got error %d; opening iec fallback " + "device '%s'\n", err, ndev); + err = snd_pcm_open + (&p->alsa, ndev, SND_PCM_STREAM_PLAYBACK, mode); + if (err >= 0) + break; + } } } talloc_free(tmp); -- cgit v1.2.3