Takashi Iwai
5dabf3bcba
- Backport upstream fixes / enhancements about alsa modules: mainly for UCM support (boo#1160914): 0001-alsa-mixer-path-test-Hide-unused-functions-when-buil.patch 0002-alsa-mixer-recognize-the-Speaker-Jack-control.patch 0003-alsa-mixer-add-support-for-SteelSeries-Arctis-Pro-20.patch 0004-alsa-mixer-Add-support-for-SteelSeries-Arctis-5-2019.patch 0005-alsa-mixer-add-support-for-LucidSound-LS31-and-creat.patch 0006-alsa-ucm-use-ucm2-name-for-the-direct-card-index-ope.patch 0007-alsa-ucm-add-mixer-IDs-to-ucm_items.patch 0008-alsa-mixer-handle-the-index-for-ALSA-mixer-element-i.patch 0009-alsa-mixer-improve-alsa_id_decode-function.patch 0010-alsa-ucm-Support-Playback-CaptureVolume.patch 0011-alsa-ucm-Fix-volume-control-based-on-review.patch 0012-alsa-ucm-use-the-correct-mixer-identifiers-as-first.patch 0013-alsa-ucm-add-support-for-master-volume.patch 0014-alsa-ucm-split-correctly-JackHWMute-device-names.patch 0015-alsa-ucm-fix-parsing-for-JackControl.patch 0016-alsa-ucm-add-comments-to-ucm_get_mixer_id.patch 0017-alsa-ucm-validate-access-to-PA_DEVICE_PORT_DATA.patch 0018-alsa-Skip-resume-PCM-if-hardware-doesn-t-support-it.patch 0019-alsa-ucm-parse-correctly-the-device-values.patch 0020-alsa-ucm-do-not-try-to-use-UCM-device-name-as-jack-n.patch 0021-alsa-util-do-not-try-to-guess-the-mixer-name-from-th.patch 0022-alsa-ucm-add-control-and-mixer-device-items.patch 0023-alsa-ucm-get-the-mixer-names-from-ucm-don-t-guess.patch 0024-alsa-ucm-use-the-proper-mixer-name-for-ucm-pcm-sink-.patch 0025-alsa-mixer-handle-interface-type-CARD-PCM-for-mixer-.patch 0026-alsa-mixer-Add-the-ability-to-pass-the-intended-role.patch 0027-alsa-mixer-Set-the-intended-role-of-Steelseries-Arct.patch 0028-alsa-rewrite-mixer-open-close-cache-mixer-accesses-i.patch OBS-URL: https://build.opensuse.org/request/show/774841 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/pulseaudio?expand=0&rev=217
243 lines
8.8 KiB
Diff
243 lines
8.8 KiB
Diff
From 9acacd9ba3b9f4df0957e9ddaacbcee00396175c Mon Sep 17 00:00:00 2001
|
|
From: Jaska Uimonen <jaska.uimonen@intel.com>
|
|
Date: Tue, 1 Oct 2019 18:34:17 +0300
|
|
Subject: [PATCH] alsa-ucm: Fix volume control based on review
|
|
|
|
- sync mixer logic added
|
|
- mixer path creation, empty set in mapping creation, paths added in path creation
|
|
- path creation moved inside new port creation as it might be called twice otherwise
|
|
- some comments added
|
|
---
|
|
src/modules/alsa/alsa-sink.c | 31 ++++++++--------------------
|
|
src/modules/alsa/alsa-source.c | 29 ++++++++------------------
|
|
src/modules/alsa/alsa-ucm.c | 47 +++++++++++++++++++++++++++++-------------
|
|
src/modules/alsa/alsa-ucm.h | 2 +-
|
|
4 files changed, 52 insertions(+), 57 deletions(-)
|
|
|
|
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
|
|
index 08d4d1f38b80..0a5c92529af3 100644
|
|
--- a/src/modules/alsa/alsa-sink.c
|
|
+++ b/src/modules/alsa/alsa-sink.c
|
|
@@ -1266,7 +1266,7 @@ static void sync_mixer(struct userdata *u, pa_device_port *port) {
|
|
|
|
/* port may be NULL, because if we use a synthesized mixer path, then the
|
|
* sink has no ports. */
|
|
- if (port) {
|
|
+ if (port && !u->ucm_context) {
|
|
pa_alsa_port_data *data;
|
|
|
|
data = PA_DEVICE_PORT_DATA(port);
|
|
@@ -1648,28 +1648,19 @@ static int sink_set_port_ucm_cb(pa_sink *s, pa_device_port *p) {
|
|
struct userdata *u = s->userdata;
|
|
pa_alsa_ucm_port_data *data;
|
|
|
|
- data = PA_DEVICE_PORT_DATA(p);
|
|
-
|
|
pa_assert(u);
|
|
pa_assert(p);
|
|
+ pa_assert(u->mixer_handle);
|
|
pa_assert(u->ucm_context);
|
|
|
|
- u->mixer_path = data->path;
|
|
+ data = PA_DEVICE_PORT_DATA(p);
|
|
+ pa_assert_se(u->mixer_path = data->path);
|
|
mixer_volume_init(u);
|
|
|
|
- if (u->mixer_path) {
|
|
- pa_alsa_path_select(u->mixer_path, NULL, u->mixer_handle, s->muted);
|
|
-
|
|
- if (s->set_mute)
|
|
- s->set_mute(s);
|
|
- if (s->flags & PA_SINK_DEFERRED_VOLUME) {
|
|
- if (s->write_volume)
|
|
- s->write_volume(s);
|
|
- } else {
|
|
- if (s->set_volume)
|
|
- s->set_volume(s);
|
|
- }
|
|
- }
|
|
+ if (s->flags & PA_SINK_DEFERRED_VOLUME)
|
|
+ pa_asyncmsgq_send(u->sink->asyncmsgq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_SYNC_MIXER, p, 0, NULL);
|
|
+ else
|
|
+ sync_mixer(u, p);
|
|
|
|
return pa_alsa_ucm_set_port(u->ucm_context, p, true);
|
|
}
|
|
@@ -2091,6 +2082,7 @@ static void set_sink_name(pa_sink_new_data *data, pa_modargs *ma, const char *de
|
|
}
|
|
|
|
static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char *element, bool ignore_dB) {
|
|
+
|
|
if (!mapping && !element)
|
|
return;
|
|
|
|
@@ -2099,11 +2091,6 @@ static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char
|
|
return;
|
|
}
|
|
|
|
- if (u->ucm_context) {
|
|
- /* We just want to open the device */
|
|
- return;
|
|
- }
|
|
-
|
|
if (element) {
|
|
|
|
if (!(u->mixer_path = pa_alsa_path_synthesize(element, PA_ALSA_DIRECTION_OUTPUT)))
|
|
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
|
|
index 657ed5aeda11..d186101720b8 100644
|
|
--- a/src/modules/alsa/alsa-source.c
|
|
+++ b/src/modules/alsa/alsa-source.c
|
|
@@ -1137,7 +1137,7 @@ static void sync_mixer(struct userdata *u, pa_device_port *port) {
|
|
|
|
/* port may be NULL, because if we use a synthesized mixer path, then the
|
|
* source has no ports. */
|
|
- if (port) {
|
|
+ if (port && !u->ucm_context) {
|
|
pa_alsa_port_data *data;
|
|
|
|
data = PA_DEVICE_PORT_DATA(port);
|
|
@@ -1523,24 +1523,17 @@ static int source_set_port_ucm_cb(pa_source *s, pa_device_port *p) {
|
|
|
|
pa_assert(u);
|
|
pa_assert(p);
|
|
+ pa_assert(u->mixer_handle);
|
|
pa_assert(u->ucm_context);
|
|
|
|
- u->mixer_path = data->path;
|
|
+ data = PA_DEVICE_PORT_DATA(p);
|
|
+ pa_assert_se(u->mixer_path = data->path);
|
|
mixer_volume_init(u);
|
|
|
|
- if (u->mixer_path) {
|
|
- pa_alsa_path_select(u->mixer_path, NULL, u->mixer_handle, s->muted);
|
|
-
|
|
- if (s->set_mute)
|
|
- s->set_mute(s);
|
|
- if (s->flags & PA_SOURCE_DEFERRED_VOLUME) {
|
|
- if (s->write_volume)
|
|
- s->write_volume(s);
|
|
- } else {
|
|
- if (s->set_volume)
|
|
- s->set_volume(s);
|
|
- }
|
|
- }
|
|
+ if (s->flags & PA_SOURCE_DEFERRED_VOLUME)
|
|
+ pa_asyncmsgq_send(u->source->asyncmsgq, PA_MSGOBJECT(u->source), SOURCE_MESSAGE_SYNC_MIXER, p, 0, NULL);
|
|
+ else
|
|
+ sync_mixer(u, p);
|
|
|
|
return pa_alsa_ucm_set_port(u->ucm_context, p, false);
|
|
}
|
|
@@ -1805,11 +1798,6 @@ static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char
|
|
return;
|
|
}
|
|
|
|
- if (u->ucm_context) {
|
|
- /* We just want to open the device */
|
|
- return;
|
|
- }
|
|
-
|
|
if (element) {
|
|
|
|
if (!(u->mixer_path = pa_alsa_path_synthesize(element, PA_ALSA_DIRECTION_INPUT)))
|
|
@@ -2404,6 +2392,7 @@ static void userdata_free(struct userdata *u) {
|
|
if (u->mixer_fdl)
|
|
pa_alsa_fdlist_free(u->mixer_fdl);
|
|
|
|
+ /* Only free the mixer_path if the sink owns it */
|
|
if (u->mixer_path && !u->mixer_path_set && !u->ucm_context)
|
|
pa_alsa_path_free(u->mixer_path);
|
|
|
|
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
|
|
index 349a59566200..a812b52f449e 100644
|
|
--- a/src/modules/alsa/alsa-ucm.c
|
|
+++ b/src/modules/alsa/alsa-ucm.c
|
|
@@ -852,21 +852,29 @@ static void ucm_add_port_combination(
|
|
|
|
pa_hashmap_put(ports, port->name, port);
|
|
pa_log_debug("Add port %s: %s", port->name, port->description);
|
|
- }
|
|
-
|
|
- if (num == 1) {
|
|
- /* To keep things simple and not worry about stacking controls, we only support hardware volumes on non-combination
|
|
- * ports. */
|
|
- data = PA_DEVICE_PORT_DATA(port);
|
|
|
|
- PA_HASHMAP_FOREACH_KV(profile, volume_element, is_sink ? dev->playback_volumes : dev->capture_volumes, state) {
|
|
- pa_alsa_path *path = pa_alsa_path_synthesize(volume_element,
|
|
- is_sink ? PA_ALSA_DIRECTION_OUTPUT : PA_ALSA_DIRECTION_INPUT);
|
|
-
|
|
- if (!path)
|
|
- pa_log_warn("Failed to set up volume control: %s", volume_element);
|
|
- else
|
|
- pa_hashmap_put(data->paths, pa_xstrdup(profile), path);
|
|
+ if (num == 1) {
|
|
+ /* To keep things simple and not worry about stacking controls, we only support hardware volumes on non-combination
|
|
+ * ports. */
|
|
+ data = PA_DEVICE_PORT_DATA(port);
|
|
+
|
|
+ PA_HASHMAP_FOREACH_KV(profile, volume_element, is_sink ? dev->playback_volumes : dev->capture_volumes, state) {
|
|
+ pa_alsa_path *path = pa_alsa_path_synthesize(volume_element,
|
|
+ is_sink ? PA_ALSA_DIRECTION_OUTPUT : PA_ALSA_DIRECTION_INPUT);
|
|
+
|
|
+ if (!path)
|
|
+ pa_log_warn("Failed to set up volume control: %s", volume_element);
|
|
+ else {
|
|
+ pa_hashmap_put(data->paths, pa_xstrdup(profile), path);
|
|
+
|
|
+ /* Add path also to already created empty path set */
|
|
+ dev = sorted[0];
|
|
+ if (is_sink)
|
|
+ pa_hashmap_put(dev->playback_mapping->output_path_set->paths, pa_xstrdup(volume_element), path);
|
|
+ else
|
|
+ pa_hashmap_put(dev->capture_mapping->input_path_set->paths, pa_xstrdup(volume_element), path);
|
|
+ }
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -1185,16 +1193,27 @@ int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *p
|
|
|
|
static void ucm_add_mapping(pa_alsa_profile *p, pa_alsa_mapping *m) {
|
|
|
|
+ pa_alsa_path_set *ps;
|
|
+
|
|
+ /* create empty path set for the future path additions */
|
|
+ ps = pa_xnew0(pa_alsa_path_set, 1);
|
|
+ ps->direction = m->direction;
|
|
+ ps->paths = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
|
+
|
|
switch (m->direction) {
|
|
case PA_ALSA_DIRECTION_ANY:
|
|
pa_idxset_put(p->output_mappings, m, NULL);
|
|
pa_idxset_put(p->input_mappings, m, NULL);
|
|
+ m->output_path_set = ps;
|
|
+ m->input_path_set = ps;
|
|
break;
|
|
case PA_ALSA_DIRECTION_OUTPUT:
|
|
pa_idxset_put(p->output_mappings, m, NULL);
|
|
+ m->output_path_set = ps;
|
|
break;
|
|
case PA_ALSA_DIRECTION_INPUT:
|
|
pa_idxset_put(p->input_mappings, m, NULL);
|
|
+ m->input_path_set = ps;
|
|
break;
|
|
}
|
|
}
|
|
diff --git a/src/modules/alsa/alsa-ucm.h b/src/modules/alsa/alsa-ucm.h
|
|
index 2e39a09a51f3..d8507a83615c 100644
|
|
--- a/src/modules/alsa/alsa-ucm.h
|
|
+++ b/src/modules/alsa/alsa-ucm.h
|
|
@@ -240,7 +240,7 @@ struct pa_alsa_ucm_port_data {
|
|
* a combination of devices. */
|
|
pa_dynarray *devices; /* pa_alsa_ucm_device */
|
|
|
|
- /* profile -> pa_alsa_path for volume control */
|
|
+ /* profile name -> pa_alsa_path for volume control */
|
|
pa_hashmap *paths;
|
|
/* Current path, set when activating profile */
|
|
pa_alsa_path *path;
|
|
--
|
|
2.16.4
|
|
|