mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-03 09:01:52 -05:00
* Cleaned the alsa.conf syntax:
- added pcm.front, pcm.rear, pcm.center_lfe blocks * Added configuration for EMU10K1 (it's fully working one!!!) * snd_config_redirect_load->snd_config_refer_load rename * snd_config_search_alias code change (works also with pairs base.key) * cleanups in the evaluate function (the function prototype has been changed)
This commit is contained in:
parent
1b8d405606
commit
977a9a33f0
25 changed files with 468 additions and 266 deletions
|
|
@ -459,32 +459,50 @@ int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
|
|||
return open_func(ctlp, name, ctl_conf, mode);
|
||||
}
|
||||
|
||||
int snd_ctl_open_noupdate(snd_ctl_t **ctlp, const char *name, int mode)
|
||||
int snd_ctl_open_noupdate(snd_ctl_t **ctlp, snd_config_t *root, const char *name, int mode)
|
||||
{
|
||||
int err;
|
||||
snd_config_t *ctl_conf;
|
||||
char *base, *key;
|
||||
const char *args = strchr(name, ':');
|
||||
char *base;
|
||||
|
||||
if (args) {
|
||||
args++;
|
||||
base = alloca(args - name);
|
||||
memcpy(base, name, args - name - 1);
|
||||
base[args - name - 1] = 0;
|
||||
} else
|
||||
base = (char *) name;
|
||||
err = snd_config_search_alias(snd_config, "ctl", base, &ctl_conf);
|
||||
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, &ctl_conf);
|
||||
if (err < 0) {
|
||||
SNDERR("Unknown CTL %s", name);
|
||||
(void)(base == NULL && (err = snd_config_search_alias(root, "ctl", key, &ctl_conf)));
|
||||
if (err < 0) {
|
||||
SNDERR("Unknown PCM %s", name);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
err = snd_config_expand(ctl_conf, args, NULL, &ctl_conf);
|
||||
if (err < 0) {
|
||||
SNDERR("Could not expand configuration for %s: %s", name, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
if (args) {
|
||||
err = snd_config_expand(ctl_conf, args, NULL, &ctl_conf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
err = snd_ctl_open_conf(ctlp, name, ctl_conf, mode);
|
||||
if (args)
|
||||
snd_config_delete(ctl_conf);
|
||||
snd_config_delete(ctl_conf);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
@ -502,7 +520,7 @@ int snd_ctl_open(snd_ctl_t **ctlp, const char *name, int mode)
|
|||
err = snd_config_update();
|
||||
if (err < 0)
|
||||
return err;
|
||||
return snd_ctl_open_noupdate(ctlp, name, mode);
|
||||
return snd_ctl_open_noupdate(ctlp, snd_config, name, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ static int add_elem(snd_sctl_t *h, snd_config_t *conf,
|
|||
{
|
||||
snd_config_iterator_t i, next;
|
||||
char *tmp;
|
||||
int iface = SND_CTL_ELEM_IFACE_PCM;
|
||||
int iface = SND_CTL_ELEM_IFACE_MIXER;
|
||||
char *name = NULL;
|
||||
long index = 0;
|
||||
long device = -1;
|
||||
|
|
@ -452,7 +452,7 @@ static int add_elem(snd_sctl_t *h, snd_config_t *conf,
|
|||
const char *id = snd_config_get_id(n);
|
||||
if (strcmp(id, "comment") == 0)
|
||||
continue;
|
||||
if (strcmp(id, "iface") == 0) {
|
||||
if (strcmp(id, "iface") == 0 || strcmp(id, "interface") == 0) {
|
||||
if ((err = config_replace(n, callback, private_data, &tmp)) < 0)
|
||||
goto _err;
|
||||
if ((err = snd_config_get_ctl_iface_ascii(tmp)) < 0) {
|
||||
|
|
@ -471,6 +471,7 @@ static int add_elem(snd_sctl_t *h, snd_config_t *conf,
|
|||
if (strcmp(id, "index") == 0) {
|
||||
if ((err = config_replace_integer(n, callback, private_data, &index)) < 0)
|
||||
goto _err;
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "device") == 0) {
|
||||
if ((err = config_replace_integer(n, callback, private_data, &device)) < 0)
|
||||
|
|
@ -544,7 +545,7 @@ static int add_elem(snd_sctl_t *h, snd_config_t *conf,
|
|||
snd_ctl_elem_info_set_id(elem->info, elem->id);
|
||||
err = snd_ctl_elem_info(h->ctl, elem->info);
|
||||
if (err < 0) {
|
||||
SNDERR("Cannot obtain info for CTL elem");
|
||||
SNDERR("Cannot obtain info for CTL elem (%s,'%s',%li,%li,%li): %s", snd_ctl_elem_iface_name(iface), name, index, device, subdevice, snd_strerror(err));
|
||||
goto _err;
|
||||
}
|
||||
snd_ctl_elem_value_set_id(elem->val, elem->id);
|
||||
|
|
@ -597,6 +598,7 @@ int snd_sctl_build(snd_sctl_t **sctl, snd_ctl_t *handle, snd_config_t *conf,
|
|||
int err;
|
||||
|
||||
assert(sctl);
|
||||
assert(handle);
|
||||
assert(conf);
|
||||
if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND)
|
||||
return -EINVAL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue