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.
This commit is contained in:
wm4 2013-05-10 14:02:04 +02:00
parent ecc6e379b2
commit f5aec5a2a7
1 changed files with 6 additions and 4 deletions

View File

@ -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 "