diff options
author | Kevin Mitchell <kevmitch@gmail.com> | 2015-10-06 02:07:00 -0700 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2015-10-06 02:24:36 -0700 |
commit | beae60bcd51c8099c3c1a6271dda16155d92e78c (patch) | |
tree | b36dc93411a9dc41ee9301e74d81d4b5ea509f48 | |
parent | 29e42b78c01a4a7d6b549c568fb9df40577f48af (diff) | |
download | mpv-beae60bcd51c8099c3c1a6271dda16155d92e78c.tar.bz2 mpv-beae60bcd51c8099c3c1a6271dda16155d92e78c.tar.xz |
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.
-rw-r--r-- | audio/out/ao_alsa.c | 11 |
1 files changed, 7 insertions, 4 deletions
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; } |