1 diff --git a/src/control/control.c b/src/control/control.c
2 index d66ed75..42cecad 100644
3 --- a/src/control/control.c
4 +++ b/src/control/control.c
5 @@ -838,6 +838,10 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
7 extern void *snd_control_open_symbols(void);
10 + snd_config_t *libs = NULL;
11 + const char *libs_lib = NULL;
13 if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND) {
15 SNDERR("Invalid type for CTL %s definition", name);
16 @@ -879,6 +883,19 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
17 SNDERR("Invalid type for %s", id);
23 + // Handle an array of extra libs.
24 + if (strcmp(id, "libs") == 0) {
25 + if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
26 + SNDERR("Invalid type for libs definition in CTL %s definition",
35 if (strcmp(id, "open") == 0) {
36 @@ -903,7 +920,62 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
38 sprintf(buf, "_snd_ctl_%s_open", str);
43 + snd_control_open_symbols();
46 + // Normal alsa behaviour when there is no libs array.
49 + open_func = snd_dlobj_cache_get(lib, open_name,
50 + SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 1);
53 + // Handle libs array.
54 + // Suppresses error messages if any function is loaded successfully.
57 + open_func = snd_dlobj_cache_get(lib, open_name,
58 + SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 0);
62 + snd_config_for_each(i, next, libs) {
63 + snd_config_t *n = snd_config_iterator_entry(i);
65 + err = snd_config_get_string(n, &libs_lib);
67 + SNDERR("Invalid entry in CTL %s libs definition", str);
72 + open_func = snd_dlobj_cache_get(libs_lib, open_name,
73 + SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 0);
78 + // Print error messages.
81 + SNDERR("Either %s cannot be opened or %s was not defined inside",
85 + snd_config_for_each(i, next, libs) {
86 + snd_config_t *n = snd_config_iterator_entry(i);
88 + snd_config_get_string(n, &libs_lib);
89 + SNDERR("Either %s cannot be opened or %s was not defined inside",
90 + libs_lib, open_name);
95 + // Look in ALSA_PLUGIN_DIR iff we found nowhere else to look.
96 + if (!lib && (!libs || !libs_lib)) {
97 const char *const *build_in = build_in_ctls;
99 if (!strcmp(*build_in, str))
100 @@ -919,12 +991,11 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
102 sprintf(buf1, "%s/libasound_module_ctl_%s.so", ALSA_PLUGIN_DIR, str);
106 - snd_control_open_symbols();
108 - open_func = snd_dlobj_cache_get(lib, open_name,
110 + open_func = snd_dlobj_cache_get(lib, open_name,
111 SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 1);
115 err = open_func(ctlp, name, ctl_root, ctl_conf, mode);
117 diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
118 index 2e24338..7f489f4 100644
121 @@ -2116,6 +2116,10 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
123 extern void *snd_pcm_open_symbols(void);
126 + snd_config_t *libs = NULL;
127 + const char *libs_lib = NULL;
129 if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
132 @@ -2160,6 +2164,19 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
133 SNDERR("Invalid type for %s", id);
139 + // Handle an array of extra libs.
140 + if (strcmp(id, "libs") == 0) {
141 + if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
142 + SNDERR("Invalid type for libs definition in PCM %s definition",
151 if (strcmp(id, "open") == 0) {
152 @@ -2184,7 +2201,62 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
154 sprintf(buf, "_snd_pcm_%s_open", str);
159 + snd_pcm_open_symbols(); /* this call is for static linking only */
162 + // Normal alsa behaviour when there is no libs array.
165 + open_func = snd_dlobj_cache_get(lib, open_name,
166 + SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 1);
169 + // Handle libs array.
170 + // Suppresses error messages if any function is loaded successfully.
173 + open_func = snd_dlobj_cache_get(lib, open_name,
174 + SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 0);
178 + snd_config_for_each(i, next, libs) {
179 + snd_config_t *n = snd_config_iterator_entry(i);
181 + err = snd_config_get_string(n, &libs_lib);
183 + SNDERR("Invalid entry in PCM %s libs definition", str);
188 + open_func = snd_dlobj_cache_get(libs_lib, open_name,
189 + SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 0);
194 + // Print error messages.
197 + SNDERR("Either %s cannot be opened or %s was not defined inside",
201 + snd_config_for_each(i, next, libs) {
202 + snd_config_t *n = snd_config_iterator_entry(i);
204 + snd_config_get_string(n, &libs_lib);
205 + SNDERR("Either %s cannot be opened or %s was not defined inside",
206 + libs_lib, open_name);
211 + // Look in ALSA_PLUGIN_DIR iff we found nowhere else to look.
212 + if (!lib && (!libs || !libs_lib)) {
213 const char *const *build_in = build_in_pcms;
215 if (!strcmp(*build_in, str))
216 @@ -2200,12 +2272,11 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
218 sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str);
222 - snd_pcm_open_symbols(); /* this call is for static linking only */
224 - open_func = snd_dlobj_cache_get(lib, open_name,
226 + open_func = snd_dlobj_cache_get(lib, open_name,
227 SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 1);
231 err = open_func(pcmp, name, pcm_root, pcm_conf, stream, mode);