From cfdd6cab204f1f6160b4d683cfdde57c1fffdb77 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 18 Aug 2020 16:52:09 +0200 Subject: [PATCH] acp: fix UCM off profile --- spa/plugins/alsa/acp/acp.c | 8 +++++--- spa/plugins/alsa/acp/alsa-mixer.h | 1 + spa/plugins/alsa/acp/alsa-ucm.c | 5 ++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spa/plugins/alsa/acp/acp.c b/spa/plugins/alsa/acp/acp.c index 1d4d28704..fa1a8c981 100644 --- a/spa/plugins/alsa/acp/acp.c +++ b/spa/plugins/alsa/acp/acp.c @@ -117,6 +117,7 @@ static void add_profiles(pa_card *impl) ap->profile.name = ap->name = pa_xstrdup("off"); ap->profile.description = ap->description = pa_xstrdup(_("Off")); ap->profile.available = ACP_AVAILABLE_YES; + ap->is_off = true; pa_hashmap_put(impl->profiles, ap->name, ap); PA_HASHMAP_FOREACH(ap, impl->profile_set->profiles, state) { @@ -1029,6 +1030,7 @@ int acp_card_set_profile(struct acp_card *card, uint32_t new_index) struct acp_card_profile **profiles = card->profiles; pa_alsa_profile *op, *np; uint32_t idx; + int res; if (new_index >= card->n_profiles) return -EINVAL; @@ -1057,9 +1059,9 @@ int acp_card_set_profile(struct acp_card *card, uint32_t new_index) /* if UCM is available for this card then update the verb */ if (impl->use_ucm) { - if (pa_alsa_ucm_set_profile(&impl->ucm, impl, np ? np->profile.name : NULL, - op ? op->profile.name : NULL) < 0) { - return -1; + if ((res = pa_alsa_ucm_set_profile(&impl->ucm, impl, np->is_off ? NULL : np->profile.name, + op ? op->profile.name : NULL)) < 0) { + return res; } } diff --git a/spa/plugins/alsa/acp/alsa-mixer.h b/spa/plugins/alsa/acp/alsa-mixer.h index 260db2c07..0b1820eda 100644 --- a/spa/plugins/alsa/acp/alsa-mixer.h +++ b/spa/plugins/alsa/acp/alsa-mixer.h @@ -369,6 +369,7 @@ struct pa_alsa_profile { bool supported:1; bool fallback_input:1; bool fallback_output:1; + bool is_off:1; char **input_mapping_names; char **output_mapping_names; diff --git a/spa/plugins/alsa/acp/alsa-ucm.c b/spa/plugins/alsa/acp/alsa-ucm.c index 53a79925c..15b96f915 100644 --- a/spa/plugins/alsa/acp/alsa-ucm.c +++ b/spa/plugins/alsa/acp/alsa-ucm.c @@ -1337,9 +1337,8 @@ int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, pa_card *card, const char * /* change verb */ pa_log_info("Set UCM verb to %s", profile); - if ((snd_use_case_set(ucm->ucm_mgr, "_verb", profile)) < 0) { - pa_log("Failed to set verb %s", profile); - ret = -1; + if ((ret = snd_use_case_set(ucm->ucm_mgr, "_verb", profile)) < 0) { + pa_log("Failed to set verb %s: %s", profile, snd_strerror(ret)); } /* find active verb */