File gnome-shell-jscSLE16518-update-subprojects-libgvc.patch of Package gnome-shell.16848

From e2be83ee4a47da9c4c4fbf302a63f04b8d5683b9 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Thu, 9 Apr 2020 11:50:14 +0200
Subject: [PATCH 1/7] build: Bump pulseaudio dependency

We need 12.99.3 in order to avoid deadlocks on Xwayland startup, see
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/79a8efb45cb8304967baa2e8c6d6156478ce19d9

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2599
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/gvc/meson.build b/subprojects/gvc/meson.build
index 3118806..a1a2af5 100644
--- a/subprojects/gvc/meson.build
+++ b/subprojects/gvc/meson.build
@@ -55,7 +55,7 @@ libgvc_no_gir_sources = [
 libgvc_deps = [
   dependency('gio-2.0'),
   dependency('gobject-2.0'),
-  dependency('libpulse', version: '>= 2.0'),
+  dependency('libpulse', version: '>= 12.99.3'),
   dependency('libpulse-mainloop-glib')
 ]
 
-- 
2.28.0


From 342e366eded97df48cef61b71bfd6b3481c69f06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= <alberts.muktupavels@gmail.com>
Date: Wed, 25 Dec 2019 19:14:19 +0200
Subject: [PATCH 2/7] mixer-control: fix -Wswitch-enum warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Warnings introduced in ec5cf3e0de6715803e64b65abb059e2155b3d6de:
gvc-mixer-control.c:1457:9: warning: enumeration value ‘PA_SINK_INIT’ not handled in switch [-Wswitch-enum]
gvc-mixer-control.c:1457:9: warning: enumeration value ‘PA_SINK_UNLINKED’ not handled in switch [-Wswitch-enum]

Warning building with alsa:
gvc-mixer-control.c:2218:9: warning: enumeration value ‘GVC_HEADSET_PORT_CHOICE_NONE’ not handled in switch [-Wswitch-enum]
---
 gvc-mixer-control.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/subprojects/gvc/gvc-mixer-control.c b/subprojects/gvc/gvc-mixer-control.c
index 21fc233..04644d7 100644
--- a/subprojects/gvc/gvc-mixer-control.c
+++ b/subprojects/gvc/gvc-mixer-control.c
@@ -1461,7 +1461,9 @@ translate_pa_state (pa_sink_state_t state) {
                 return GVC_STREAM_STATE_IDLE;
         case PA_SINK_SUSPENDED:
                 return GVC_STREAM_STATE_SUSPENDED;
+        case PA_SINK_INIT:
         case PA_SINK_INVALID_STATE:
+        case PA_SINK_UNLINKED:
         default:
                 return GVC_STREAM_STATE_INVALID;
         }
@@ -2228,6 +2230,7 @@ gvc_mixer_control_set_headset_port (GvcMixerControl      *control,
                 gvc_mixer_control_set_port_status_for_headset (control, id, "analog-output-speaker", TRUE);
                 gvc_mixer_control_set_port_status_for_headset (control, id, "analog-input-headphone-mic", FALSE);
                 break;
+        case GVC_HEADSET_PORT_CHOICE_NONE:
         default:
                 g_assert_not_reached ();
         }
-- 
2.28.0


From d8ba41f1d2982afdc5579dd2e73b84bd021e6230 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= <alberts.muktupavels@gmail.com>
Date: Wed, 25 Dec 2019 19:20:46 +0200
Subject: [PATCH 3/7] test-audio-device-selection: fix -Wsign-compare warning

---
 test-audio-device-selection.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/gvc/test-audio-device-selection.c b/subprojects/gvc/test-audio-device-selection.c
index b276a8c..4b930a1 100644
--- a/subprojects/gvc/test-audio-device-selection.c
+++ b/subprojects/gvc/test-audio-device-selection.c
@@ -51,7 +51,7 @@ audio_selection_needed (GvcMixerControl      *volume,
 		g_print ("What is your choice?\n");
 		if (scanf ("%d", &res) == 1 &&
 		    res > 0 &&
-		    res < g_strv_length (args)) {
+		    res < (int) g_strv_length (args)) {
 			response = res;
 			break;
 		}
-- 
2.28.0


From 15980858d39ac3e4d6954e75c35caf5f8ea18358 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= <alberts.muktupavels@gmail.com>
Date: Wed, 25 Dec 2019 19:23:18 +0200
Subject: [PATCH 4/7] test-audio-device-selection: fix -Wdiscarded-qualifiers
 warnings

---
 test-audio-device-selection.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/subprojects/gvc/test-audio-device-selection.c b/subprojects/gvc/test-audio-device-selection.c
index 4b930a1..8195f9d 100644
--- a/subprojects/gvc/test-audio-device-selection.c
+++ b/subprojects/gvc/test-audio-device-selection.c
@@ -8,7 +8,7 @@
 
 typedef struct {
 	GvcHeadsetPortChoice choice;
-	gchar *name;
+	const char *name;
 } AudioSelectionChoice;
 
 static AudioSelectionChoice audio_selection_choices[] = {
@@ -24,7 +24,7 @@ audio_selection_needed (GvcMixerControl      *volume,
 			GvcHeadsetPortChoice  choices,
 			gpointer              user_data)
 {
-	char *args[G_N_ELEMENTS (audio_selection_choices) + 1];
+	const char *args[G_N_ELEMENTS (audio_selection_choices) + 1];
 	guint i, n;
 	int response = -1;
 
@@ -51,7 +51,7 @@ audio_selection_needed (GvcMixerControl      *volume,
 		g_print ("What is your choice?\n");
 		if (scanf ("%d", &res) == 1 &&
 		    res > 0 &&
-		    res < (int) g_strv_length (args)) {
+		    res < (int) g_strv_length ((char **)  args)) {
 			response = res;
 			break;
 		}
-- 
2.28.0


From 0aab80a78c6eabfe77f81cc30f2b2cade4ea1a58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= <alberts.muktupavels@gmail.com>
Date: Wed, 25 Dec 2019 19:56:45 +0200
Subject: [PATCH 5/7] mixer-control: fix -Wsign-compare warnings

headset_card type is changed from int to guint32 to match uint32_t
used in PulseAudio's pa_card_info struct.
---
 gvc-mixer-control.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/subprojects/gvc/gvc-mixer-control.c b/subprojects/gvc/gvc-mixer-control.c
index 04644d7..a43ae1d 100644
--- a/subprojects/gvc/gvc-mixer-control.c
+++ b/subprojects/gvc/gvc-mixer-control.c
@@ -2096,7 +2096,7 @@ create_ui_device_from_card (GvcMixerControl *control,
 #ifdef HAVE_ALSA
 typedef struct {
         char *port_name_to_set;
-        int headset_card;
+        guint32 headset_card;
 } PortStatusData;
 
 static void
@@ -2124,7 +2124,7 @@ sink_info_cb (pa_context         *c,
 {
         PortStatusData *data = userdata;
         pa_operation *o;
-        int j;
+        guint j;
         const char *s;
 
         if (eol != 0) {
@@ -2160,7 +2160,7 @@ source_info_cb (pa_context           *c,
 {
         PortStatusData *data = userdata;
         pa_operation *o;
-        int j;
+        guint j;
         const char *s;
 
         if (eol != 0) {
-- 
2.28.0


From 960e01d957a97a752cbdd417ba06a3c8280881b5 Mon Sep 17 00:00:00 2001
From: Hui Wang <hui.wang@canonical.com>
Date: Mon, 2 Dec 2019 13:55:28 +0800
Subject: [PATCH 6/7] mixer-control: consolidate port finding and setting
 with/without ucm

Recently Intel added a new audio driver in the Linux kernel, it is
called sof driver. This driver is needed on the laptops which
connects the digital mic to the PCH instead of the codec. To make the
sof driver work with pulseaudio, the ucm is mandatory.

With the ucm, the multi-function audio jack has different port names
in the pulseaudio from the one without ucm, these are the port names
with the ucm:
[In] Mic1: Digital Microphone
[In] Mic2: Headphones Stereo Microphone
[In] Headset: Headset Mono Microphone
[Out] Headphones: Headphones
[Out] Speaker: Speaker

To make the audio device selection work on the machines using the ucm,
the pulseaudio introduces a change to add 2 new members in the device
port structure from the PA_PROTOCOL_VERSION=34, with these 2 members'
help, we could consolidate the port finding and setting for both with
ucm and without ucm.

And this patch maintains the backward compatibility with the
PA_PROTOCOL_VERSION < 34.
---
 gvc-mixer-control.c | 129 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 110 insertions(+), 19 deletions(-)

diff --git a/subprojects/gvc/gvc-mixer-control.c b/subprojects/gvc/gvc-mixer-control.c
index a43ae1d..2dc2cb7 100644
--- a/subprojects/gvc/gvc-mixer-control.c
+++ b/subprojects/gvc/gvc-mixer-control.c
@@ -62,6 +62,7 @@ struct GvcMixerControlPrivate
         pa_glib_mainloop *pa_mainloop;
         pa_mainloop_api  *pa_api;
         pa_context       *pa_context;
+        guint             server_protocol_version;
         int               n_outstanding;
         guint             reconnect_id;
         char             *name;
@@ -104,6 +105,11 @@ struct GvcMixerControlPrivate
         gboolean has_headsetmic;
         gboolean has_headphonemic;
         gboolean headset_plugged_in;
+        char    *headphones_name;
+        char    *headsetmic_name;
+        char    *headphonemic_name;
+        char    *internalspk_name;
+        char    *internalmic_name;
 #endif /* HAVE_ALSA */
 
         GvcMixerControlState state;
@@ -2173,6 +2179,19 @@ source_info_cb (pa_context           *c,
 
         s = data->port_name_to_set;
 
+        for (j = 0; j < i->n_ports; j++) {
+                if (g_str_equal (i->ports[j]->name, s)) {
+                        o = pa_context_set_default_source (c,
+                                                           i->name,
+                                                           NULL,
+                                                           NULL);
+                        if (o == NULL) {
+                                g_warning ("pa_context_set_default_source() failed");
+                                return;
+                        }
+                }
+	}
+
         if (i->active_port && strcmp (i->active_port->name, s) == 0)
                 return;
 
@@ -2196,6 +2215,9 @@ gvc_mixer_control_set_port_status_for_headset (GvcMixerControl *control,
         pa_operation *o;
         PortStatusData *data;
 
+        if (port_name == NULL)
+                return;
+
         data = g_new0 (PortStatusData, 1);
         data->port_name_to_set = g_strdup (port_name);
         data->headset_card = id;
@@ -2209,6 +2231,18 @@ gvc_mixer_control_set_port_status_for_headset (GvcMixerControl *control,
 }
 #endif /* HAVE_ALSA */
 
+static void
+free_priv_port_names (GvcMixerControl    *control)
+{
+#ifdef HAVE_ALSA
+        g_clear_pointer (&control->priv->headphones_name, g_free);
+        g_clear_pointer (&control->priv->headsetmic_name, g_free);
+        g_clear_pointer (&control->priv->headphonemic_name, g_free);
+        g_clear_pointer (&control->priv->internalspk_name, g_free);
+        g_clear_pointer (&control->priv->internalmic_name, g_free);
+#endif
+}
+
 void
 gvc_mixer_control_set_headset_port (GvcMixerControl      *control,
                                     guint                 id,
@@ -2219,16 +2253,16 @@ gvc_mixer_control_set_headset_port (GvcMixerControl      *control,
 #ifdef HAVE_ALSA
         switch (choice) {
         case GVC_HEADSET_PORT_CHOICE_HEADPHONES:
-                gvc_mixer_control_set_port_status_for_headset (control, id, "analog-output-headphones", TRUE);
-                gvc_mixer_control_set_port_status_for_headset (control, id, "analog-input-internal-mic", FALSE);
+                gvc_mixer_control_set_port_status_for_headset (control, id, control->priv->headphones_name, TRUE);
+                gvc_mixer_control_set_port_status_for_headset (control, id, control->priv->internalmic_name, FALSE);
                 break;
         case GVC_HEADSET_PORT_CHOICE_HEADSET:
-                gvc_mixer_control_set_port_status_for_headset (control, id, "analog-output-headphones", TRUE);
-                gvc_mixer_control_set_port_status_for_headset (control, id, "analog-input-headset-mic", FALSE);
+                gvc_mixer_control_set_port_status_for_headset (control, id, control->priv->headphones_name, TRUE);
+                gvc_mixer_control_set_port_status_for_headset (control, id, control->priv->headsetmic_name, FALSE);
                 break;
         case GVC_HEADSET_PORT_CHOICE_MIC:
-                gvc_mixer_control_set_port_status_for_headset (control, id, "analog-output-speaker", TRUE);
-                gvc_mixer_control_set_port_status_for_headset (control, id, "analog-input-headphone-mic", FALSE);
+                gvc_mixer_control_set_port_status_for_headset (control, id, control->priv->internalspk_name, TRUE);
+                gvc_mixer_control_set_port_status_for_headset (control, id, control->priv->headphonemic_name, FALSE);
                 break;
         case GVC_HEADSET_PORT_CHOICE_NONE:
         default:
@@ -2244,16 +2278,24 @@ typedef struct {
         const pa_card_port_info *headphones;
         const pa_card_port_info *headsetmic;
         const pa_card_port_info *headphonemic;
+        const pa_card_port_info *internalmic;
+        const pa_card_port_info *internalspk;
 } headset_ports;
 
 /*
    TODO: Check if we still need this with the changed PA port names
 
-   In PulseAudio ports will show up with the following names:
+   In PulseAudio without ucm, ports will show up with the following names:
    Headphones - analog-output-headphones
    Headset mic - analog-input-headset-mic (was: analog-input-microphone-headset)
    Jack in mic-in mode - analog-input-headphone-mic (was: analog-input-microphone)
 
+   In PulseAudio with ucm, the ports name depends on the ucm, with the current
+   ucm2, the ports will show up with the following names:
+   Headphones - [Out] Headphone
+   Headset mic - [In] Headset
+   Jack in mic-in mode - [In] Mic2
+
    However, since regular mics also show up as analog-input-microphone,
    we need to check for certain controls on alsa mixer level too, to know
    if we deal with a separate mic jack, or a multi-function jack with a
@@ -2268,10 +2310,18 @@ typedef struct {
    Headset Mic Jack - indicates headset jack where hardware can distinguish
      between headphones and headsets. There is no use popping up a dialog in
      this case, unless we already need to do this for the mic-in mode.
+
+   From the PA_PROCOTOL_VERSION=34, The device_port structure adds 2 members
+   available_group and type, with the help of these 2 members, we could
+   consolidate the port checking and port setting for non-ucm and with-ucm
+   cases.
 */
 
+#define GET_PORT_NAME(x) (x ? g_strdup (x->name) : NULL)
+
 static headset_ports *
-get_headset_ports (const pa_card_info *c)
+get_headset_ports (GvcMixerControl    *control,
+                   const pa_card_info *c)
 {
         headset_ports *h;
         guint i;
@@ -2280,13 +2330,42 @@ get_headset_ports (const pa_card_info *c)
 
         for (i = 0; i < c->n_ports; i++) {
                 pa_card_port_info *p = c->ports[i];
-
-                if (strcmp (p->name, "analog-output-headphones") == 0)
-                        h->headphones = p;
-                else if (strcmp (p->name, "analog-input-headset-mic") == 0)
-                        h->headsetmic = p;
-                else if (strcmp(p->name, "analog-input-headphone-mic") == 0)
-                        h->headphonemic = p;
+                if (control->priv->server_protocol_version < 34) {
+                        if (g_str_equal (p->name, "analog-output-headphones"))
+                                h->headphones = p;
+                        else if (g_str_equal (p->name, "analog-input-headset-mic"))
+                                h->headsetmic = p;
+                        else if (g_str_equal (p->name, "analog-input-headphone-mic"))
+                                h->headphonemic = p;
+                        else if (g_str_equal (p->name, "analog-input-internal-mic"))
+                                h->internalmic = p;
+                        else if (g_str_equal (p->name, "analog-output-speaker"))
+                                h->internalspk = p;
+                } else {
+#if (PA_PROTOCOL_VERSION >= 34)
+                        if (p->available_group && strcmp (p->available_group, "Headphone Mic") == 0) {
+                                if (p->type == PA_DEVICE_PORT_TYPE_HEADPHONES)
+                                        h->headphones = p;
+                                else if (p->type == PA_DEVICE_PORT_TYPE_HEADSET)
+                                        h->headsetmic = p;
+                                else if (p->type == PA_DEVICE_PORT_TYPE_MIC)
+                                        h->headphonemic = p;
+                        } else if (p->type == PA_DEVICE_PORT_TYPE_SPEAKER) {
+                                if (strcmp (p->name, "analog-output-speaker") == 0 ||
+                                    strcmp (p->name, "[Out] Speaker") == 0 )
+                                        h->internalspk = p;
+                        } else if (p->type == PA_DEVICE_PORT_TYPE_MIC) {
+                                if (strcmp (p->name, "analog-input-internal-mic") == 0 ||
+                                    strcmp (p->name, "[In] Mic1") == 0 )
+                                        h->internalmic = p;
+                        }
+#else
+                        g_warning_once ("libgnome-volume-control running against PulseAudio %u, "
+                                        "but compiled against older %d, report a bug to your distribution",
+                                        control->priv->server_protocol_version,
+                                        PA_PROTOCOL_VERSION);
+#endif
+                }
         }
         return h;
 }
@@ -2353,7 +2432,7 @@ check_audio_device_selection_needed (GvcMixerControl    *control,
 
         start_dialog = FALSE;
         stop_dialog = FALSE;
-        h = get_headset_ports (info);
+        h = get_headset_ports (control, info);
 
         if (!h->headphones ||
             (!h->headsetmic && !h->headphonemic)) {
@@ -2363,7 +2442,8 @@ check_audio_device_selection_needed (GvcMixerControl    *control,
 
         if (control->priv->headset_card != (int) info->index) {
                 int cardindex;
-                gboolean hsmic, hpmic;
+                gboolean hsmic = TRUE;
+                gboolean hpmic = TRUE;
                 const char *s;
 
                 s = pa_proplist_gets (info->proplist, "alsa.card");
@@ -2374,8 +2454,10 @@ check_audio_device_selection_needed (GvcMixerControl    *control,
                 if (cardindex == 0 && strcmp(s, "0") != 0)
                         goto out;
 
-                if (!verify_alsa_card(cardindex, &hsmic, &hpmic))
-                        goto out;
+                if (control->priv->server_protocol_version < 34) {
+                        if (!verify_alsa_card(cardindex, &hsmic, &hpmic))
+                                goto out;
+                }
 
                 control->priv->headset_card = info->index;
                 control->priv->has_headsetmic = hsmic && h->headsetmic;
@@ -2386,6 +2468,12 @@ check_audio_device_selection_needed (GvcMixerControl    *control,
         }
 
         control->priv->headset_plugged_in = h->headphones->available != PA_PORT_AVAILABLE_NO;
+        free_priv_port_names (control);
+        control->priv->headphones_name = GET_PORT_NAME(h->headphones);
+        control->priv->headsetmic_name = GET_PORT_NAME(h->headsetmic);
+        control->priv->headphonemic_name = GET_PORT_NAME(h->headphonemic);
+        control->priv->internalspk_name = GET_PORT_NAME(h->internalspk);
+        control->priv->internalmic_name = GET_PORT_NAME(h->internalmic);
 
         if (!start_dialog &&
             !stop_dialog)
@@ -3268,6 +3356,7 @@ gvc_mixer_control_ready (GvcMixerControl *control)
         req_update_sink_input_info (control, -1);
         req_update_source_output_info (control, -1);
 
+        control->priv->server_protocol_version = pa_context_get_server_protocol_version (control->priv->pa_context);
 
         control->priv->n_outstanding = 6;
 
@@ -3350,6 +3439,7 @@ idle_reconnect (gpointer data)
         if (control->priv->pa_context) {
                 pa_context_unref (control->priv->pa_context);
                 control->priv->pa_context = NULL;
+                control->priv->server_protocol_version = 0;
                 gvc_mixer_new_pa_context (control);
         }
 
@@ -3503,6 +3593,7 @@ gvc_mixer_control_dispose (GObject *object)
                 control->priv->ui_inputs = NULL;
         }
 
+        free_priv_port_names (control);
         G_OBJECT_CLASS (gvc_mixer_control_parent_class)->dispose (object);
 }
 
-- 
2.28.0


From 7a621180b46421e356b33972e3446775a504139c Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 2 Jun 2020 12:20:45 +0200
Subject: [PATCH 7/7] mixer-control: do not use port name string to select the
 headset ports

It is a bad idea to use the variable port name to check the port
type. Use only the new port type and availability group string
for the decision.

Also, select the ports by priority, if there multiple ports
with the similar type.
---
 gvc-mixer-control.c | 54 +++++++++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/subprojects/gvc/gvc-mixer-control.c b/subprojects/gvc/gvc-mixer-control.c
index 2dc2cb7..8b39080 100644
--- a/subprojects/gvc/gvc-mixer-control.c
+++ b/subprojects/gvc/gvc-mixer-control.c
@@ -2283,19 +2283,11 @@ typedef struct {
 } headset_ports;
 
 /*
-   TODO: Check if we still need this with the changed PA port names
-
    In PulseAudio without ucm, ports will show up with the following names:
    Headphones - analog-output-headphones
    Headset mic - analog-input-headset-mic (was: analog-input-microphone-headset)
    Jack in mic-in mode - analog-input-headphone-mic (was: analog-input-microphone)
 
-   In PulseAudio with ucm, the ports name depends on the ucm, with the current
-   ucm2, the ports will show up with the following names:
-   Headphones - [Out] Headphone
-   Headset mic - [In] Headset
-   Jack in mic-in mode - [In] Mic2
-
    However, since regular mics also show up as analog-input-microphone,
    we need to check for certain controls on alsa mixer level too, to know
    if we deal with a separate mic jack, or a multi-function jack with a
@@ -2312,11 +2304,17 @@ typedef struct {
      this case, unless we already need to do this for the mic-in mode.
 
    From the PA_PROCOTOL_VERSION=34, The device_port structure adds 2 members
-   available_group and type, with the help of these 2 members, we could
+   availability_group and type, with the help of these 2 members, we could
    consolidate the port checking and port setting for non-ucm and with-ucm
    cases.
 */
 
+#define HEADSET_PORT_SET(dst, src) \
+        do { \
+                if (!(dst) || (dst)->priority < (src)->priority) \
+                        dst = src; \
+        } while (0)
+
 #define GET_PORT_NAME(x) (x ? g_strdup (x->name) : NULL)
 
 static headset_ports *
@@ -2343,21 +2341,16 @@ get_headset_ports (GvcMixerControl    *control,
                                 h->internalspk = p;
                 } else {
 #if (PA_PROTOCOL_VERSION >= 34)
-                        if (p->available_group && strcmp (p->available_group, "Headphone Mic") == 0) {
-                                if (p->type == PA_DEVICE_PORT_TYPE_HEADPHONES)
-                                        h->headphones = p;
-                                else if (p->type == PA_DEVICE_PORT_TYPE_HEADSET)
-                                        h->headsetmic = p;
-                                else if (p->type == PA_DEVICE_PORT_TYPE_MIC)
-                                        h->headphonemic = p;
+                        /* in the first loop, set only headphones */
+                        /* the microphone ports are assigned in the second loop */
+                        if (p->type == PA_DEVICE_PORT_TYPE_HEADPHONES) {
+                                if (p->availability_group)
+                                        HEADSET_PORT_SET (h->headphones, p);
                         } else if (p->type == PA_DEVICE_PORT_TYPE_SPEAKER) {
-                                if (strcmp (p->name, "analog-output-speaker") == 0 ||
-                                    strcmp (p->name, "[Out] Speaker") == 0 )
-                                        h->internalspk = p;
+                                HEADSET_PORT_SET (h->internalspk, p);
                         } else if (p->type == PA_DEVICE_PORT_TYPE_MIC) {
-                                if (strcmp (p->name, "analog-input-internal-mic") == 0 ||
-                                    strcmp (p->name, "[In] Mic1") == 0 )
-                                        h->internalmic = p;
+                                if (!p->availability_group)
+                                        HEADSET_PORT_SET (h->internalmic, p);
                         }
 #else
                         g_warning_once ("libgnome-volume-control running against PulseAudio %u, "
@@ -2367,6 +2360,23 @@ get_headset_ports (GvcMixerControl    *control,
 #endif
                 }
         }
+
+#if (PA_PROTOCOL_VERSION >= 34)
+        if (h->headphones && (control->priv->server_protocol_version >= 34)) {
+                for (i = 0; i < c->n_ports; i++) {
+                        pa_card_port_info *p = c->ports[i];
+                        if (g_strcmp0(h->headphones->availability_group, p->availability_group))
+                                continue;
+                        if (p->direction != PA_DIRECTION_INPUT)
+                                continue;
+                        if (p->type == PA_DEVICE_PORT_TYPE_HEADSET)
+                                HEADSET_PORT_SET (h->headsetmic, p);
+                        else if (p->type == PA_DEVICE_PORT_TYPE_MIC)
+                                HEADSET_PORT_SET (h->headphonemic, p);
+                }
+        }
+#endif
+
         return h;
 }
 
-- 
2.28.0
openSUSE Build Service is sponsored by