mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Extended parameterization. Marked with @ all fields with special use
This commit is contained in:
		
							parent
							
								
									cf325c68e3
								
							
						
					
					
						commit
						54daf2f16d
					
				
					 16 changed files with 315 additions and 349 deletions
				
			
		| 
						 | 
				
			
			@ -91,11 +91,11 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
 | 
			
		|||
		SNDERR("Invalid type for %s", snd_config_get_id(conf));
 | 
			
		||||
		return err;
 | 
			
		||||
	}
 | 
			
		||||
	err = snd_config_search_alias(snd_config, "rawmidi_type", str, &type_conf);
 | 
			
		||||
	err = snd_config_search_definition(snd_config, "rawmidi_type", str, &type_conf);
 | 
			
		||||
	if (err >= 0) {
 | 
			
		||||
		if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
 | 
			
		||||
			SNDERR("Invalid type for RAWMIDI type %s definition", str);
 | 
			
		||||
			return -EINVAL;
 | 
			
		||||
			goto _err;
 | 
			
		||||
		}
 | 
			
		||||
		snd_config_for_each(i, next, type_conf) {
 | 
			
		||||
			snd_config_t *n = snd_config_iterator_entry(i);
 | 
			
		||||
| 
						 | 
				
			
			@ -106,7 +106,7 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
 | 
			
		|||
				err = snd_config_get_string(n, &lib);
 | 
			
		||||
				if (err < 0) {
 | 
			
		||||
					SNDERR("Invalid type for %s", id);
 | 
			
		||||
					return -EINVAL;
 | 
			
		||||
					goto _err;
 | 
			
		||||
				}
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -114,11 +114,13 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
 | 
			
		|||
				err = snd_config_get_string(n, &open_name);
 | 
			
		||||
				if (err < 0) {
 | 
			
		||||
					SNDERR("Invalid type for %s", id);
 | 
			
		||||
					return -EINVAL;
 | 
			
		||||
					goto _err;
 | 
			
		||||
				}
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
			SNDERR("Unknown field %s", id);
 | 
			
		||||
		_err:
 | 
			
		||||
			snd_config_delete(type_conf);
 | 
			
		||||
			return -EINVAL;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -129,11 +131,14 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
 | 
			
		|||
	if (!lib)
 | 
			
		||||
		lib = ALSA_LIB;
 | 
			
		||||
	h = dlopen(lib, RTLD_NOW);
 | 
			
		||||
	if (h)
 | 
			
		||||
		open_func = dlsym(h, open_name);
 | 
			
		||||
	if (type_conf)
 | 
			
		||||
		snd_config_delete(type_conf);
 | 
			
		||||
	if (!h) {
 | 
			
		||||
		SNDERR("Cannot open shared library %s", lib);
 | 
			
		||||
		return -ENOENT;
 | 
			
		||||
	}
 | 
			
		||||
	open_func = dlsym(h, open_name);
 | 
			
		||||
	if (!open_func) {
 | 
			
		||||
		SNDERR("symbol %s is not defined inside %s", open_name, lib);
 | 
			
		||||
		dlclose(h);
 | 
			
		||||
| 
						 | 
				
			
			@ -160,44 +165,11 @@ int snd_rawmidi_open_noupdate(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
 | 
			
		|||
{
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_config_t *rawmidi_conf;
 | 
			
		||||
	char *base, *key;
 | 
			
		||||
	const char *args = strchr(name, ':');
 | 
			
		||||
 | 
			
		||||
	if (args) {
 | 
			
		||||
		args++;
 | 
			
		||||
		base = alloca(args - name);
 | 
			
		||||
		memcpy(base, name, args - name - 1);
 | 
			
		||||
		base[args - name - 1] = '\0';
 | 
			
		||||
		key = strchr(base, '.');
 | 
			
		||||
		if (key)
 | 
			
		||||
			*key++ = '\0';
 | 
			
		||||
	} else {
 | 
			
		||||
		key = strchr(name, '.');
 | 
			
		||||
		if (key) {
 | 
			
		||||
			key++;
 | 
			
		||||
			base = alloca(key - name);
 | 
			
		||||
			memcpy(base, name, key - name - 1);
 | 
			
		||||
			base[key - name - 1] = '\0';
 | 
			
		||||
		} else
 | 
			
		||||
			base = (char *) name;
 | 
			
		||||
	}
 | 
			
		||||
	if (key == NULL) {
 | 
			
		||||
		key = base;
 | 
			
		||||
		base = NULL;
 | 
			
		||||
	}
 | 
			
		||||
	err = snd_config_search_alias(root, base, key, &rawmidi_conf);
 | 
			
		||||
	err = snd_config_search_definition(root, "rawmidi", name, &rawmidi_conf);
 | 
			
		||||
	if (err < 0) {
 | 
			
		||||
		(void)(base == NULL && (err = snd_config_search_alias(root, "rawmidi", key, &rawmidi_conf)));
 | 
			
		||||
		if (err < 0) {
 | 
			
		||||
			SNDERR("Unknown RawMidi %s", name);
 | 
			
		||||
			return err;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	err = snd_config_expand(rawmidi_conf, args, NULL, &rawmidi_conf);
 | 
			
		||||
	if (err < 0) {
 | 
			
		||||
		SNDERR("Could not expand configuration for %s: %s", name, snd_strerror(err));
 | 
			
		||||
		SNDERR("Unknown RawMidi %s", name);
 | 
			
		||||
		return err;
 | 
			
		||||
        }
 | 
			
		||||
	}
 | 
			
		||||
	err = snd_rawmidi_open_conf(inputp, outputp, name, rawmidi_conf, mode);
 | 
			
		||||
	snd_config_delete(rawmidi_conf);
 | 
			
		||||
	return err;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue