summary refs log tree commit diff
path: root/pkgs/os-specific/linux/alsa-project/alsa-lib/alsa-plugin-conf-multilib.patch
blob: b17df9a492e5bf862ce37a48ad3717925176287d (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
diff --git a/src/control/control.c b/src/control/control.c
index d66ed75..42cecad 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -838,6 +838,10 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
 #ifndef PIC
 	extern void *snd_control_open_symbols(void);
 #endif
+
+	snd_config_t *libs = NULL;
+	const char *libs_lib = NULL;
+
 	if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND) {
 		if (name)
 			SNDERR("Invalid type for CTL %s definition", name);
@@ -879,6 +883,19 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
 					SNDERR("Invalid type for %s", id);
 					goto _err;
 				}
+
+				continue;
+			}
+			// Handle an array of extra libs.
+			if (strcmp(id, "libs") == 0) {
+				if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+					SNDERR("Invalid type for libs definition in CTL %s definition",
+						str);
+					goto _err;
+				}
+
+				libs = n;
+
 				continue;
 			}
 			if (strcmp(id, "open") == 0) {
@@ -903,7 +920,62 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
 		open_name = buf;
 		sprintf(buf, "_snd_ctl_%s_open", str);
 	}
-	if (!lib) {
+
+#ifndef PIC
+	snd_control_open_symbols();
+#endif
+
+	// Normal alsa behaviour when there is no libs array.
+	if (!libs) {
+		if (lib) {
+			open_func = snd_dlobj_cache_get(lib, open_name,
+				SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 1);
+		}
+	}
+	// Handle libs array.
+	// Suppresses error messages if any function is loaded successfully.
+	else {
+		if (lib) {
+			open_func = snd_dlobj_cache_get(lib, open_name,
+				SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 0);
+		}
+
+		if (!open_func) {
+			snd_config_for_each(i, next, libs) {
+				snd_config_t *n = snd_config_iterator_entry(i);
+
+				err = snd_config_get_string(n, &libs_lib);
+				if (err < 0) {
+					SNDERR("Invalid entry in CTL %s libs definition", str);
+					goto _err;
+				}
+
+				if (!open_func) {
+					open_func = snd_dlobj_cache_get(libs_lib, open_name,
+						SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 0);
+				}
+			}
+		}
+
+		// Print error messages.
+		if (!open_func) {
+			if (lib) {
+				SNDERR("Either %s cannot be opened or %s was not defined inside",
+					lib, open_name);
+			}
+
+			snd_config_for_each(i, next, libs) {
+				snd_config_t *n = snd_config_iterator_entry(i);
+
+				snd_config_get_string(n, &libs_lib);
+				SNDERR("Either %s cannot be opened or %s was not defined inside",
+					libs_lib, open_name);
+			}
+		}
+	}
+
+	// Look in ALSA_PLUGIN_DIR iff we found nowhere else to look.
+	if (!lib && (!libs || !libs_lib)) {
 		const char *const *build_in = build_in_ctls;
 		while (*build_in) {
 			if (!strcmp(*build_in, str))
@@ -919,12 +991,11 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
 			lib = buf1;
 			sprintf(buf1, "%s/libasound_module_ctl_%s.so", ALSA_PLUGIN_DIR, str);
 		}
-	}
-#ifndef PIC
-	snd_control_open_symbols();
-#endif
-	open_func = snd_dlobj_cache_get(lib, open_name,
+
+		open_func = snd_dlobj_cache_get(lib, open_name,
 			SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 1);
+	}
+
 	if (open_func) {
 		err = open_func(ctlp, name, ctl_root, ctl_conf, mode);
 		if (err >= 0) {
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 2e24338..7f489f4 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -2116,6 +2116,10 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
 #ifndef PIC
 	extern void *snd_pcm_open_symbols(void);
 #endif
+
+	snd_config_t *libs = NULL;
+	const char *libs_lib = NULL;
+
 	if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
 		char *val;
 		id = NULL;
@@ -2160,6 +2164,19 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
 					SNDERR("Invalid type for %s", id);
 					goto _err;
 				}
+
+				continue;
+			}
+			// Handle an array of extra libs.
+			if (strcmp(id, "libs") == 0) {
+				if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+					SNDERR("Invalid type for libs definition in PCM %s definition",
+						str);
+					goto _err;
+				}
+
+				libs = n;
+
 				continue;
 			}
 			if (strcmp(id, "open") == 0) {
@@ -2184,7 +2201,62 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
 		open_name = buf;
 		sprintf(buf, "_snd_pcm_%s_open", str);
 	}
-	if (!lib) {
+
+#ifndef PIC
+	snd_pcm_open_symbols();	/* this call is for static linking only */
+#endif
+
+	// Normal alsa behaviour when there is no libs array.
+	if (!libs) {
+		if (lib) {
+			open_func = snd_dlobj_cache_get(lib, open_name,
+				SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 1);
+		}
+	}
+	// Handle libs array.
+	// Suppresses error messages if any function is loaded successfully.
+	else {
+		if (lib) {
+			open_func = snd_dlobj_cache_get(lib, open_name,
+				SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 0);
+		}
+
+		if (!open_func) {
+			snd_config_for_each(i, next, libs) {
+				snd_config_t *n = snd_config_iterator_entry(i);
+
+				err = snd_config_get_string(n, &libs_lib);
+				if (err < 0) {
+					SNDERR("Invalid entry in PCM %s libs definition", str);
+					goto _err;
+				}
+
+				if (!open_func) {
+					open_func = snd_dlobj_cache_get(libs_lib, open_name,
+						SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 0);
+				}
+			}
+		}
+
+		// Print error messages.
+		if (!open_func) {
+			if (lib) {
+				SNDERR("Either %s cannot be opened or %s was not defined inside",
+					lib, open_name);
+			}
+
+			snd_config_for_each(i, next, libs) {
+				snd_config_t *n = snd_config_iterator_entry(i);
+
+				snd_config_get_string(n, &libs_lib);
+				SNDERR("Either %s cannot be opened or %s was not defined inside",
+					libs_lib, open_name);
+			}
+		}
+	}
+
+	// Look in ALSA_PLUGIN_DIR iff we found nowhere else to look.
+	if (!lib && (!libs || !libs_lib)) {
 		const char *const *build_in = build_in_pcms;
 		while (*build_in) {
 			if (!strcmp(*build_in, str))
@@ -2200,12 +2272,11 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
 			lib = buf1;
 			sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str);
 		}
-	}
-#ifndef PIC
-	snd_pcm_open_symbols();	/* this call is for static linking only */
-#endif
-	open_func = snd_dlobj_cache_get(lib, open_name,
+
+		open_func = snd_dlobj_cache_get(lib, open_name,
 			SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 1);
+	}
+
 	if (open_func) {
 		err = open_func(pcmp, name, pcm_root, pcm_conf, stream, mode);
 		if (err >= 0) {