mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-23 12:36:31 +01:00
added -F option to restore the matching control elements as much as
possible.
This commit is contained in:
parent
a00e467d67
commit
28d0fdaa6a
2 changed files with 21 additions and 7 deletions
|
@ -33,9 +33,14 @@ loaded.
|
||||||
Help: show available flags and commands.
|
Help: show available flags and commands.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fI-f, --f\fP file
|
\fI-f, --file\fP
|
||||||
Select the configuration file to use. The default is /etc/asound.state
|
Select the configuration file to use. The default is /etc/asound.state
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fI-F, --force\fP
|
||||||
|
Used with restore command. Try to restore the matching control elements
|
||||||
|
as much as possible.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fI-d, --debug\fP
|
\fI-d, --debug\fP
|
||||||
Use debug mode: a bit more verbose.
|
Use debug mode: a bit more verbose.
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#define SYS_ASOUNDRC "/etc/asound.state"
|
#define SYS_ASOUNDRC "/etc/asound.state"
|
||||||
|
|
||||||
int debugflag = 0;
|
int debugflag = 0;
|
||||||
|
int force_restore = 0;
|
||||||
char *command;
|
char *command;
|
||||||
|
|
||||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
||||||
|
@ -54,6 +55,7 @@ static void help(void)
|
||||||
printf("\nAvailable options:\n");
|
printf("\nAvailable options:\n");
|
||||||
printf(" -h,--help this help\n");
|
printf(" -h,--help this help\n");
|
||||||
printf(" -f,--file # configuration file (default " SYS_ASOUNDRC ")\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(" -d,--debug debug mode\n");
|
||||||
printf(" -v,--version print version of this program\n");
|
printf(" -v,--version print version of this program\n");
|
||||||
printf("\nAvailable commands:\n");
|
printf("\nAvailable commands:\n");
|
||||||
|
@ -756,8 +758,11 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
|
err = -EINVAL;
|
||||||
|
if (! force_restore) {
|
||||||
snd_ctl_elem_info_set_numid(info, numid);
|
snd_ctl_elem_info_set_numid(info, numid);
|
||||||
err = snd_ctl_elem_info(handle, info);
|
err = snd_ctl_elem_info(handle, info);
|
||||||
|
}
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
if (iface >= 0 && name) {
|
if (iface >= 0 && name) {
|
||||||
snd_ctl_elem_info_set_numid(info, 0);
|
snd_ctl_elem_info_set_numid(info, 0);
|
||||||
|
@ -797,7 +802,7 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
||||||
|
|
||||||
if (!snd_ctl_elem_info_is_writable(info))
|
if (!snd_ctl_elem_info_is_writable(info))
|
||||||
return 0;
|
return 0;
|
||||||
snd_ctl_elem_value_set_numid(ctl, numid);
|
snd_ctl_elem_value_set_numid(ctl, numid1);
|
||||||
|
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -994,7 +999,7 @@ static int set_controls(int card, snd_config_t *top)
|
||||||
snd_config_for_each(i, next, control) {
|
snd_config_for_each(i, next, control) {
|
||||||
snd_config_t *n = snd_config_iterator_entry(i);
|
snd_config_t *n = snd_config_iterator_entry(i);
|
||||||
err = set_control(handle, n);
|
err = set_control(handle, n);
|
||||||
if (err < 0)
|
if (err < 0 && ! force_restore)
|
||||||
goto _close;
|
goto _close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,7 +1124,7 @@ static int load_state(char *file, const char *cardname)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
first = 0;
|
first = 0;
|
||||||
if ((err = set_controls(card, config)))
|
if ((err = set_controls(card, config)) && ! force_restore)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1130,7 +1135,7 @@ static int load_state(char *file, const char *cardname)
|
||||||
error("Cannot find soundcard '%s'...", cardname);
|
error("Cannot find soundcard '%s'...", cardname);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if ((err = set_controls(cardno, config))) {
|
if ((err = set_controls(cardno, config)) && ! force_restore) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1311,6 +1316,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
{"help", 0, NULL, 'h'},
|
{"help", 0, NULL, 'h'},
|
||||||
{"file", 1, NULL, 'f'},
|
{"file", 1, NULL, 'f'},
|
||||||
|
{"force", 1, NULL, 'F'},
|
||||||
{"debug", 0, NULL, 'd'},
|
{"debug", 0, NULL, 'd'},
|
||||||
{"version", 0, NULL, 'v'},
|
{"version", 0, NULL, 'v'},
|
||||||
{NULL, 0, NULL, 0},
|
{NULL, 0, NULL, 0},
|
||||||
|
@ -1331,6 +1337,9 @@ int main(int argc, char *argv[])
|
||||||
case 'f':
|
case 'f':
|
||||||
cfgfile = optarg;
|
cfgfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
force_restore = 1;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
debugflag = 1;
|
debugflag = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue