pulseaudio/0032-alsa-ucm-allow-to-set-profile-priority-from-UCM-valu.patch
Takashi Iwai 5dabf3bcba Accepting request 774841 from home:tiwai:branches:multimedia:libs
- 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
2020-02-17 11:47:50 +00:00

129 lines
4.1 KiB
Diff

From cd4a69374cefe7c720bd6916f06ff7151da9892a Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 10 Dec 2019 12:34:19 +0100
Subject: [PATCH] alsa-ucm: allow to set profile priority from UCM value
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
src/modules/alsa/alsa-ucm.c | 59 +++++++++++++++++++++++++++++++++------------
src/modules/alsa/alsa-ucm.h | 1 +
2 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index 5695840abaf1..a57be6d22497 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -146,6 +146,26 @@ static struct ucm_info dev_info[] = {
{NULL, 0}
};
+
+static char *ucm_verb_value(
+ snd_use_case_mgr_t *uc_mgr,
+ const char *verb_name,
+ const char *id) {
+
+ const char *value;
+ char *_id = pa_sprintf_malloc("=%s//%s", id, verb_name);
+ int err = snd_use_case_get(uc_mgr, _id, &value);
+ pa_xfree(_id);
+ if (err < 0)
+ return NULL;
+ pa_log_debug("Got %s for verb %s: %s", id, verb_name, value);
+ /* Use the cast here to allow free() call without casting for callers.
+ * The snd_use_case_get() returns mallocated string.
+ * See the Note: in use-case.h for snd_use_case_get().
+ */
+ return (char *)value;
+}
+
static int ucm_device_exists(pa_idxset *idxset, pa_alsa_ucm_device *dev) {
pa_alsa_ucm_device *d;
uint32_t idx;
@@ -766,6 +786,8 @@ int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, cons
pa_alsa_ucm_device *d;
pa_alsa_ucm_modifier *mod;
pa_alsa_ucm_verb *verb;
+ char *value;
+ unsigned ui;
int err = 0;
*p_verb = NULL;
@@ -780,6 +802,11 @@ int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, cons
pa_proplist_sets(verb->proplist, PA_ALSA_PROP_UCM_NAME, pa_strnull(verb_name));
pa_proplist_sets(verb->proplist, PA_ALSA_PROP_UCM_DESCRIPTION, pa_strna(verb_desc));
+ value = ucm_verb_value(uc_mgr, verb_name, "Priority");
+ if (value && !pa_atou(value, &ui))
+ verb->priority = ui > 10000 ? 10000 : ui;
+ free(value);
+
err = ucm_get_devices(verb, uc_mgr);
if (err < 0)
pa_log("No UCM devices for verb %s", verb_name);
@@ -1637,7 +1664,7 @@ static int ucm_create_profile(
pa_alsa_ucm_modifier *mod;
int i = 0;
const char *name, *sink, *source;
- char *verb_cmp, *c;
+ unsigned int priority;
pa_assert(ps);
@@ -1657,24 +1684,26 @@ static int ucm_create_profile(
p->supported = true;
pa_hashmap_put(ps->profiles, p->name, p);
- /* TODO: get profile priority from ucm info or policy management */
- c = verb_cmp = pa_xstrdup(verb_name);
- while (*c) {
- if (*c == '_') *c = ' ';
- c++;
- }
+ /* TODO: get profile priority from policy management */
+ priority = verb->priority;
- for (i = 0; verb_info[i].id; i++) {
- if (strcasecmp(verb_info[i].id, verb_cmp) == 0) {
- p->priority = verb_info[i].priority;
- break;
+ if (priority == 0) {
+ char *verb_cmp, *c;
+ c = verb_cmp = pa_xstrdup(verb_name);
+ while (*c) {
+ if (*c == '_') *c = ' ';
+ c++;
+ }
+ for (i = 0; verb_info[i].id; i++) {
+ if (strcasecmp(verb_info[i].id, verb_cmp) == 0) {
+ priority = verb_info[i].priority;
+ break;
+ }
}
+ pa_xfree(verb_cmp);
}
- pa_xfree(verb_cmp);
-
- if (verb_info[i].id == NULL)
- p->priority = 1000;
+ p->priority = priority;
PA_LLIST_FOREACH(dev, verb->devices) {
pa_alsa_jack *jack;
diff --git a/src/modules/alsa/alsa-ucm.h b/src/modules/alsa/alsa-ucm.h
index 48fd9db3f79f..e7a795cedeb7 100644
--- a/src/modules/alsa/alsa-ucm.h
+++ b/src/modules/alsa/alsa-ucm.h
@@ -241,6 +241,7 @@ struct pa_alsa_ucm_verb {
PA_LLIST_FIELDS(pa_alsa_ucm_verb);
pa_proplist *proplist;
+ unsigned priority;
PA_LLIST_HEAD(pa_alsa_ucm_device, devices);
PA_LLIST_HEAD(pa_alsa_ucm_modifier, modifiers);
--
2.16.4