acp: add options to disable profile and port switching

See #498
This commit is contained in:
Wim Taymans 2020-12-22 13:08:14 +01:00
parent 09265e116e
commit a8937413e6
2 changed files with 17 additions and 2 deletions

View file

@ -910,6 +910,10 @@ impl_init(const struct spa_handle_factory *factory,
if (info) { if (info) {
if ((str = spa_dict_lookup(info, SPA_KEY_API_ALSA_PATH)) != NULL) if ((str = spa_dict_lookup(info, SPA_KEY_API_ALSA_PATH)) != NULL)
snprintf(this->props.device, sizeof(this->props.device)-1, "%s", str); snprintf(this->props.device, sizeof(this->props.device)-1, "%s", str);
if ((str = spa_dict_lookup(info, "api.acp.auto-port")) != NULL)
this->props.auto_port = strcmp(str, "true") == 0 || atoi(str) != 0;
if ((str = spa_dict_lookup(info, "api.acp.auto-profile")) != NULL)
this->props.auto_profile = strcmp(str, "true") == 0 || atoi(str) != 0;
items = alloca((info->n_items) * sizeof(*items)); items = alloca((info->n_items) * sizeof(*items));
spa_dict_for_each(it, info) spa_dict_for_each(it, info)

View file

@ -826,12 +826,23 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id,
device->pending_profile = 1; device->pending_profile = 1;
spa_list_append(&impl->device_list, &device->link); spa_list_append(&impl->device_list, &device->link);
name = pw_properties_get(device->props, "device.name");
if ((str = pw_properties_get(impl->session->props, "alsa.soft-mixer")) != NULL && if ((str = pw_properties_get(impl->session->props, "alsa.soft-mixer")) != NULL &&
(strcmp(str, "*") == 0 || (strcmp(str, "*") == 0 ||
((name = pw_properties_get(device->props, "device.name")) != NULL && (name != NULL && strstr(str, name) != NULL))) {
strstr(str, name) != NULL))) {
pw_properties_set(device->props, "api.alsa.soft-mixer", "true"); pw_properties_set(device->props, "api.alsa.soft-mixer", "true");
} }
if ((str = pw_properties_get(impl->session->props, "alsa.auto-port")) != NULL &&
(strcmp(str, "*") == 0 ||
(name != NULL && strstr(str, name) != NULL))) {
pw_properties_set(device->props, "api.acp.auto-port", "true");
}
if ((str = pw_properties_get(impl->session->props, "alsa.auto-profile")) != NULL &&
(strcmp(str, "*") == 0 ||
(name != NULL && strstr(str, name) != NULL))) {
pw_properties_set(device->props, "api.acp.auto-profile", "true");
}
if (impl->conn && if (impl->conn &&
(card = spa_dict_lookup(info->props, SPA_KEY_API_ALSA_CARD)) != NULL) { (card = spa_dict_lookup(info->props, SPA_KEY_API_ALSA_CARD)) != NULL) {