#define SYS_ASOUNDRC "/etc/asound.state"
int debugflag = 0;
+int force_restore = 0;
char *command;
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
printf("\nAvailable options:\n");
printf(" -h,--help this help\n");
printf(" -f,--file # configuration file (default " SYS_ASOUNDRC ")\n");
+ printf(" -F,--force try to restore the matching controls as much as possible\n");
printf(" -d,--debug debug mode\n");
printf(" -v,--version print version of this program\n");
printf("\nAvailable commands:\n");
if (index < 0)
index = 0;
- snd_ctl_elem_info_set_numid(info, numid);
- err = snd_ctl_elem_info(handle, info);
+ err = -EINVAL;
+ if (! force_restore) {
+ snd_ctl_elem_info_set_numid(info, numid);
+ err = snd_ctl_elem_info(handle, info);
+ }
if (err < 0) {
if (iface >= 0 && name) {
snd_ctl_elem_info_set_numid(info, 0);
if (!snd_ctl_elem_info_is_writable(info))
return 0;
- snd_ctl_elem_value_set_numid(ctl, numid);
+ snd_ctl_elem_value_set_numid(ctl, numid1);
if (count == 1) {
switch (type) {
snd_config_for_each(i, next, control) {
snd_config_t *n = snd_config_iterator_entry(i);
err = set_control(handle, n);
- if (err < 0)
+ if (err < 0 && ! force_restore)
goto _close;
}
break;
}
first = 0;
- if ((err = set_controls(card, config)))
+ if ((err = set_controls(card, config)) && ! force_restore)
return err;
}
} else {
error("Cannot find soundcard '%s'...", cardname);
return EXIT_FAILURE;
}
- if ((err = set_controls(cardno, config))) {
+ if ((err = set_controls(cardno, config)) && ! force_restore) {
return err;
}
}
{
{"help", 0, NULL, 'h'},
{"file", 1, NULL, 'f'},
+ {"force", 1, NULL, 'F'},
{"debug", 0, NULL, 'd'},
{"version", 0, NULL, 'v'},
{NULL, 0, NULL, 0},
case 'f':
cfgfile = optarg;
break;
+ case 'F':
+ force_restore = 1;
+ break;
case 'd':
debugflag = 1;
break;