acp: strip UCM alibpref from mapping

Strip the alibpref from the device string in the mapping name. This
name is used to generate the node name eventually and we don't want
this random identifier in it.

Fixes #1362
This commit is contained in:
Wim Taymans 2021-06-29 17:43:00 +02:00
parent d1c6114423
commit ae89ae093e
3 changed files with 21 additions and 11 deletions

View file

@ -242,24 +242,18 @@ static void init_device(pa_card *impl, pa_alsa_device *dev, pa_alsa_direction_t
dev->ports = pa_hashmap_new(pa_idxset_string_hash_func,
pa_idxset_string_compare_func);
if (m->ucm_context.ucm) {
const char *alibpref = NULL;
dev->ucm_context = &m->ucm_context;
if ((snd_use_case_get(impl->ucm.ucm_mgr, "_alibpref", &alibpref) != 0))
alibpref = NULL;
if (alibpref == NULL)
alibpref = strdup("_ucm");
if (alibpref != NULL) {
if (impl->ucm.alibpref != NULL) {
char **d;
for (d = m->device_strings; *d; d++) {
if (pa_startswith(*d, alibpref)) {
size_t plen = strlen(alibpref);
if (pa_startswith(*d, impl->ucm.alibpref)) {
size_t plen = strlen(impl->ucm.alibpref);
size_t len = strlen(*d);
memmove(*d, (*d) + plen, len - plen + 1);
dev->device.flags |= ACP_DEVICE_UCM_DEVICE;
break;
}
}
free((void*)alibpref);
}
}
pa_dynarray_init(&dev->port_array, NULL);