summaryrefslogtreecommitdiff
path: root/source/l/alsa-lib/0e4ba2ea8c0402f12a645032a14693eb9b1278e6.patch
blob: 3703f809652523e72648e0ade30b08eb5e8a2f88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 0e4ba2ea8c0402f12a645032a14693eb9b1278e6 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Wed, 2 Jun 2021 11:09:43 +0200
Subject: [PATCH] ucm: add _alibpref to get the private device prefix

It may be useful to get the device prefix for the local configuration.

Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1251
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
 include/use-case.h |  1 +
 src/ucm/main.c     | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/use-case.h b/include/use-case.h
index ec1a97b0..7890358b 100644
--- a/include/use-case.h
+++ b/include/use-case.h
@@ -258,6 +258,7 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
  *   - _verb		- return current verb
  *   - _file		- return configuration file loaded for current card
  *   - _alibcfg		- return private alsa-lib's configuration for current card
+ *   - _alibpref	- return private alsa-lib's configuration device prefix for current card
  *
  *   - [=]{NAME}[/[{modifier}|{/device}][/{verb}]]
  *                      - value identifier {NAME}
diff --git a/src/ucm/main.c b/src/ucm/main.c
index 361952f6..3c9ea15d 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -2138,6 +2138,25 @@ static int get_alibcfg(snd_use_case_mgr_t *uc_mgr, char **str)
 	return 0;
 }
 
+/**
+ * \brief Get device prefix for private alsa-lib configuration
+ * \param uc_mgr Use case manager
+ * \param str Returned value string
+ * \return Zero on success (value is filled), otherwise a negative error code
+ */
+static int get_alibpref(snd_use_case_mgr_t *uc_mgr, char **str)
+{
+	const size_t l = 9;
+	char *s;
+
+	s = malloc(l);
+	if (s == NULL)
+		return -ENOMEM;
+	snprintf(s, l, "_ucm%04X", uc_mgr->ucm_card_number);
+	*str = s;
+	return 0;
+}
+
 /**
  * \brief Get current - string
  * \param uc_mgr Use case manager
@@ -2193,6 +2212,8 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
 
 	} else if (strcmp(identifier, "_alibcfg") == 0) {
 		err = get_alibcfg(uc_mgr, (char **)value);
+	} else if (strcmp(identifier, "_alibpref") == 0) {
+		err = get_alibpref(uc_mgr, (char **)value);
 	} else if (identifier[0] == '_') {
 		err = -ENOENT;
 	} else {