mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
alsa-ucm: Always create device conflicting/supported device idxsets
This is intended to make the current and upcoming code a bit clearer, as we won't need to constantly check for the existence of these idxsets before using or operating on them.
This commit is contained in:
parent
b554fc20e9
commit
b1286c62c9
1 changed files with 27 additions and 35 deletions
|
|
@ -506,10 +506,10 @@ static int ucm_get_device_property(
|
||||||
n_confdev = snd_use_case_get_list(uc_mgr, id, &devices);
|
n_confdev = snd_use_case_get_list(uc_mgr, id, &devices);
|
||||||
pa_xfree(id);
|
pa_xfree(id);
|
||||||
|
|
||||||
|
device->conflicting_devices = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||||
if (n_confdev <= 0)
|
if (n_confdev <= 0)
|
||||||
pa_log_debug("No %s for device %s", "_conflictingdevs", device_name);
|
pa_log_debug("No %s for device %s", "_conflictingdevs", device_name);
|
||||||
else {
|
else {
|
||||||
device->conflicting_devices = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
|
||||||
ucm_add_devices_to_idxset(device->conflicting_devices, device, verb->devices, devices, n_confdev);
|
ucm_add_devices_to_idxset(device->conflicting_devices, device, verb->devices, devices, n_confdev);
|
||||||
snd_use_case_free_list(devices, n_confdev);
|
snd_use_case_free_list(devices, n_confdev);
|
||||||
}
|
}
|
||||||
|
|
@ -518,10 +518,10 @@ static int ucm_get_device_property(
|
||||||
n_suppdev = snd_use_case_get_list(uc_mgr, id, &devices);
|
n_suppdev = snd_use_case_get_list(uc_mgr, id, &devices);
|
||||||
pa_xfree(id);
|
pa_xfree(id);
|
||||||
|
|
||||||
|
device->supported_devices = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||||
if (n_suppdev <= 0)
|
if (n_suppdev <= 0)
|
||||||
pa_log_debug("No %s for device %s", "_supporteddevs", device_name);
|
pa_log_debug("No %s for device %s", "_supporteddevs", device_name);
|
||||||
else {
|
else {
|
||||||
device->supported_devices = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
|
||||||
ucm_add_devices_to_idxset(device->supported_devices, device, verb->devices, devices, n_suppdev);
|
ucm_add_devices_to_idxset(device->supported_devices, device, verb->devices, devices, n_suppdev);
|
||||||
snd_use_case_free_list(devices, n_suppdev);
|
snd_use_case_free_list(devices, n_suppdev);
|
||||||
}
|
}
|
||||||
|
|
@ -713,28 +713,18 @@ static void append_lost_relationship(pa_alsa_ucm_device *dev) {
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
pa_alsa_ucm_device *d;
|
pa_alsa_ucm_device *d;
|
||||||
|
|
||||||
if (dev->conflicting_devices) {
|
PA_IDXSET_FOREACH(d, dev->conflicting_devices, idx) {
|
||||||
PA_IDXSET_FOREACH(d, dev->conflicting_devices, idx) {
|
if (pa_idxset_put(d->conflicting_devices, dev, NULL) == 0)
|
||||||
if (!d->conflicting_devices)
|
pa_log_warn("Add lost conflicting device %s to %s",
|
||||||
d->conflicting_devices = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME),
|
||||||
|
pa_proplist_gets(d->proplist, PA_ALSA_PROP_UCM_NAME));
|
||||||
if (pa_idxset_put(d->conflicting_devices, dev, NULL) == 0)
|
|
||||||
pa_log_warn("Add lost conflicting device %s to %s",
|
|
||||||
pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME),
|
|
||||||
pa_proplist_gets(d->proplist, PA_ALSA_PROP_UCM_NAME));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->supported_devices) {
|
PA_IDXSET_FOREACH(d, dev->supported_devices, idx) {
|
||||||
PA_IDXSET_FOREACH(d, dev->supported_devices, idx) {
|
if (pa_idxset_put(d->supported_devices, dev, NULL) == 0)
|
||||||
if (!d->supported_devices)
|
pa_log_warn("Add lost supported device %s to %s",
|
||||||
d->supported_devices = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME),
|
||||||
|
pa_proplist_gets(d->proplist, PA_ALSA_PROP_UCM_NAME));
|
||||||
if (pa_idxset_put(d->supported_devices, dev, NULL) == 0)
|
|
||||||
pa_log_warn("Add lost supported device %s to %s",
|
|
||||||
pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME),
|
|
||||||
pa_proplist_gets(d->proplist, PA_ALSA_PROP_UCM_NAME));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1185,23 +1175,27 @@ static int ucm_check_conformance(
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->conflicting_devices) { /* the device defines conflicting devices */
|
PA_IDXSET_FOREACH(d, dev->conflicting_devices, idx) {
|
||||||
PA_IDXSET_FOREACH(d, dev->conflicting_devices, idx) {
|
/* No conflicting device must already be selected */
|
||||||
for (i = 0; i < dev_num; i++) {
|
for (i = 0; i < dev_num; i++) {
|
||||||
if (pdevices[i] == d) {
|
if (pdevices[i] == d) {
|
||||||
pa_log_debug("Conflicting device found");
|
pa_log_debug("Conflicting device found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (dev->supported_devices) { /* the device defines supported devices */
|
}
|
||||||
|
|
||||||
|
if (!pa_idxset_isempty(dev->supported_devices)) {
|
||||||
|
/* No already selected device must be unsupported */
|
||||||
for (i = 0; i < dev_num; i++) {
|
for (i = 0; i < dev_num; i++) {
|
||||||
if (!ucm_device_exists(dev->supported_devices, pdevices[i])) {
|
if (!ucm_device_exists(dev->supported_devices, pdevices[i])) {
|
||||||
pa_log_debug("Supported device not found");
|
pa_log_debug("Supported device not found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { /* not support any other devices */
|
}
|
||||||
|
|
||||||
|
if (pa_idxset_isempty(dev->conflicting_devices) && pa_idxset_isempty(dev->supported_devices)) {
|
||||||
pa_log_debug("Not support any other devices");
|
pa_log_debug("Not support any other devices");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2102,10 +2096,8 @@ static void free_verb(pa_alsa_ucm_verb *verb) {
|
||||||
|
|
||||||
pa_proplist_free(di->proplist);
|
pa_proplist_free(di->proplist);
|
||||||
|
|
||||||
if (di->conflicting_devices)
|
pa_idxset_free(di->conflicting_devices, NULL);
|
||||||
pa_idxset_free(di->conflicting_devices, NULL);
|
pa_idxset_free(di->supported_devices, NULL);
|
||||||
if (di->supported_devices)
|
|
||||||
pa_idxset_free(di->supported_devices, NULL);
|
|
||||||
|
|
||||||
pa_xfree(di->eld_mixer_device_name);
|
pa_xfree(di->eld_mixer_device_name);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue