* 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:
Jaroslav Kysela 2001-06-15 08:47:59 +00:00
parent 1b8d405606
commit 977a9a33f0
25 changed files with 468 additions and 266 deletions

View file

@ -1001,9 +1001,8 @@ static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root,
{
int err;
snd_config_t *pcm_conf;
char *key;
char *base, *key;
const char *args = strchr(name, ':');
char *base;
snd_config_t *conf;
if (args) {
args++;
@ -1037,23 +1036,23 @@ static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root,
}
err = snd_config_expand(pcm_conf, args, NULL, &pcm_conf);
if (err < 0) {
SNDERR("Could not expand configuration: %s", snd_strerror(err));
SNDERR("Could not expand configuration for %s: %s", name, snd_strerror(err));
return err;
}
if (snd_config_search(pcm_conf, "refer", &conf) >= 0) {
snd_config_t *tmp_conf;
int conf_free_tmp;
char *redir_name = NULL;
err = snd_config_redirect_load(root, conf, &redir_name, &tmp_conf, &conf_free_tmp);
char *refer_name = NULL;
err = snd_config_refer_load(root, conf, &refer_name, &tmp_conf, &conf_free_tmp);
if (args)
snd_config_delete(pcm_conf);
if (err < 0) {
SNDERR("Redirect error: %s", snd_strerror(err));
SNDERR("Refer load error for %s: %s", name, snd_strerror(err));
return err;
}
err = snd_pcm_open_noupdate(pcmp, tmp_conf, redir_name, stream, mode);
if (redir_name)
free(redir_name);
err = snd_pcm_open_noupdate(pcmp, tmp_conf, refer_name, stream, mode);
if (refer_name)
free(refer_name);
if (conf_free_tmp)
snd_config_delete(tmp_conf);
return err;
@ -1083,25 +1082,13 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
}
#ifndef DOC_HIDDEN
int snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root, snd_config_t *conf,
const char *args, snd_pcm_stream_t stream, int mode)
int snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root,
snd_config_t *conf, snd_pcm_stream_t stream,
int mode)
{
const char *str;
if (snd_config_get_string(conf, &str) >= 0) {
char *tmp;
int err;
if (args == NULL)
return snd_pcm_open_noupdate(pcmp, root, str, stream, mode);
tmp = malloc(strlen(str) + 1 + strlen(args) + 1);
if (tmp == NULL)
return -ENOMEM;
strcpy(tmp, str);
strcat(tmp, ":");
strcat(tmp, args);
err = snd_pcm_open_noupdate(pcmp, root, tmp, stream, mode);
free(tmp);
return err;
}
if (snd_config_get_string(conf, &str) >= 0)
return snd_pcm_open_noupdate(pcmp, root, str, stream, mode);
return snd_pcm_open_conf(pcmp, NULL, root, conf, stream, mode);
}
#endif
@ -4318,8 +4305,7 @@ static const char *names[SND_PCM_HW_PARAM_LAST + 1] = {
};
int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
snd_config_t **pcm_conf, const char **pcm_args,
unsigned int count, ...)
snd_config_t **_pcm_conf, unsigned int count, ...)
{
snd_config_iterator_t i, next;
const char *str;
@ -4330,48 +4316,18 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
int valid;
} fields[count];
unsigned int k;
int pcm_valid = 0;
snd_config_t *pcm_conf = NULL;
int err;
va_list args;
assert(root);
assert(conf);
assert(pcm_conf);
assert(_pcm_conf);
if (snd_config_get_string(conf, &str) >= 0) {
char *key;
const char *args = strchr(str, ':');
char *base;
if (args) {
args++;
base = alloca(args - str);
memcpy(base, str, args - str - 1);
base[args - str - 1] = '\0';
key = strchr(base, '.');
if (key)
*key++ = '\0';
} else {
key = strchr(str, '.');
if (key) {
key++;
base = alloca(key - str);
memcpy(base, str, key - str - 1);
base[key - str - 1] = '\0';
} else
base = (char *) str;
}
if (key == NULL) {
key = base;
base = NULL;
}
err = snd_config_search_alias(root, base, key, &conf);
err = snd_config_search_alias(conf, "pcm_slave", str, &conf);
if (err < 0) {
(void)(base == NULL && (err = snd_config_search_alias(root, "pcm_slave", key, &conf)));
if (err < 0) {
SNDERR("unknown pcm_slave %s", str);
return err;
}
SNDERR("Configuration pcm_slave.%s was not found\n", str);
return -EINVAL;
}
if (pcm_args)
*pcm_args = args;
}
if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid slave definition");
@ -4391,8 +4347,7 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(id, "pcm") == 0) {
*pcm_conf = n;
pcm_valid = 1;
pcm_conf = n;
continue;
}
for (k = 0; k < count; ++k) {
@ -4435,7 +4390,7 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
SNDERR("Unknown field %s", id);
// return -EINVAL;
}
if (!pcm_valid) {
if (!pcm_conf) {
SNDERR("missing field pcm");
return -EINVAL;
}
@ -4445,6 +4400,7 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
return -EINVAL;
}
}
*_pcm_conf = pcm_conf;
return 0;
}

View file

@ -556,7 +556,6 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_t *spcm;
snd_config_t *slave = NULL, *sconf;
snd_pcm_format_t sformat;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -573,7 +572,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 1,
err = snd_pcm_slave_conf(root, slave, &sconf, 1,
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
if (err < 0)
return err;
@ -582,7 +581,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
SNDERR("invalid slave format");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_adpcm_open(pcmp, name, sformat, spcm, 1);

View file

@ -429,7 +429,6 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_t *spcm;
snd_config_t *slave = NULL, *sconf;
snd_pcm_format_t sformat;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -446,7 +445,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 1,
err = snd_pcm_slave_conf(root, slave, &sconf, 1,
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
if (err < 0)
return err;
@ -455,7 +454,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
SNDERR("invalid slave format");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_alaw_open(pcmp, name, sformat, spcm, 1);

View file

@ -198,7 +198,6 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
int err;
snd_pcm_t *spcm;
snd_config_t *slave = NULL, *sconf;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -215,10 +214,10 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 0);
err = snd_pcm_slave_conf(root, slave, &sconf, 0);
if (err < 0)
return err;
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_copy_open(pcmp, name, spcm, 1);

View file

@ -466,7 +466,6 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
const char *fname = NULL;
const char *format = NULL;
long fd = -1;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -502,14 +501,14 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 0);
err = snd_pcm_slave_conf(root, slave, &sconf, 0);
if (err < 0)
return err;
if (!fname && fd < 0) {
SNDERR("file is not defined");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_file_open(pcmp, name, fname, fd, format, spcm, 1);

View file

@ -355,7 +355,7 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
type = n;
continue;
}
if (strcmp(id, "args") == 0) {
if (strcmp(id, "hook_args") == 0) {
args = n;
continue;
}
@ -441,7 +441,6 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_t *spcm;
snd_config_t *slave = NULL, *sconf;
snd_config_t *hooks = NULL;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -466,10 +465,10 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 0);
err = snd_pcm_slave_conf(root, slave, &sconf, 0);
if (err < 0)
return err;
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_hooks_open(pcmp, name, spcm, 1);

View file

@ -334,7 +334,6 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_t *spcm;
snd_config_t *slave = NULL, *sconf;
snd_pcm_format_t sformat;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -351,7 +350,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 1,
err = snd_pcm_slave_conf(root, slave, &sconf, 1,
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
if (err < 0)
return err;
@ -359,7 +358,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave format is not linear");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_linear_open(pcmp, name, sformat, spcm, 1);

View file

@ -527,11 +527,12 @@ int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int orde
snd_pcm_hw_strategy_simple_choices_list_t *choices);
#endif
int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf, snd_config_t **pcm_conf,
const char **args, unsigned int count, ...);
int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
snd_config_t **pcm_conf, unsigned int count, ...);
int snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root, snd_config_t *conf,
const char *args, snd_pcm_stream_t stream, int mode);
int snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root,
snd_config_t *conf, snd_pcm_stream_t stream,
int mode);
int snd_pcm_conf_generic_id(const char *id);
#define SND_PCM_HW_PARBIT_ACCESS (1U << SND_PCM_HW_PARAM_ACCESS)

View file

@ -743,7 +743,6 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *slave = NULL, *sconf;
long frequency = -1;
snd_config_t *scopes = NULL;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -776,10 +775,10 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 0);
err = snd_pcm_slave_conf(root, slave, &sconf, 0);
if (err < 0)
return err;
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_meter_open(pcmp, name, frequency > 0 ? (unsigned int) frequency : FREQUENCY, spcm, 1);

View file

@ -444,7 +444,6 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_t *spcm;
snd_config_t *slave = NULL, *sconf;
snd_pcm_format_t sformat;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -461,7 +460,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 1,
err = snd_pcm_slave_conf(root, slave, &sconf, 1,
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
if (err < 0)
return err;
@ -470,7 +469,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
SNDERR("invalid slave format");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_mulaw_open(pcmp, name, sformat, spcm, 1);

View file

@ -659,7 +659,6 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
unsigned int idx;
const char **slaves_id = NULL;
snd_config_t **slaves_conf = NULL;
const char **slaves_args = NULL;
snd_pcm_t **slaves_pcm = NULL;
unsigned int *slaves_channels = NULL;
int *channels_sidx = NULL;
@ -731,7 +730,6 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
}
slaves_id = calloc(slaves_count, sizeof(*slaves_id));
slaves_conf = calloc(slaves_count, sizeof(*slaves_conf));
slaves_args = calloc(slaves_count, sizeof(*slaves_args));
slaves_pcm = calloc(slaves_count, sizeof(*slaves_pcm));
slaves_channels = calloc(slaves_count, sizeof(*slaves_channels));
channels_sidx = calloc(channels_count, sizeof(*channels_sidx));
@ -744,7 +742,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *m = snd_config_iterator_entry(i);
int channels;
slaves_id[idx] = snd_config_get_id(m);
err = snd_pcm_slave_conf(root, m, &slaves_conf[idx], &slaves_args[idx], 1,
err = snd_pcm_slave_conf(root, m, &slaves_conf[idx], 1,
SND_PCM_HW_PARAM_CHANNELS, 1, &channels);
if (err < 0)
goto _free;
@ -818,7 +816,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
}
for (idx = 0; idx < slaves_count; ++idx) {
err = snd_pcm_open_slave(&slaves_pcm[idx], root, slaves_conf[idx], slaves_args[idx], stream, mode);
err = snd_pcm_open_slave(&slaves_pcm[idx], root, slaves_conf[idx], stream, mode);
if (err < 0)
goto _free;
}
@ -836,8 +834,6 @@ _free:
}
if (slaves_conf)
free(slaves_conf);
if (slaves_args)
free(slaves_args);
if (slaves_pcm)
free(slaves_pcm);
if (slaves_channels)

View file

@ -721,7 +721,6 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *tt = NULL;
snd_pcm_route_ttable_entry_t *ttable = NULL;
unsigned int cused, sused;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -746,7 +745,7 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 0);
err = snd_pcm_slave_conf(root, slave, &sconf, 0);
if (err < 0)
return err;
if (tt) {
@ -757,7 +756,7 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
return err;
}
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_plug_open(pcmp, name, ttable, MAX_CHANNELS, cused, sused, spcm, 1);

View file

@ -544,7 +544,6 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *slave = NULL, *sconf;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
int srate = -1;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -561,7 +560,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 2,
err = snd_pcm_slave_conf(root, slave, &sconf, 2,
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
SND_PCM_HW_PARAM_RATE, 1, &srate);
if (err < 0)
@ -571,7 +570,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
SNDERR("slave format is not linear");
return -EINVAL;
}
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_rate_open(pcmp, name,

View file

@ -848,7 +848,6 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *tt = NULL;
snd_pcm_route_ttable_entry_t ttable[MAX_CHANNELS*MAX_CHANNELS];
unsigned int cused, sused;
const char *args;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
@ -877,7 +876,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
SNDERR("ttable is not defined");
return -EINVAL;
}
err = snd_pcm_slave_conf(root, slave, &sconf, &args, 2,
err = snd_pcm_slave_conf(root, slave, &sconf, 2,
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
SND_PCM_HW_PARAM_CHANNELS, 0, &schannels);
if (err < 0)
@ -893,7 +892,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
if (err < 0)
return err;
err = snd_pcm_open_slave(&spcm, root, sconf, args, stream, mode);
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
if (err < 0)
return err;
err = snd_pcm_route_open(pcmp, name, sformat, schannels,