ucm: fix the port / ucm device activation on boot
authorJaroslav Kysela <perex@perex.cz>
Tue, 31 Mar 2020 11:24:36 +0000 (13:24 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Thu, 9 Apr 2020 13:42:28 +0000 (16:42 +0300)
The UCM device must be activated using the pa_alsa_ucm_set_port()
call on boot (the sink creation time). In case when the
mixer controls are not defined for the application in the
UCM configuration, the mixer_handle is NULL.

Call the pa_alsa_ucm_set_port() before the mixer_handle check.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c

index 65430ca..7048371 100644 (file)
@@ -2138,6 +2138,15 @@ static int setup_mixer(struct userdata *u, bool ignore_dB) {
 
     pa_assert(u);
 
+    /* This code is before the u->mixer_handle check, because if the UCM
+     * configuration doesn't specify volume or mute controls, u->mixer_handle
+     * will be NULL, but the UCM device enable sequence will still need to be
+     * executed. */
+    if (u->sink->active_port && u->ucm_context) {
+        if (pa_alsa_ucm_set_port(u->ucm_context, u->sink->active_port, true) < 0)
+            return -1;
+    }
+
     if (!u->mixer_handle)
         return 0;
 
@@ -2155,10 +2164,6 @@ static int setup_mixer(struct userdata *u, bool ignore_dB) {
         } else {
             pa_alsa_ucm_port_data *data;
 
-            /* First activate the port on the UCM side */
-            if (pa_alsa_ucm_set_port(u->ucm_context, u->sink->active_port, true) < 0)
-                return -1;
-
             data = PA_DEVICE_PORT_DATA(u->sink->active_port);
 
             /* Now activate volume controls, if any */
index c33f81e..bf9e093 100644 (file)
@@ -1844,6 +1844,15 @@ static int setup_mixer(struct userdata *u, bool ignore_dB) {
 
     pa_assert(u);
 
+    /* This code is before the u->mixer_handle check, because if the UCM
+     * configuration doesn't specify volume or mute controls, u->mixer_handle
+     * will be NULL, but the UCM device enable sequence will still need to be
+     * executed. */
+    if (u->source->active_port && u->ucm_context) {
+        if (pa_alsa_ucm_set_port(u->ucm_context, u->source->active_port, false) < 0)
+            return -1;
+    }
+
     if (!u->mixer_handle)
         return 0;
 
@@ -1861,10 +1870,6 @@ static int setup_mixer(struct userdata *u, bool ignore_dB) {
         } else {
             pa_alsa_ucm_port_data *data;
 
-            /* First activate the port on the UCM side */
-            if (pa_alsa_ucm_set_port(u->ucm_context, u->source->active_port, false) < 0)
-                return -1;
-
             data = PA_DEVICE_PORT_DATA(u->source->active_port);
 
             /* Now activate volume controls, if any */