summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-04 21:54:08 +0200
committerwm4 <wm4@nowhere>2015-06-04 21:54:08 +0200
commitb2d058ef00513d52734c2b61e7a8be7b51fc01dd (patch)
treeb812bd846944056e324c63b57786334760a1b0bc
parentfd96bddca98b88e77d6047371b54d6065c4260c2 (diff)
downloadmpv-b2d058ef00513d52734c2b61e7a8be7b51fc01dd.tar.bz2
mpv-b2d058ef00513d52734c2b61e7a8be7b51fc01dd.tar.xz
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.
-rw-r--r--audio/out/ao_alsa.c12
1 files changed, 6 insertions, 6 deletions
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)