[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] alsa-ucm: Consider devices using the same PCM as incompatible

PulseAudio Marge Bot (@pulseaudio-merge-bot) gitlab at gitlab.freedesktop.org
Sun Mar 19 20:56:14 UTC 2023



PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio


Commits:
45509ff9 by Alper Nebi Yasak at 2023-03-19T20:54:18+00:00
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 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/743>

- - - - -


1 changed file:

- src/modules/alsa/alsa-ucm.c


Changes:

=====================================
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;
 }
 



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/45509ff9bc92345fef4ecf1003bee6fe632c3bcb

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/45509ff9bc92345fef4ecf1003bee6fe632c3bcb
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20230319/59c30a31/attachment-0001.htm>


More information about the pulseaudio-commits mailing list