summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-02 23:57:34 +0100
committerwm4 <wm4@nowhere>2015-11-03 00:23:28 +0100
commit3f0d831af0a7247075e1be7a253b4cfca7c2d9ba (patch)
tree4f68cf7397fef6aa4ed158b7e509789116b42de8
parent587bb5e81193526d282eee7aacbaf5396f93d822 (diff)
downloadmpv-3f0d831af0a7247075e1be7a253b4cfca7c2d9ba.tar.bz2
mpv-3f0d831af0a7247075e1be7a253b4cfca7c2d9ba.tar.xz
ao_alsa: set access type before format
I'm worried that not restricting the access type before restricting the format will cause problems. While it's unlikely, it might prevent failures in some corner cases. Also, since we by default always use interleaved access (buggy ALSA plugins), this will have no effects at all.
-rw-r--r--audio/out/ao_alsa.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 83c98e6fcc..bae7def017 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -479,10 +479,23 @@ 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");
+ snd_pcm_access_t access = af_fmt_is_planar(ao->format)
+ ? SND_PCM_ACCESS_RW_NONINTERLEAVED
+ : SND_PCM_ACCESS_RW_INTERLEAVED;
+ err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access);
+ if (err < 0 && af_fmt_is_planar(ao->format)) {
+ ao->format = af_fmt_from_planar(ao->format);
+ access = SND_PCM_ACCESS_RW_INTERLEAVED;
+ err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access);
+ }
+ CHECK_ALSA_ERROR("Unable to set access type");
+
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++) {
+ if (af_fmt_is_planar(ao->format) != af_fmt_is_planar(try_formats[n]))
+ continue; // implied SND_PCM_ACCESS mismatches
p->alsa_fmt = find_alsa_format(try_formats[n]);
MP_VERBOSE(ao, "trying format %s\n", af_fmt_to_str(try_formats[n]));
if (snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt) >= 0) {
@@ -500,17 +513,6 @@ static int init_device(struct ao *ao, bool second_try)
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
CHECK_ALSA_ERROR("Unable to set format");
- snd_pcm_access_t access = af_fmt_is_planar(ao->format)
- ? SND_PCM_ACCESS_RW_NONINTERLEAVED
- : SND_PCM_ACCESS_RW_INTERLEAVED;
- err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access);
- if (err < 0 && af_fmt_is_planar(ao->format)) {
- ao->format = af_fmt_from_planar(ao->format);
- access = SND_PCM_ACCESS_RW_INTERLEAVED;
- err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access);
- }
- CHECK_ALSA_ERROR("Unable to set access type");
-
struct mp_chmap dev_chmap = ao->channels;
if (af_fmt_is_spdif(ao->format) || p->cfg_ignore_chmap) {
dev_chmap.num = 0; // disable chmap API