summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2022-08-19 19:52:56 +0300
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>2023-03-19 20:54:18 +0000
commit45509ff9bc92345fef4ecf1003bee6fe632c3bcb (patch)
tree757720632c14d5bd0fc689333105a2587de8cc31
parentb74269016c1f7babcdd69d33f20cedbe33fe3124 (diff)
downloadpulseaudio-45509ff9bc92345fef4ecf1003bee6fe632c3bcb.tar.gz
alsa-ucm: Consider devices using the same PCM as incompatible
Although it's a valid UCM configuration to have multiple devices using the same PlaybackPCM or CapturePCM, it's unclear how PulseAudio should handle the cases where multiple of these devices are enabled. Some options I can think of are: - Merge all devices sharing the same PCM into the same mapping, open only one PCM substream for this mapping, and add 'combination ports' that enable combinations of the devices. This has been the case until recently, although the combination port logic was broken. A problem with this is that we can't independently control device volumes. We most likely cannot use hardware volumes either. - Have one mapping for each device in the same profile, and open one PCM substream for each mapping. This is the current state, and it fails when there are fewer substreams than devices. Otherwise it works, but it's still confusing, as sound directed to a device-specific mapping might end up playing at multiple devices. - Make multiple profiles each with combinations of upto-substream-count devices, and have one mapping/substream per device. This still causes the confusion mentioned above. And it's likely that the substream count will almost always be one, where this case degenerates into the last one. - Have one mapping for each device in the same profile, but open only one PCM substream. I assume this is possible with software mixing, but it is still confusing like the above, and probably less performant. - Generate multiple profiles each with one of the shared-PCM devices, again with one mapping/substream for that one device. The trade-off with this is that we can't use multiple of these devices at the same time. However, this doesn't have the output device confusion, combination port's volume problems, or the substream count limitation. This patch takes a short-cut to achieve the last option, by considering shared-PCM devices implicitly conflicting with each other. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/743>
-rw-r--r--src/modules/alsa/alsa-ucm.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index 785b23453..50a7cd8d8 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -1279,6 +1279,7 @@ void pa_alsa_ucm_add_port(
}
static bool devset_supports_device(pa_idxset *devices, pa_alsa_ucm_device *dev) {
+ const char *sink, *sink2, *source, *source2;
pa_alsa_ucm_device *d;
uint32_t idx;
@@ -1302,12 +1303,26 @@ static bool devset_supports_device(pa_idxset *devices, pa_alsa_ucm_device *dev)
if (!pa_idxset_issubset(devices, dev->supported_devices))
return false;
- /* Must not be unsupported by any selected device */
- PA_IDXSET_FOREACH(d, devices, idx)
+ sink = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_SINK);
+ source = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_SOURCE);
+
+ PA_IDXSET_FOREACH(d, devices, idx) {
+ /* Must not be unsupported by any selected device */
if (!pa_idxset_isempty(d->supported_devices))
if (!pa_idxset_contains(d->supported_devices, dev))
return false;
+ /* PlaybackPCM must not be the same as any selected device */
+ sink2 = pa_proplist_gets(d->proplist, PA_ALSA_PROP_UCM_SINK);
+ if (sink && sink2 && pa_streq(sink, sink2))
+ return false;
+
+ /* CapturePCM must not be the same as any selected device */
+ source2 = pa_proplist_gets(d->proplist, PA_ALSA_PROP_UCM_SOURCE);
+ if (source && source2 && pa_streq(source, source2))
+ return false;
+ }
+
return true;
}