mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:05:41 +01:00
Add -I option to alsactl
Add -I option to alsactl to take back the old restore behavior without initialization. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
bbd71560bc
commit
1797b2c290
4 changed files with 26 additions and 6 deletions
|
@ -60,6 +60,15 @@ and do not set an error exit code when soundcards are not installed.
|
|||
Used with restore command. Don't restore mismatching control elements.
|
||||
This option was the old default behavior.
|
||||
|
||||
.TP
|
||||
\fI\-I, \-\-no\-init\-fallback\fP
|
||||
Don't initialize cards if restore fails. Since version 1.0.18,
|
||||
\fBalsactl\fP tries to initialize the card with the restore operation
|
||||
as default. But this can cause incompatibility with the older version.
|
||||
The caller may expect that the state won't be touched if no state file
|
||||
exists. This option takes the restore behavior back to the older
|
||||
version by suppressing the initialization.
|
||||
|
||||
.TP
|
||||
\fI\-r, \-\-runstate\fP
|
||||
Save restore and init state to this file. The file will contain only errors.
|
||||
|
|
|
@ -51,6 +51,8 @@ static void help(void)
|
|||
printf(" (default mode)\n");
|
||||
printf(" -g,--ignore ignore 'No soundcards found' error\n");
|
||||
printf(" -P,--pedantic do not restore mismatching controls (old default)\n");
|
||||
printf(" -I,--no-init-fallback\n"
|
||||
" don't initialize even if restore fails\n");
|
||||
printf(" -r,--runstate # save restore and init state to this file (only errors)\n");
|
||||
printf(" default settings is 'no file set'\n");
|
||||
printf(" -R,--remove remove runstate file at first, otherwise append errors\n");
|
||||
|
@ -76,6 +78,7 @@ int main(int argc, char *argv[])
|
|||
{"file", 1, NULL, 'f'},
|
||||
{"env", 1, NULL, 'E'},
|
||||
{"initfile", 1, NULL, 'i'},
|
||||
{"no-init-fallback", 0, NULL, 'I'},
|
||||
{"force", 0, NULL, 'F'},
|
||||
{"ignore", 0, NULL, 'g'},
|
||||
{"pedantic", 0, NULL, 'P'},
|
||||
|
@ -96,6 +99,7 @@ int main(int argc, char *argv[])
|
|||
char *initfile = DATADIR "/init/00main";
|
||||
char *cardname, **tmp, ncardname[16];
|
||||
int removestate = 0;
|
||||
int init_fallback = 1; /* new default behavior */
|
||||
int res;
|
||||
|
||||
command = argv[0];
|
||||
|
@ -126,6 +130,9 @@ int main(int argc, char *argv[])
|
|||
case 'i':
|
||||
initfile = optarg;
|
||||
break;
|
||||
case 'I':
|
||||
init_fallback = 0;
|
||||
break;
|
||||
case 'r':
|
||||
statefile = optarg;
|
||||
break;
|
||||
|
@ -173,7 +180,7 @@ int main(int argc, char *argv[])
|
|||
} else if (!strcmp(argv[optind], "restore")) {
|
||||
if (removestate)
|
||||
remove(statefile);
|
||||
res = load_state(cfgfile, initfile, cardname);
|
||||
res = load_state(cfgfile, initfile, cardname, init_fallback);
|
||||
} else {
|
||||
fprintf(stderr, "alsactl: Unknown command '%s'...\n",
|
||||
argv[optind]);
|
||||
|
|
|
@ -68,7 +68,8 @@ extern char *statefile;
|
|||
|
||||
int init(const char *file, const char *cardname);
|
||||
int save_state(const char *file, const char *cardname);
|
||||
int load_state(const char *file, const char *initfile, const char *cardname);
|
||||
int load_state(const char *file, const char *initfile, const char *cardname,
|
||||
int do_init);
|
||||
int power(const char *argv[], int argc);
|
||||
int generate_names(const char *cfgfile);
|
||||
|
||||
|
|
|
@ -1548,7 +1548,8 @@ int save_state(const char *file, const char *cardname)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int load_state(const char *file, const char *initfile, const char *cardname)
|
||||
int load_state(const char *file, const char *initfile, const char *cardname,
|
||||
int do_init)
|
||||
{
|
||||
int err, finalerr = 0;
|
||||
snd_config_t *config;
|
||||
|
@ -1586,6 +1587,8 @@ int load_state(const char *file, const char *initfile, const char *cardname)
|
|||
if (card < 0)
|
||||
break;
|
||||
first = 0;
|
||||
if (!do_init)
|
||||
break;
|
||||
sprintf(cardname1, "%i", card);
|
||||
err = init(initfile, cardname1);
|
||||
if (err < 0) {
|
||||
|
@ -1594,7 +1597,7 @@ int load_state(const char *file, const char *initfile, const char *cardname)
|
|||
}
|
||||
initfailed(card, "restore");
|
||||
}
|
||||
if (!first)
|
||||
if (first)
|
||||
finalerr = 0; /* no cards, no error code */
|
||||
return finalerr;
|
||||
}
|
||||
|
@ -1621,7 +1624,7 @@ int load_state(const char *file, const char *initfile, const char *cardname)
|
|||
}
|
||||
first = 0;
|
||||
/* do a check if controls matches state file */
|
||||
if (set_controls(card, config, 0)) {
|
||||
if (do_init && set_controls(card, config, 0)) {
|
||||
sprintf(cardname1, "%i", card);
|
||||
err = init(initfile, cardname1);
|
||||
if (err < 0) {
|
||||
|
@ -1644,7 +1647,7 @@ int load_state(const char *file, const char *initfile, const char *cardname)
|
|||
return -ENODEV;
|
||||
}
|
||||
/* do a check if controls matches state file */
|
||||
if (set_controls(cardno, config, 0)) {
|
||||
if (do_init && set_controls(cardno, config, 0)) {
|
||||
err = init(initfile, cardname);
|
||||
if (err < 0) {
|
||||
initfailed(cardno, "init");
|
||||
|
|
Loading…
Reference in a new issue