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.
Errors are appended with the soundcard id to the end of file.
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");
{"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'},
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];
case 'i':
initfile = optarg;
break;
+ case 'I':
+ init_fallback = 0;
+ break;
case 'r':
statefile = optarg;
break;
} 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]);
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);
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;
if (card < 0)
break;
first = 0;
+ if (!do_init)
+ break;
sprintf(cardname1, "%i", card);
err = init(initfile, cardname1);
if (err < 0) {
}
initfailed(card, "restore");
}
- if (!first)
+ if (first)
finalerr = 0; /* no cards, no error code */
return finalerr;
}
}
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) {
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");