[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] 2 commits: ucm: fix the port / ucm device activation on boot

Tanu Kaskinen gitlab at gitlab.freedesktop.org
Thu Apr 9 13:49:33 UTC 2020



Tanu Kaskinen pushed to branch master at PulseAudio / pulseaudio


Commits:
fc5f263e by Jaroslav Kysela at 2020-04-09T16:42:28+03:00
ucm: fix the port / ucm device activation on boot

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 at perex.cz>

- - - - -
5eb02e31 by Jaroslav Kysela at 2020-04-09T16:42:28+03:00
alsa sink/source: fix the mixer initialization

- remove duplicate mixer initialization in sink
- use the similar mixer initialization for source like for sink

Signed-off-by: Jaroslav Kysela <perex at perex.cz>

- - - - -


2 changed files:

- src/modules/alsa/alsa-sink.c
- src/modules/alsa/alsa-source.c


Changes:

=====================================
src/modules/alsa/alsa-sink.c
=====================================
@@ -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 */
@@ -2506,8 +2511,6 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     /* ALSA might tweak the sample spec, so recalculate the frame size */
     frame_size = pa_frame_size(&ss);
 
-    find_mixer(u, mapping, pa_modargs_get_value(ma, "control", NULL), ignore_dB);
-
     pa_sink_new_data_init(&data);
     data.driver = driver;
     data.module = m;


=====================================
src/modules/alsa/alsa-source.c
=====================================
@@ -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 */
@@ -2193,8 +2198,6 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     /* ALSA might tweak the sample spec, so recalculate the frame size */
     frame_size = pa_frame_size(&ss);
 
-    find_mixer(u, mapping, pa_modargs_get_value(ma, "control", NULL), ignore_dB);
-
     pa_source_new_data_init(&data);
     data.driver = driver;
     data.module = m;
@@ -2249,10 +2252,14 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
         goto fail;
     }
 
-    if (u->ucm_context)
+    if (u->ucm_context) {
         pa_alsa_ucm_add_ports(&data.ports, data.proplist, u->ucm_context, false, card, u->pcm_handle, ignore_dB);
-    else if (u->mixer_path_set)
-        pa_alsa_add_ports(&data, u->mixer_path_set, card);
+        find_mixer(u, mapping, pa_modargs_get_value(ma, "control", NULL), ignore_dB);
+    } else {
+        find_mixer(u, mapping, pa_modargs_get_value(ma, "control", NULL), ignore_dB);
+        if (u->mixer_path_set)
+            pa_alsa_add_ports(&data, u->mixer_path_set, card);
+    }
 
     u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY|(u->use_tsched ? PA_SOURCE_DYNAMIC_LATENCY : 0));
     volume_is_set = data.volume_is_set;



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/77d00b1cce9bc695be6314ec15b12a4a0dcd08ee...5eb02e31a6de116395075f814123daaad424d5a4

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/77d00b1cce9bc695be6314ec15b12a4a0dcd08ee...5eb02e31a6de116395075f814123daaad424d5a4
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/20200409/f5a2fe66/attachment-0001.htm>


More information about the pulseaudio-commits mailing list