alsa: strip and add the _alibpref from device names

Strip the _alibpref from the device name, it contains a local counter
to identify the ucm card that should remain internal. We set a flag on
the device to notify of this.

Re-add the _alibpref of the local card to the device name if the
device was flagged.

See #1286
This commit is contained in:
Wim Taymans 2021-06-10 15:36:26 +02:00
parent 283e13629c
commit 1c513464c8
2 changed files with 8 additions and 3 deletions

View file

@ -9,6 +9,7 @@
#include <limits.h>
#include <spa/pod/filter.h>
#include <spa/utils/string.h>
#include <spa/support/system.h>
#define NAME "alsa-pcm"
@ -49,9 +50,10 @@ int spa_alsa_init(struct state *state)
if ((snd_use_case_get(state->ucm, "_alibpref", &alibpref) != 0))
alibpref = NULL;
if (alibpref != NULL) {
size_t len = strlen(alibpref);
if (len > 4 && strncmp(state->props.device, alibpref, 4) == 0)
memcpy(state->props.device, alibpref, len);
char name[sizeof(state->props.device)];
spa_scnprintf(name, sizeof(name), "%s%s", alibpref,
state->props.device);
strcpy(state->props.device, name);
}
}
return 0;