summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-10 14:02:04 +0200
committerwm4 <wm4@nowhere>2013-05-12 21:24:57 +0200
commitf5aec5a2a7703b18d7e5d1b83991039f3414dba8 (patch)
treeb3b1896c72291a863c5d73857856abec6f91c309 /audio
parentecc6e379b24dd5e37b864ae599a154880a2bd2d0 (diff)
downloadmpv-f5aec5a2a7703b18d7e5d1b83991039f3414dba8.tar.bz2
mpv-f5aec5a2a7703b18d7e5d1b83991039f3414dba8.tar.xz
ao_alsa: set fallback if format unknown
The snd_pcm_hw_params_test_format() call actually crashes in alsa-lib if called with SND_PCM_FORMAT_UNKNOWN, so the already existing fallback code won't work in this case.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_alsa.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index bb7a5cbb15..93327881e5 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -444,8 +444,6 @@ static int init(struct ao *ao, char *params)
snd_lib_error_set_handler(alsa_error_handler);
- p->alsa_fmt = find_alsa_format(ao->format);
-
//subdevice parsing
// set defaults
block = 1;
@@ -516,8 +514,12 @@ static int init(struct ao *ao, char *params)
(p->alsa, alsa_hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
CHECK_ALSA_ERROR("Unable to set access type");
- /* workaround for nonsupported formats
- sets default format to S16_LE if the given formats aren't supported */
+ p->alsa_fmt = find_alsa_format(ao->format);
+ if (p->alsa_fmt == SND_PCM_FORMAT_UNKNOWN) {
+ p->alsa_fmt = SND_PCM_FORMAT_S16;
+ ao->format = AF_FORMAT_S16_NE;
+ }
+
err = snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt);
if (err < 0) {
mp_tmsg(MSGT_AO, MSGL_INFO, "[AO_ALSA] Format %s is not supported "