mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: alsa: Try to initialise card_index from path if needed
If the PCM is loaded directly using only api.alsa.path, state->card_index may never be initialised, and then we end up opening the wrong ctl device. Let's try a fallback for this case.
This commit is contained in:
parent
ae37dd7773
commit
90075b838c
1 changed files with 14 additions and 0 deletions
|
|
@ -888,6 +888,7 @@ int open_card_ctl(struct state *state)
|
|||
char card_name[256];
|
||||
|
||||
snprintf(card_name, sizeof(card_name), "hw:%d", state->card_index);
|
||||
spa_log_debug(state->log, "Trying to open ctl device '%s'", card_name);
|
||||
|
||||
err = snd_ctl_open(&state->ctl, card_name, SND_CTL_NONBLOCK);
|
||||
if (err < 0) {
|
||||
|
|
@ -954,6 +955,8 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info)
|
|||
state->multi_rate = true;
|
||||
state->htimestamp = false;
|
||||
state->htimestamp_max_errors = MAX_HTIMESTAMP_ERROR;
|
||||
state->card_index = SPA_ID_INVALID;
|
||||
|
||||
for (i = 0; info && i < info->n_items; i++) {
|
||||
const char *k = info->items[i].key;
|
||||
const char *s = info->items[i].value;
|
||||
|
|
@ -989,6 +992,17 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info)
|
|||
alsa_set_param(state, k, s);
|
||||
}
|
||||
}
|
||||
|
||||
if (state->card_index == SPA_ID_INVALID) {
|
||||
/* If we don't have a card index, see if we have a *:<idx> string */
|
||||
sscanf(state->props.device, "%*[^:]:%u", &state->card_index);
|
||||
if (state->card_index == SPA_ID_INVALID) {
|
||||
spa_log_error(state->log, "Could not determine card index, maybe set %s",
|
||||
SPA_KEY_API_ALSA_CARD);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (state->clock_name[0] == '\0')
|
||||
snprintf(state->clock_name, sizeof(state->clock_name),
|
||||
"api.alsa.%s-%u",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue