Encapsulated conf API

This commit is contained in:
Abramo Bagnara 2001-02-07 11:34:33 +00:00
parent 8f0cb26fdf
commit 3e091c8822
26 changed files with 473 additions and 404 deletions

View file

@ -591,15 +591,16 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
ERR("Unknown PCM %s", name);
return -ENOENT;
}
if (snd_config_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for PCM %s definition", name);
return -EINVAL;
}
err = snd_config_search(pcm_conf, "stream", &conf);
if (err >= 0) {
err = snd_config_string_get(conf, &str);
const char *id = snd_config_get_id(conf);
err = snd_config_get_string(conf, &str);
if (err < 0) {
ERR("Invalid type for %s", conf->id);
ERR("Invalid type for %s", id);
return err;
}
if (strcmp(str, "playback") == 0) {
@ -609,7 +610,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
if (stream != SND_PCM_STREAM_CAPTURE)
return -EINVAL;
} else {
ERR("Invalid value for %s", conf->id);
ERR("Invalid value for %s", id);
return -EINVAL;
}
}
@ -618,9 +619,9 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
ERR("type is not defined");
return err;
}
err = snd_config_string_get(conf, &str);
err = snd_config_get_string(conf, &str);
if (err < 0) {
ERR("Invalid type for %s", conf->id);
ERR("Invalid type for %s", snd_config_get_id(conf));
return err;
}
err = snd_config_searchv(snd_config, &type_conf, "pcmtype", str, 0);
@ -629,25 +630,26 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
return err;
}
snd_config_foreach(i, type_conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "lib") == 0) {
err = snd_config_string_get(n, &lib);
if (strcmp(id, "lib") == 0) {
err = snd_config_get_string(n, &lib);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "open") == 0) {
err = snd_config_string_get(n, &open);
if (strcmp(id, "open") == 0) {
err = snd_config_get_string(n, &open);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
}

View file

@ -602,26 +602,27 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "sformat") == 0) {
if (strcmp(id, "sformat") == 0) {
const char *f;
err = snd_config_string_get(n, &f);
err = snd_config_get_string(n, &f);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
sformat = snd_pcm_format_value(f);
@ -636,7 +637,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -475,26 +475,27 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "sformat") == 0) {
if (strcmp(id, "sformat") == 0) {
const char *f;
err = snd_config_string_get(n, &f);
err = snd_config_get_string(n, &f);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
sformat = snd_pcm_format_value(f);
@ -509,7 +510,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -232,22 +232,23 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, char *name,
int err;
snd_pcm_t *spcm;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -471,41 +471,42 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name,
const char *format = NULL;
long fd = -1;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "format") == 0) {
err = snd_config_string_get(n, &format);
if (strcmp(id, "format") == 0) {
err = snd_config_get_string(n, &format);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "file") == 0) {
err = snd_config_string_get(n, &fname);
if (strcmp(id, "file") == 0) {
err = snd_config_get_string(n, &fname);
if (err < 0) {
err = snd_config_integer_get(n, &fd);
err = snd_config_get_integer(n, &fd);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -681,46 +681,47 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
const char *str;
int err;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "card") == 0) {
err = snd_config_integer_get(n, &card);
if (strcmp(id, "card") == 0) {
err = snd_config_get_integer(n, &card);
if (err < 0) {
err = snd_config_string_get(n, &str);
err = snd_config_get_string(n, &str);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
card = snd_card_get_index(str);
if (card < 0) {
ERR("Invalid value for %s", n->id);
ERR("Invalid value for %s", id);
return card;
}
}
continue;
}
if (strcmp(n->id, "device") == 0) {
err = snd_config_integer_get(n, &device);
if (strcmp(id, "device") == 0) {
err = snd_config_get_integer(n, &device);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return err;
}
continue;
}
if (strcmp(n->id, "subdevice") == 0) {
err = snd_config_integer_get(n, &subdevice);
if (strcmp(id, "subdevice") == 0) {
err = snd_config_get_integer(n, &subdevice);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return err;
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (card < 0) {

View file

@ -373,26 +373,27 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "sformat") == 0) {
if (strcmp(id, "sformat") == 0) {
const char *f;
err = snd_config_string_get(n, &f);
err = snd_config_get_string(n, &f);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
sformat = snd_pcm_format_value(f);
@ -406,7 +407,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -490,26 +490,27 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "sformat") == 0) {
if (strcmp(id, "sformat") == 0) {
const char *f;
err = snd_config_string_get(n, &f);
err = snd_config_get_string(n, &f);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
sformat = snd_pcm_format_value(f);
@ -524,7 +525,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -597,30 +597,31 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
unsigned int slaves_count = 0;
unsigned int channels_count = 0;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "slave") == 0) {
if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", n->id);
if (strcmp(id, "slave") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", id);
return -EINVAL;
}
slave = n;
continue;
}
if (strcmp(n->id, "binding") == 0) {
if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", n->id);
if (strcmp(id, "binding") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", id);
return -EINVAL;
}
binding = n;
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!slave) {
@ -637,11 +638,12 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
snd_config_foreach(i, binding) {
int cchannel = -1;
char *p;
snd_config_t *m = snd_config_entry(i);
snd_config_t *m = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(m);
errno = 0;
cchannel = strtol(m->id, &p, 10);
cchannel = strtol(id, &p, 10);
if (errno || *p || cchannel < 0) {
ERR("Invalid channel number: %s", m->id);
ERR("Invalid channel number: %s", id);
return -EINVAL;
}
if ((unsigned)cchannel >= channels_count)
@ -662,31 +664,32 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
channels_sidx[idx] = -1;
idx = 0;
snd_config_foreach(i, slave) {
snd_config_t *m = snd_config_entry(i);
snd_config_t *m = snd_config_iterator_entry(i);
const char *name = NULL;
long channels = -1;
slaves_id[idx] = m->id;
slaves_id[idx] = snd_config_get_id(m);
snd_config_foreach(j, m) {
snd_config_t *n = snd_config_entry(j);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(j);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "name") == 0) {
err = snd_config_string_get(n, &name);
if (strcmp(id, "name") == 0) {
err = snd_config_get_string(n, &name);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
goto _free;
}
continue;
}
if (strcmp(n->id, "channels") == 0) {
err = snd_config_integer_get(n, &channels);
if (strcmp(id, "channels") == 0) {
err = snd_config_get_integer(n, &channels);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
goto _free;
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
err = -EINVAL;
goto _free;
}
@ -706,30 +709,32 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
}
snd_config_foreach(i, binding) {
snd_config_t *m = snd_config_entry(i);
snd_config_t *m = snd_config_iterator_entry(i);
long cchannel = -1;
long schannel = -1;
int slave = -1;
long val;
const char *str;
cchannel = strtol(m->id, 0, 10);
const char *id = snd_config_get_id(m);
cchannel = strtol(id, 0, 10);
if (cchannel < 0) {
ERR("Invalid channel number: %s", m->id);
ERR("Invalid channel number: %s", id);
err = -EINVAL;
goto _free;
}
snd_config_foreach(j, m) {
snd_config_t *n = snd_config_entry(j);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(j);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "sidx") == 0) {
if (strcmp(id, "sidx") == 0) {
char buf[32];
unsigned int k;
err = snd_config_string_get(n, &str);
err = snd_config_get_string(n, &str);
if (err < 0) {
err = snd_config_integer_get(n, &val);
err = snd_config_get_integer(n, &val);
if (err < 0) {
ERR("Invalid value for %s", n->id);
ERR("Invalid value for %s", id);
goto _free;
}
sprintf(buf, "%ld", val);
@ -741,15 +746,15 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
}
continue;
}
if (strcmp(n->id, "schannel") == 0) {
err = snd_config_integer_get(n, &schannel);
if (strcmp(id, "schannel") == 0) {
err = snd_config_get_integer(n, &schannel);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
goto _free;
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
err = -EINVAL;
goto _free;
}

View file

@ -376,14 +376,15 @@ int _snd_pcm_null_open(snd_pcm_t **pcmp, char *name,
{
snd_config_iterator_t i;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
return snd_pcm_null_open(pcmp, name, stream, mode);

View file

@ -712,30 +712,31 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_route_ttable_entry_t *ttable = NULL;
unsigned int cused, sused;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "ttable") == 0) {
if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", n->id);
if (strcmp(id, "ttable") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", id);
return -EINVAL;
}
tt = n;
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -628,26 +628,27 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
long srate = -1;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "sformat") == 0) {
if (strcmp(id, "sformat") == 0) {
const char *f;
err = snd_config_string_get(n, &f);
err = snd_config_get_string(n, &f);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
sformat = snd_pcm_format_value(f);
@ -661,15 +662,15 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
}
continue;
}
if (strcmp(n->id, "srate") == 0) {
err = snd_config_integer_get(n, &srate);
if (strcmp(id, "srate") == 0) {
err = snd_config_get_integer(n, &srate);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -828,38 +828,39 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
for (k = 0; k < tt_csize * tt_ssize; ++k)
ttable[k] = 0.0;
snd_config_foreach(i, tt) {
snd_config_t *in = snd_config_entry(i);
snd_config_t *in = snd_config_iterator_entry(i);
snd_config_iterator_t j;
char *p;
long cchannel;
errno = 0;
cchannel = strtol(in->id, &p, 10);
cchannel = strtol(snd_config_get_id(in), &p, 10);
if (errno || *p ||
cchannel < 0 || (unsigned int) cchannel > tt_csize) {
ERR("Invalid client channel: %s", in->id);
ERR("Invalid client channel: %s", snd_config_get_id(in));
return -EINVAL;
}
if (snd_config_type(in) != SND_CONFIG_TYPE_COMPOUND)
if (snd_config_get_type(in) != SND_CONFIG_TYPE_COMPOUND)
return -EINVAL;
snd_config_foreach(j, in) {
snd_config_t *jn = snd_config_entry(j);
snd_config_t *jn = snd_config_iterator_entry(j);
double value;
long schannel;
int err;
const char *id = snd_config_get_id(jn);
errno = 0;
schannel = strtol(jn->id, &p, 10);
schannel = strtol(id, &p, 10);
if (errno || *p ||
schannel < 0 || (unsigned int) schannel > tt_ssize ||
(schannels > 0 && schannel >= schannels)) {
ERR("Invalid slave channel: %s", jn->id);
ERR("Invalid slave channel: %s", id);
return -EINVAL;
}
err = snd_config_real_get(jn, &value);
err = snd_config_get_real(jn, &value);
if (err < 0) {
long v;
err = snd_config_integer_get(jn, &v);
err = snd_config_get_integer(jn, &v);
if (err < 0) {
ERR("Invalid type for %s", jn->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
value = v;
@ -892,26 +893,27 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
snd_pcm_route_ttable_entry_t ttable[MAX_CHANNELS*MAX_CHANNELS];
unsigned int cused, sused;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "sformat") == 0) {
if (strcmp(id, "sformat") == 0) {
const char *f;
err = snd_config_string_get(n, &f);
err = snd_config_get_string(n, &f);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
sformat = snd_pcm_format_value(f);
@ -925,23 +927,23 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
}
continue;
}
if (strcmp(n->id, "schannels") == 0) {
err = snd_config_integer_get(n, &schannels);
if (strcmp(id, "schannels") == 0) {
err = snd_config_get_integer(n, &schannels);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "ttable") == 0) {
if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", n->id);
if (strcmp(id, "ttable") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", id);
return -EINVAL;
}
tt = n;
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {

View file

@ -1374,26 +1374,27 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
long srate = -1;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "sformat") == 0) {
if (strcmp(id, "sformat") == 0) {
const char *f;
err = snd_config_string_get(n, &f);
err = snd_config_get_string(n, &f);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
sformat = snd_pcm_format_value(f);
@ -1403,31 +1404,31 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
}
continue;
}
if (strcmp(n->id, "schannels") == 0) {
err = snd_config_integer_get(n, &schannels_count);
if (strcmp(id, "schannels") == 0) {
err = snd_config_get_integer(n, &schannels_count);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "srate") == 0) {
err = snd_config_integer_get(n, &srate);
if (strcmp(id, "srate") == 0) {
err = snd_config_get_integer(n, &srate);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "binding") == 0) {
if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", n->id);
if (strcmp(id, "binding") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
ERR("Invalid type for %s", id);
return -EINVAL;
}
binding = n;
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {
@ -1441,11 +1442,12 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
snd_config_foreach(i, binding) {
int cchannel = -1;
char *p;
snd_config_t *n = snd_config_entry(i);
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
errno = 0;
cchannel = strtol(n->id, &p, 10);
cchannel = strtol(id, &p, 10);
if (errno || *p || cchannel < 0) {
ERR("Invalid client channel in binding: %s", n->id);
ERR("Invalid client channel in binding: %s", id);
return -EINVAL;
}
if ((unsigned)cchannel >= channels_count)
@ -1460,11 +1462,12 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
channels_map[idx] = -1;
snd_config_foreach(i, binding) {
snd_config_t *n = snd_config_entry(i);
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
long cchannel;
long schannel = -1;
cchannel = strtol(n->id, 0, 10);
err = snd_config_integer_get(n, &schannel);
cchannel = strtol(id, 0, 10);
err = snd_config_get_integer(n, &schannel);
if (err < 0)
goto _free;
assert(schannels_count <= 0 || schannel < schannels_count);

View file

@ -730,30 +730,31 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
int local;
struct hostent *h;
snd_config_foreach(i, conf) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "type") == 0)
if (strcmp(id, "type") == 0)
continue;
if (strcmp(n->id, "stream") == 0)
if (strcmp(id, "stream") == 0)
continue;
if (strcmp(n->id, "server") == 0) {
err = snd_config_string_get(n, &server);
if (strcmp(id, "server") == 0) {
err = snd_config_get_string(n, &server);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (strcmp(id, "sname") == 0) {
err = snd_config_get_string(n, &sname);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}
if (!sname) {
@ -770,34 +771,35 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
return -EINVAL;
}
snd_config_foreach(i, sconfig) {
snd_config_t *n = snd_config_entry(i);
if (strcmp(n->id, "comment") == 0)
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
continue;
if (strcmp(n->id, "host") == 0) {
err = snd_config_string_get(n, &host);
if (strcmp(id, "host") == 0) {
err = snd_config_get_string(n, &host);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "socket") == 0) {
err = snd_config_string_get(n, &socket);
if (strcmp(id, "socket") == 0) {
err = snd_config_get_string(n, &socket);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "port") == 0) {
err = snd_config_integer_get(n, &port);
if (strcmp(id, "port") == 0) {
err = snd_config_get_integer(n, &port);
if (err < 0) {
ERR("Invalid type for %s", n->id);
ERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
ERR("Unknown field %s", n->id);
ERR("Unknown field %s", id);
return -EINVAL;
}