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
84 lines
2.9 KiB
Diff
84 lines
2.9 KiB
Diff
From 8837c90b7fe6b7c3cbbaeda0a29e2f5d311c3d14 Mon Sep 17 00:00:00 2001
|
|
From: Jaroslav Kysela <perex@perex.cz>
|
|
Date: Sun, 8 Dec 2019 22:48:45 +0100
|
|
Subject: [PATCH] alsa-mixer: do the quick card number lookup to save mixer
|
|
instances
|
|
|
|
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
|
---
|
|
src/modules/alsa/alsa-mixer.h | 1 +
|
|
src/modules/alsa/alsa-util.c | 33 +++++++++++++++++++++++++++++++++
|
|
2 files changed, 34 insertions(+)
|
|
|
|
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
|
|
index 325b0c998b02..d740a78c8dce 100644
|
|
--- a/src/modules/alsa/alsa-mixer.h
|
|
+++ b/src/modules/alsa/alsa-mixer.h
|
|
@@ -102,6 +102,7 @@ struct pa_alsa_setting {
|
|
/* An entry for one ALSA mixer */
|
|
struct pa_alsa_mixer {
|
|
snd_mixer_t *mixer_handle;
|
|
+ int card_index;
|
|
pa_alsa_fdlist *fdl;
|
|
bool used_for_probe_only:1;
|
|
};
|
|
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
|
|
index 34930c9fa155..d86f43c10098 100644
|
|
--- a/src/modules/alsa/alsa-util.c
|
|
+++ b/src/modules/alsa/alsa-util.c
|
|
@@ -1737,11 +1737,33 @@ snd_mixer_t *pa_alsa_open_mixer_by_name(pa_hashmap *mixers, const char *dev, boo
|
|
int err;
|
|
snd_mixer_t *m;
|
|
pa_alsa_mixer *pm;
|
|
+ char *dev2;
|
|
+ void *state;
|
|
|
|
pa_assert(mixers);
|
|
pa_assert(dev);
|
|
|
|
pm = pa_hashmap_get(mixers, dev);
|
|
+
|
|
+ /* The quick card number/index lookup (hw:#)
|
|
+ * We already know the card number/index, thus use the mixer
|
|
+ * from the cache at first.
|
|
+ */
|
|
+ if (!pm && pa_strneq(dev, "hw:", 3)) {
|
|
+ const char *s = dev + 3;
|
|
+ int card_index;
|
|
+ while (*s && *s >= 0 && *s <= '9') s++;
|
|
+ if (*s == '\0' && pa_atoi(dev + 3, &card_index) >= 0) {
|
|
+ PA_HASHMAP_FOREACH_KV(dev2, pm, mixers, state) {
|
|
+ if (pm->card_index == card_index) {
|
|
+ dev = dev2;
|
|
+ pm = pa_hashmap_get(mixers, dev);
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
if (pm) {
|
|
if (!probe)
|
|
pm->used_for_probe_only = false;
|
|
@@ -1756,6 +1778,17 @@ snd_mixer_t *pa_alsa_open_mixer_by_name(pa_hashmap *mixers, const char *dev, boo
|
|
if (prepare_mixer(m, dev) >= 0) {
|
|
pm = pa_xnew0(pa_alsa_mixer, 1);
|
|
if (pm) {
|
|
+ snd_hctl_t *hctl;
|
|
+ pm->card_index = -1;
|
|
+ /* determine the ALSA card number (index) and store it to card_index */
|
|
+ err = snd_mixer_get_hctl(m, dev, &hctl);
|
|
+ if (err >= 0) {
|
|
+ snd_ctl_card_info_t *info;
|
|
+ snd_ctl_card_info_alloca(&info);
|
|
+ err = snd_ctl_card_info(snd_hctl_ctl(hctl), info);
|
|
+ if (err >= 0)
|
|
+ pm->card_index = snd_ctl_card_info_get_card(info);
|
|
+ }
|
|
pm->used_for_probe_only = probe;
|
|
pm->mixer_handle = m;
|
|
pa_hashmap_put(mixers, pa_xstrdup(dev), pm);
|
|
--
|
|
2.16.4
|
|
|