From 587bb5e81193526d282eee7aacbaf5396f93d822 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 2 Nov 2015 23:57:12 +0100 Subject: ao_alsa: handle channel count mismatch safeguard after chmap negotiation If the API doesn't list padded channel maps, but the final device channel map is padded, and if unpadded output is not possible (unlike in the somewhat similar dmix case), then we shouldn't apply the channel count mismatch fallback in the beginning. Do it after channel map negotiation instead. --- audio/out/ao_alsa.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'audio/out/ao_alsa.c') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 05fc4086cb..83c98e6fcc 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -535,15 +535,6 @@ static int init_device(struct ao *ao, bool second_try) goto alsa_error; } - if (num_channels != ao->channels.num) { - int req = ao->channels.num; - mp_chmap_from_channels_alsa(&ao->channels, num_channels); - if (!mp_chmap_is_valid(&ao->channels)) - mp_chmap_from_channels(&ao->channels, 2); - MP_ERR(ao, "Asked for %d channels, got %d - fallback to %s.\n", req, - num_channels, mp_chmap_to_str(&ao->channels)); - } - // Some ALSA drivers have broken delay reporting, so disable the ALSA // resampling plugin by default. if (!p->cfg_resample) { @@ -650,10 +641,10 @@ static int init_device(struct ao *ao, bool second_try) return INIT_BRAINDEATH; } - if (mp_chmap_equals(&chmap, &ao->channels)) { - MP_VERBOSE(ao, "which is what we requested.\n"); - } else if (chmap.num == ao->channels.num) { + if (chmap.num == num_channels) { MP_VERBOSE(ao, "using the ALSA channel map.\n"); + if (mp_chmap_equals(&chmap, &ao->channels)) + MP_VERBOSE(ao, "which is what we requested.\n"); ao->channels = chmap; } else { MP_WARN(ao, "ALSA channel map conflicts with channel count!\n"); @@ -672,6 +663,15 @@ static int init_device(struct ao *ao, bool second_try) } #endif + if (num_channels != ao->channels.num) { + int req = ao->channels.num; + mp_chmap_from_channels_alsa(&ao->channels, num_channels); + if (!mp_chmap_is_valid(&ao->channels)) + mp_chmap_from_channels(&ao->channels, 2); + MP_ERR(ao, "Asked for %d channels, got %d - fallback to %s.\n", req, + num_channels, mp_chmap_to_str(&ao->channels)); + } + snd_pcm_uframes_t bufsize; err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &bufsize); CHECK_ALSA_ERROR("Unable to get buffersize"); -- cgit v1.2.3