]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsactl: Add -g,--ignore option to ignore 'No soundcards found' error
authorJaroslav Kysela <perex@perex.cz>
Thu, 18 Sep 2008 07:40:02 +0000 (09:40 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 18 Sep 2008 07:40:02 +0000 (09:40 +0200)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
alsactl/alsactl.1
alsactl/alsactl.c
alsactl/alsactl.h
alsactl/state.c

index d7f30f621bad76fc64a75ddb06a77e4d8de9190d..b038a82248e694ed7f0a6d5ce490ce103c9e41c2 100644 (file)
@@ -50,6 +50,11 @@ Select the configuration file to use. The default is /etc/asound.state.
 Used with restore command.  Try to restore the matching control elements
 as much as possible.  This option is set as default now.
 
+.TP
+\fI\-g, \-\-ignore\fP
+Used with store and restore commands. Do not show 'No soundcards found'
+and do not set an error exit code when soundcards are not installed.
+
 .TP
 \fI\-P, \-\-pedantic\fP
 Used with restore command.  Don't restore mismatching control elements.
index 57957bf476faa9e6f3e1a188ea72f5655e30d4d4..f8463169c6ae29d4f308842b793bd26bcdaec2c5 100644 (file)
@@ -34,6 +34,7 @@
 
 int debugflag = 0;
 int force_restore = 1;
+int ignore_nocards = 0;
 char *command;
 char *statefile = NULL;
 
@@ -48,7 +49,8 @@ static void help(void)
        printf("  -f,--file #      configuration file (default " SYS_ASOUNDRC ")\n");
        printf("  -F,--force       try to restore the matching controls as much as possible\n");
        printf("                   (default mode)\n");
-       printf("  -P,--pedantic    don't restore mismatching controls (old default)\n");
+       printf("  -g,--ignore      ignore 'No soundcards found' error\n");
+       printf("  -P,--pedantic    do not restore mismatching controls (old default)\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");
@@ -75,6 +77,7 @@ int main(int argc, char *argv[])
                {"env", 1, NULL, 'E'},
                {"initfile", 1, NULL, 'i'},
                {"force", 0, NULL, 'F'},
+               {"ignore", 0, NULL, 'g'},
                {"pedantic", 0, NULL, 'P'},
                {"runstate", 0, NULL, 'r'},
                {"remove", 0, NULL, 'R'},
@@ -99,7 +102,7 @@ int main(int argc, char *argv[])
        while (1) {
                int c;
 
-               if ((c = getopt_long(argc, argv, "hdvf:FE:i:Pr:R", long_option, NULL)) < 0)
+               if ((c = getopt_long(argc, argv, "hdvf:FgE:i:Pr:R", long_option, NULL)) < 0)
                        break;
                switch (c) {
                case 'h':
@@ -111,6 +114,9 @@ int main(int argc, char *argv[])
                case 'F':
                        force_restore = 1;
                        break;
+               case 'g':
+                       ignore_nocards = 1;
+                       break;
                case 'E':
                        if (putenv(optarg)) {
                                fprintf(stderr, "environment string '%s' is wrong\n", optarg);
index 408b145b5f4eb0eae3987d5bdc1c26ccee90ef4a..44d27f12c81c371f24dbe3120a54723ffab604fa 100644 (file)
@@ -1,5 +1,6 @@
 extern int debugflag;
 extern int force_restore;
+extern int ignore_nocards;
 extern char *command;
 extern char *statefile;
 
index 554020bd3e14b04d8d7818aadf06575198a3699d..576721ad5dbad4ff6f04c743f9d895469aaadca1 100644 (file)
@@ -1507,8 +1507,12 @@ int save_state(const char *file, const char *cardname)
                                break;
                        if (card < 0) {
                                if (first) {
-                                       error("No soundcards found...");
-                                       return -ENODEV;
+                                       if (ignore_nocards) {
+                                               return 0;
+                                       } else {
+                                               error("No soundcards found...");
+                                               return -ENODEV;
+                                       }
                                }
                                break;
                        }
@@ -1606,8 +1610,12 @@ int load_state(const char *file, const char *initfile, const char *cardname)
                                break;
                        if (card < 0) {
                                if (first) {
-                                       error("No soundcards found...");
-                                       return -ENODEV;
+                                       if (ignore_nocards) {
+                                               return 0;
+                                       } else {
+                                               error("No soundcards found...");
+                                               return -ENODEV;
+                                       }
                                }
                                break;
                        }