From b2d058ef00513d52734c2b61e7a8be7b51fc01dd Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 4 Jun 2015 21:54:08 +0200 Subject: ao_alsa: refuse to use spdif if AES flags can't be set Seems like a good idea to avoid accidentally playing noise by writing spdif data to pure PCM devices. --- audio/out/ao_alsa.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'audio/out/ao_alsa.c') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 02c6a05e08..af31cf7cc7 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -375,6 +375,7 @@ static char *append_params(void *ta_parent, const char *device, const char *p) static int try_open_device(struct ao *ao, const char *device) { struct priv *p = ao->priv; + int err; if (AF_FORMAT_IS_IEC61937(ao->format)) { void *tmp = talloc_new(NULL); @@ -385,8 +386,7 @@ static int try_open_device(struct ao *ao, const char *device) map_iec958_srate(ao->samplerate)); const char *ac3_device = append_params(tmp, device, params); 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); + 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 @@ -403,12 +403,12 @@ static int try_open_device(struct ao *ao, const char *device) } } talloc_free(tmp); - if (err >= 0) - return 0; + } else { + MP_VERBOSE(ao, "opening device '%s'\n", device); + err = snd_pcm_open(&p->alsa, device, SND_PCM_STREAM_PLAYBACK, 0); } - MP_VERBOSE(ao, "opening device '%s'\n", device); - return snd_pcm_open(&p->alsa, device, SND_PCM_STREAM_PLAYBACK, 0); + return err; } static void uninit(struct ao *ao) -- cgit v1.2.3