"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "alsactl/state.c" between
alsa-utils-1.2.5.tar.bz2 and alsa-utils-1.2.5.1.tar.bz2

About: ALSA (Advanced Linux Sound Architecture) - Utilities.

state.c  (alsa-utils-1.2.5.tar.bz2):state.c  (alsa-utils-1.2.5.1.tar.bz2)
skipping to change at line 231 skipping to change at line 231
} }
} }
} }
return 0; return 0;
} }
static int get_control(snd_ctl_t *handle, snd_ctl_elem_id_t *id, snd_config_t *t op) static int get_control(snd_ctl_t *handle, snd_ctl_elem_id_t *id, snd_config_t *t op)
{ {
snd_ctl_elem_value_t *ctl; snd_ctl_elem_value_t *ctl;
snd_ctl_elem_info_t *info; snd_ctl_elem_info_t *info;
snd_config_t *control, *comment, *item, *value; snd_config_t *control, *comment, *item = NULL, *value;
const char *s; const char *s;
char buf[256]; char buf[256];
unsigned int idx; unsigned int idx;
int err; int err;
unsigned int device, subdevice, index; unsigned int device, subdevice, index;
const char *name; const char *name;
snd_ctl_elem_type_t type; snd_ctl_elem_type_t type;
unsigned int count; unsigned int count;
snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_value_alloca(&ctl);
snd_ctl_elem_info_alloca(&info); snd_ctl_elem_info_alloca(&info);
skipping to change at line 657 skipping to change at line 657
} }
static long config_iface(snd_config_t *n) static long config_iface(snd_config_t *n)
{ {
long i; long i;
long long li; long long li;
snd_ctl_elem_iface_t idx; snd_ctl_elem_iface_t idx;
const char *str; const char *str;
switch (snd_config_get_type(n)) { switch (snd_config_get_type(n)) {
case SND_CONFIG_TYPE_INTEGER: case SND_CONFIG_TYPE_INTEGER:
snd_config_get_integer(n, &i); if (snd_config_get_integer(n, &i) < 0)
return -1;
return i; return i;
case SND_CONFIG_TYPE_INTEGER64: case SND_CONFIG_TYPE_INTEGER64:
snd_config_get_integer64(n, &li); if (snd_config_get_integer64(n, &li) < 0)
return -1;
return li; return li;
case SND_CONFIG_TYPE_STRING: case SND_CONFIG_TYPE_STRING:
snd_config_get_string(n, &str); if (snd_config_get_string(n, &str) < 0)
return -1;
break; break;
default: default:
return -1; return -1;
} }
for (idx = 0; idx <= SND_CTL_ELEM_IFACE_LAST; idx++) { for (idx = 0; idx <= SND_CTL_ELEM_IFACE_LAST; idx++) {
if (strcasecmp(snd_ctl_elem_iface_name(idx), str) == 0) if (strcasecmp(snd_ctl_elem_iface_name(idx), str) == 0)
return idx; return idx;
} }
return -1; return -1;
} }
static int config_bool(snd_config_t *n, int doit) static int config_bool(snd_config_t *n, int doit)
{ {
const char *str; const char *str;
long val; long val;
long long lval; long long lval;
switch (snd_config_get_type(n)) { switch (snd_config_get_type(n)) {
case SND_CONFIG_TYPE_INTEGER: case SND_CONFIG_TYPE_INTEGER:
snd_config_get_integer(n, &val); if (snd_config_get_integer(n, &val) < 0)
return -1;
if (val < 0 || val > 1) if (val < 0 || val > 1)
return -1; return -1;
return val; return val;
case SND_CONFIG_TYPE_INTEGER64: case SND_CONFIG_TYPE_INTEGER64:
snd_config_get_integer64(n, &lval); if (snd_config_get_integer64(n, &lval) < 0)
return -1;
if (lval < 0 || lval > 1) if (lval < 0 || lval > 1)
return -1; return -1;
return (int) lval; return (int) lval;
case SND_CONFIG_TYPE_STRING: case SND_CONFIG_TYPE_STRING:
snd_config_get_string(n, &str); if (snd_config_get_string(n, &str) < 0)
return -1;
break; break;
case SND_CONFIG_TYPE_COMPOUND: case SND_CONFIG_TYPE_COMPOUND:
if (!force_restore || !doit) if (!force_restore || !doit)
return -1; return -1;
n = snd_config_iterator_entry(snd_config_iterator_first(n)); n = snd_config_iterator_entry(snd_config_iterator_first(n));
return config_bool(n, doit); return config_bool(n, doit);
default: default:
return -1; return -1;
} }
if (strcmp(str, "on") == 0 || strcmp(str, "true") == 0) if (strcmp(str, "on") == 0 || strcmp(str, "true") == 0)
skipping to change at line 720 skipping to change at line 726
static int config_enumerated(snd_config_t *n, snd_ctl_t *handle, static int config_enumerated(snd_config_t *n, snd_ctl_t *handle,
snd_ctl_elem_info_t *info, int doit) snd_ctl_elem_info_t *info, int doit)
{ {
const char *str; const char *str;
long val; long val;
long long lval; long long lval;
unsigned int idx, items; unsigned int idx, items;
switch (snd_config_get_type(n)) { switch (snd_config_get_type(n)) {
case SND_CONFIG_TYPE_INTEGER: case SND_CONFIG_TYPE_INTEGER:
snd_config_get_integer(n, &val); if (snd_config_get_integer(n, &val) < 0)
return -1;
return val; return val;
case SND_CONFIG_TYPE_INTEGER64: case SND_CONFIG_TYPE_INTEGER64:
snd_config_get_integer64(n, &lval); if (snd_config_get_integer64(n, &lval) < 0)
return -1;
return (int) lval; return (int) lval;
case SND_CONFIG_TYPE_STRING: case SND_CONFIG_TYPE_STRING:
snd_config_get_string(n, &str); if (snd_config_get_string(n, &str) < 0)
return -1;
break; break;
case SND_CONFIG_TYPE_COMPOUND: case SND_CONFIG_TYPE_COMPOUND:
if (!force_restore || !doit) if (!force_restore || !doit)
return -1; return -1;
n = snd_config_iterator_entry(snd_config_iterator_first(n)); n = snd_config_iterator_entry(snd_config_iterator_first(n));
return config_enumerated(n, handle, info, doit); return config_enumerated(n, handle, info, doit);
default: default:
return -1; return -1;
} }
items = snd_ctl_elem_info_get_items(info); items = snd_ctl_elem_info_get_items(info);
skipping to change at line 1249 skipping to change at line 1258
if (strcmp(fld, "comment") == 0) { if (strcmp(fld, "comment") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
cerror(doit, "control.%d.%s is invalid", numid, f ld); cerror(doit, "control.%d.%s is invalid", numid, f ld);
return -EINVAL; return -EINVAL;
} }
comment = n; comment = n;
continue; continue;
} }
if (strcmp(fld, "iface") == 0) { if (strcmp(fld, "iface") == 0) {
iface = (snd_ctl_elem_iface_t)config_iface(n); iface = (snd_ctl_elem_iface_t)config_iface(n);
if (iface < 0)
return -EINVAL;
continue; continue;
} }
if (strcmp(fld, "device") == 0) { if (strcmp(fld, "device") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) {
cerror(doit, "control.%d.%s is invalid", numid, f ld); cerror(doit, "control.%d.%s is invalid", numid, f ld);
return -EINVAL; return -EINVAL;
} }
snd_config_get_integer(n, &device); if (snd_config_get_integer(n, &device) < 0)
return -EINVAL;
continue; continue;
} }
if (strcmp(fld, "subdevice") == 0) { if (strcmp(fld, "subdevice") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) {
cerror(doit, "control.%d.%s is invalid", numid, f ld); cerror(doit, "control.%d.%s is invalid", numid, f ld);
return -EINVAL; return -EINVAL;
} }
snd_config_get_integer(n, &subdevice); if (snd_config_get_integer(n, &subdevice) < 0)
return -EINVAL;
continue; continue;
} }
if (strcmp(fld, "name") == 0) { if (strcmp(fld, "name") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) {
cerror(doit, "control.%d.%s is invalid", numid, f ld); cerror(doit, "control.%d.%s is invalid", numid, f ld);
return -EINVAL; return -EINVAL;
} }
snd_config_get_string(n, &name); if (snd_config_get_string(n, &name) < 0)
return -EINVAL;
continue; continue;
} }
if (strcmp(fld, "index") == 0) { if (strcmp(fld, "index") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) {
cerror(doit, "control.%d.%s is invalid", numid, f ld); cerror(doit, "control.%d.%s is invalid", numid, f ld);
return -EINVAL; return -EINVAL;
} }
snd_config_get_integer(n, &index); if (snd_config_get_integer(n, &index) < 0)
return -EINVAL;
continue; continue;
} }
if (strcmp(fld, "value") == 0) { if (strcmp(fld, "value") == 0) {
value = n; value = n;
continue; continue;
} }
cerror(doit, "unknown control.%d.%s field", numid, fld); cerror(doit, "unknown control.%d.%s field", numid, fld);
} }
if (!value) { if (!value) {
cerror(doit, "missing control.%d.value", numid); cerror(doit, "missing control.%d.value", numid);
skipping to change at line 1629 skipping to change at line 1644
int load_state(const char *cfgdir, const char *file, int load_state(const char *cfgdir, const char *file,
const char *initfile, int initflags, const char *initfile, int initflags,
const char *cardname, int do_init) const char *cardname, int do_init)
{ {
int err, finalerr = 0, open_failed; int err, finalerr = 0, open_failed;
struct snd_card_iterator iter; struct snd_card_iterator iter;
snd_config_t *config; snd_config_t *config;
const char *cardname1; const char *cardname1;
config = NULL;
err = load_configuration(file, &config, &open_failed); err = load_configuration(file, &config, &open_failed);
if (err < 0 && !open_failed) if (err < 0 && !open_failed)
return err; return err;
if (open_failed) { if (open_failed) {
error("Cannot open %s for reading: %s", file, snd_strerror(err)); error("Cannot open %s for reading: %s", file, snd_strerror(err));
finalerr = err; finalerr = err;
err = snd_card_iterator_sinit(&iter, cardname); err = snd_card_iterator_sinit(&iter, cardname);
if (err < 0) if (err < 0)
skipping to change at line 1678 skipping to change at line 1694
} }
} }
if ((err = set_controls(iter.card, config, 1))) { if ((err = set_controls(iter.card, config, 1))) {
if (!force_restore) if (!force_restore)
finalerr = err; finalerr = err;
initfailed(iter.card, "restore", err); initfailed(iter.card, "restore", err);
} }
} }
err = finalerr ? finalerr : snd_card_iterator_error(&iter); err = finalerr ? finalerr : snd_card_iterator_error(&iter);
out: out:
snd_config_delete(config); if (config)
snd_config_delete(config);
snd_config_update_free_global(); snd_config_update_free_global();
return err; return err;
} }
 End of changes. 17 change blocks. 
15 lines changed or deleted 32 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)