Add more UCM patches (#1818883)

This commit is contained in:
Wim Taymans 2020-03-31 16:20:07 +02:00
parent de7aed422e
commit a16d6158a4
3 changed files with 149 additions and 2 deletions

View File

@ -0,0 +1,79 @@
From d45b84cae0a09b5804669da1bfec228272101664 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 31 Mar 2020 13:24:36 +0200
Subject: [PATCH 1/2] 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@perex.cz>
---
src/modules/alsa/alsa-sink.c | 11 +++++++----
src/modules/alsa/alsa-source.c | 11 +++++++----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 65430caed..c7754b60b 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -2138,6 +2138,13 @@ static int setup_mixer(struct userdata *u, bool ignore_dB) {
pa_assert(u);
+ /* First activate the port on the UCM side */
+ /* the UCM device might not define mixer controls */
+ 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 +2162,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 */
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index c33f81e35..b12deef76 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1844,6 +1844,13 @@ static int setup_mixer(struct userdata *u, bool ignore_dB) {
pa_assert(u);
+ /* First activate the port on the UCM side */
+ /* the UCM device might not define mixer controls */
+ 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 +1868,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 */
--
2.25.1

View File

@ -0,0 +1,61 @@
From dc0b263d687055e4b58323c5a1ba98222a19c518 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 31 Mar 2020 13:32:46 +0200
Subject: [PATCH 2/2] 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@perex.cz>
---
src/modules/alsa/alsa-sink.c | 2 --
src/modules/alsa/alsa-source.c | 12 +++++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index c7754b60b..a8792ed33 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -2509,8 +2509,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;
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index b12deef76..721cda2db 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -2196,8 +2196,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;
@@ -2252,10 +2250,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;
--
2.25.1

View File

@ -31,7 +31,7 @@
Name: pulseaudio
Summary: Improved Linux Sound Server
Version: %{pa_major}%{?pa_minor:.%{pa_minor}}
Release: 2%{?snap:.%{snap}git%{shortcommit}}%{?dist}
Release: 3%{?snap:.%{snap}git%{shortcommit}}%{?dist}
License: LGPLv2+
URL: http://www.freedesktop.org/wiki/Software/PulseAudio
%if 0%{?gitrel}
@ -59,9 +59,11 @@ Patch207: 0001-alsa-ucm-correct-the-channel-default-logic-stereo.patch
Patch208: 0002-alsa-ucm-do-not-assign-JackHWMute-when-JackControl-i.patch
Patch209: 0003-ucm-Don-t-log-errors-during-normal-operation.patch
Patch210: 0004-bluetooth-Ensure-that-only-one-A2DP-codec-is-registe.patch
Patch211: 0005-alsa-handle-unavailbale-HW-volume-in-UCM.patch
## upstreamable patches
Patch211: 0005-alsa-handle-unavailbale-HW-volume-in-UCM.patch
Patch212: 0001-ucm-fix-the-port-ucm-device-activation-on-boot.patch
Patch213: 0002-alsa-sink-source-fix-the-mixer-initialization.patch
BuildRequires: automake libtool
BuildRequires: gcc-c++
@ -263,6 +265,8 @@ This package contains GDM integration hooks for the PulseAudio sound server.
%patch209 -p1 -b .0009
%patch210 -p1 -b .0010
%patch211 -p1 -b .0011
%patch212 -p1 -b .0012
%patch213 -p1 -b .0013
sed -i.no_consolekit -e \
's/^load-module module-console-kit/#load-module module-console-kit/' \
@ -654,6 +658,9 @@ systemctl --no-reload preset --global pulseaudio.socket >/dev/null 2>&1 || :
%changelog
* Tue Mar 31 2020 Wim Taymans <wtaymans@redhat.com> - 13.99.1-3
- Add more UCM patches (#1818883)
* Fri Mar 20 2020 Wim Taymans <wtaymans@redhat.com> - 13.99.1-2
- Add some more UCM patches
- Fix missing UCM mixers crash (#1815437)