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.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
This commit is contained in:
Alper Nebi Yasak 2021-06-28 17:16:08 +03:00
parent 0f26022843
commit 5245117781

View file

@ -1226,6 +1226,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);
@ -1233,6 +1236,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;
@ -1242,9 +1249,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;
}