From beae60bcd51c8099c3c1a6271dda16155d92e78c Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Tue, 6 Oct 2015 02:07:00 -0700 Subject: ao_alsa: fix failure to find any sampleformat Set format to invalid after each failed test. This way the final check for valid format will actually fail if no formats work. --- audio/out/ao_alsa.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index a9d642566a..3b4977a2ff 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -478,16 +478,19 @@ static int init_device(struct ao *ao, bool second_try) err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams); CHECK_ALSA_ERROR("Unable to get initial parameters"); + bool found_format = false; int try_formats[AF_FORMAT_COUNT]; af_get_best_sample_formats(ao->format, try_formats); for (int n = 0; try_formats[n]; n++) { - ao->format = try_formats[n]; - p->alsa_fmt = find_alsa_format(ao->format); - if (snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt) >= 0) + p->alsa_fmt = find_alsa_format(try_formats[n]); + if (snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt) >= 0) { + ao->format = try_formats[n]; + found_format = true; break; + } } - if (!ao->format) { + if (!found_format) { MP_ERR(ao, "Can't find appropriate sample format.\n"); goto alsa_error; } -- cgit v1.2.3