From f5aec5a2a7703b18d7e5d1b83991039f3414dba8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 10 May 2013 14:02:04 +0200 Subject: 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. --- audio/out/ao_alsa.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'audio/out/ao_alsa.c') 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 " -- cgit v1.2.3