summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_alsa.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-02 23:57:12 +0100
committerwm4 <wm4@nowhere>2015-11-03 00:23:28 +0100
commit587bb5e81193526d282eee7aacbaf5396f93d822 (patch)
tree76b8050ef333f34d68ca0f17b915b0113024b208 /audio/out/ao_alsa.c
parentc2220c526d6ce49c724059403e6e408b438013b6 (diff)
downloadmpv-587bb5e81193526d282eee7aacbaf5396f93d822.tar.bz2
mpv-587bb5e81193526d282eee7aacbaf5396f93d822.tar.xz
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.
Diffstat (limited to 'audio/out/ao_alsa.c')
-rw-r--r--audio/out/ao_alsa.c24
1 files changed, 12 insertions, 12 deletions
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");