From 803c82abb910e2b75092e57bdddfbb2110d1c2d1 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 25 Jan 2024 10:26:11 +0100 Subject: [PATCH] alsa: use chmap by default when using UCM Fixes #2648 --- spa/plugins/alsa/alsa-pcm.c | 11 +++++++++-- spa/plugins/alsa/alsa-pcm.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index a817a0f12..a143fa75e 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -762,6 +762,8 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info) state->card_index = atoi(s); } else if (spa_streq(k, SPA_KEY_API_ALSA_OPEN_UCM)) { state->open_ucm = spa_atob(s); + if (state->open_ucm) + state->props.use_chmap = true; } else if (spa_streq(k, "clock.quantum-limit")) { spa_atou32(s, &state->quantum_limit, 0); } else if (spa_streq(k, SPA_KEY_API_ALSA_BIND_CTLS)) { @@ -1353,6 +1355,8 @@ skip_channels: goto skip_channels; } + spa_log_debug(state->log, "%p: using chmap", state); + sanitize_map(map); spa_pod_builder_int(b, map->channels); @@ -1385,10 +1389,13 @@ skip_channels: spa_pod_builder_pop(b, &f[0]); if (min == max) { - if (state->default_pos.channels == min) + if (state->default_pos.channels == min) { map = &state->default_pos; - else if (min == max && min <= 8) + spa_log_debug(state->log, "%p: using provided default", state); + } else if (min <= 8) { map = &default_map[min]; + spa_log_debug(state->log, "%p: using default %d channel map", state, min); + } } if (map) { spa_pod_builder_prop(b, SPA_FORMAT_AUDIO_position, 0); diff --git a/spa/plugins/alsa/alsa-pcm.h b/spa/plugins/alsa/alsa-pcm.h index c3cfe0e51..172993fbd 100644 --- a/spa/plugins/alsa/alsa-pcm.h +++ b/spa/plugins/alsa/alsa-pcm.h @@ -40,6 +40,7 @@ extern "C" { #define DEFAULT_PERIOD 1024u #define DEFAULT_RATE 48000u #define DEFAULT_CHANNELS 2u +/* CHMAP defaults to true when using UCM */ #define DEFAULT_USE_CHMAP false #define MAX_HTIMESTAMP_ERROR 64