ucm: add _alibpref to get the private device prefix

It may be useful to get the device prefix for the local configuration.

Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1251
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-06-02 11:09:43 +02:00
parent ddfc32abf5
commit 0e4ba2ea8c
2 changed files with 22 additions and 0 deletions

View file

@ -258,6 +258,7 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
* - _verb - return current verb
* - _file - return configuration file loaded for current card
* - _alibcfg - return private alsa-lib's configuration for current card
* - _alibpref - return private alsa-lib's configuration device prefix for current card
*
* - [=]{NAME}[/[{modifier}|{/device}][/{verb}]]
* - value identifier {NAME}

View file

@ -2138,6 +2138,25 @@ static int get_alibcfg(snd_use_case_mgr_t *uc_mgr, char **str)
return 0;
}
/**
* \brief Get device prefix for private alsa-lib configuration
* \param uc_mgr Use case manager
* \param str Returned value string
* \return Zero on success (value is filled), otherwise a negative error code
*/
static int get_alibpref(snd_use_case_mgr_t *uc_mgr, char **str)
{
const size_t l = 9;
char *s;
s = malloc(l);
if (s == NULL)
return -ENOMEM;
snprintf(s, l, "_ucm%04X", uc_mgr->ucm_card_number);
*str = s;
return 0;
}
/**
* \brief Get current - string
* \param uc_mgr Use case manager
@ -2193,6 +2212,8 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
} else if (strcmp(identifier, "_alibcfg") == 0) {
err = get_alibcfg(uc_mgr, (char **)value);
} else if (strcmp(identifier, "_alibpref") == 0) {
err = get_alibpref(uc_mgr, (char **)value);
} else if (identifier[0] == '_') {
err = -ENOENT;
} else {