[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] switch-on-port-available: Switch to headphones on unknown availability

Arun Raghavan gitlab at gitlab.freedesktop.org
Sun Nov 15 23:48:11 UTC 2020



Arun Raghavan pushed to branch master at PulseAudio / pulseaudio


Commits:
323195e3 by Arun Raghavan at 2020-11-15T04:00:25-05:00
switch-on-port-available: Switch to headphones on unknown availability

Since not all users will have environments that asks what they plugged
in when their hardware supports TRRS inputs but don't have impedance
sensing, let's emulate our previous default behaviour of enabling the
headphone port at least.

This can likely be improved so users can configure the module to select
for the device they are most likely to plug in (so an option to enable
just the microphone, or headphones+headset-mic ports).

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1028

- - - - -


1 changed file:

- src/modules/module-switch-on-port-available.c


Changes:

=====================================
src/modules/module-switch-on-port-available.c
=====================================
@@ -234,6 +234,28 @@ static void switch_to_port(pa_device_port *port) {
     if (pp.is_port_active)
         return; /* Already selected */
 
+    /* If a port availability became unknown, let's see if it's part of some
+     * availability group. If it is, it is likely to be a headphone jack that
+     * does not have impedance sensing to detect whether what was plugged in
+     * was a headphone, headset or microphone. In desktop environments that
+     * support it, this will trigger a user choice to select what kind of
+     * device was plugged in. However, let's switch to the headphone port at
+     * least, so that we have don't break functionality for setups that can't
+     * trigger this kind of interaction.
+     *
+     * We should make this configurable so that users can optionally override
+     * the default to a headset or mic.
+     */
+    if (port->available == PA_AVAILABLE_UNKNOWN) {
+        /* Not part of a group of ports, so likely not a combination port */
+        if (!port->availability_group)
+            return;
+
+        /* For no we only switch the headphone port */
+        if (port->direction != PA_DIRECTION_OUTPUT)
+            return;
+    }
+
     pa_log_debug("Trying to switch to port %s", port->name);
     if (!pp.is_preferred_profile_active) {
         if (try_to_switch_profile(port) < 0) {
@@ -303,6 +325,7 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
         return PA_HOOK_OK;
 
     switch (port->available) {
+    case PA_AVAILABLE_UNKNOWN:
     case PA_AVAILABLE_YES:
         switch_to_port(port);
         break;



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/323195e305ce3bd0f183fc66a301b8ad6120e17f

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/323195e305ce3bd0f183fc66a301b8ad6120e17f
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/20201115/fa7bbbbe/attachment-0001.htm>


More information about the pulseaudio-commits mailing list