alsa-ucm: Fix device conformance check

Right now this check is rejecting devices whose UCM config specifies
neither a conflicting device nor a supported device list, and accepting
devices which specify both. However, a device without neither list is
actually unrestricted, and a device with both lists is a configuration
error. Fix the check to accept the former.

Furthermore, this is missing another case where an already selected
device might have a supported devices list that doesn't have the
candidate device. Make this function also check against that, and also
make it accept devices already in the set.

Link: 5245117781
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
This commit is contained in:
Alper Nebi Yasak 2023-11-27 23:12:56 +03:00 committed by Wim Taymans
parent d7591edc25
commit 943967b826

View file

@ -1252,6 +1252,9 @@ static int ucm_port_contains(const char *port_name, const char *dev_name, bool i
}
static bool devset_supports_device(pa_idxset *devices, pa_alsa_ucm_device *dev) {
pa_alsa_ucm_device *d;
uint32_t idx;
pa_assert(devices);
pa_assert(dev);
@ -1259,6 +1262,10 @@ static bool devset_supports_device(pa_idxset *devices, pa_alsa_ucm_device *dev)
if (pa_idxset_isempty(devices))
return true;
/* Device already selected */
if (pa_idxset_contains(devices, dev))
return true;
/* No conflicting device must already be selected */
if (!pa_idxset_isdisjoint(devices, dev->conflicting_devices))
return false;
@ -1268,9 +1275,11 @@ static bool devset_supports_device(pa_idxset *devices, pa_alsa_ucm_device *dev)
if (!pa_idxset_issubset(devices, dev->supported_devices))
return false;
if (pa_idxset_isempty(dev->conflicting_devices) && pa_idxset_isempty(dev->supported_devices)) {
return false;
}
/* Must not be unsupported by any selected device */
PA_IDXSET_FOREACH(d, devices, idx)
if (!pa_idxset_isempty(d->supported_devices))
if (!pa_idxset_contains(d->supported_devices, dev))
return false;
return true;
}