alsa-ucm: Set profiles by their struct instance, not their name

While switching profiles, it's possible that we will want to do more
work besides switching UCM verbs. The alsa-card module already has our
profiles as structs, but passes in only the names instead of the entire
struct. Make things work with the struct instead, so we can add other
things (like a UCM context) to it and use those here.

Co-authored-by: Tanu Kaskinen <tanuk@iki.fi>
[Alper: Split into its own commit and integrated Tanu's snippet.]

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
This commit is contained in:
Jaroslav Kysela 2021-06-06 22:06:46 +03:00 committed by Alper Nebi Yasak
parent c83b345169
commit 880ff393f1
3 changed files with 10 additions and 12 deletions

View file

@ -249,8 +249,7 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
/* if UCM is available for this card then update the verb */
if (u->use_ucm) {
if (pa_alsa_ucm_set_profile(&u->ucm, c, nd->profile ? nd->profile->name : NULL,
od->profile ? od->profile->name : NULL) < 0) {
if (pa_alsa_ucm_set_profile(&u->ucm, c, nd->profile, od->profile) < 0) {
ret = -1;
goto finish;
}
@ -302,7 +301,7 @@ static void init_profile(struct userdata *u) {
if (d->profile && u->use_ucm) {
/* Set initial verb */
if (pa_alsa_ucm_set_profile(ucm, u->card, d->profile->name, NULL) < 0) {
if (pa_alsa_ucm_set_profile(ucm, u->card, d->profile, NULL) < 0) {
pa_log("Failed to set ucm profile %s", d->profile->name);
return;
}