alsactl prints error messages from alsa-lib as is, and it's rather annoying to see the error messages like alsactl[xxx]: alsa-lib parser.c:242:(error_node) UCM is not supported for this HDA model (HDA Intel PCH...) alsactl[xxx]: alsa-lib main.c:1405:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -6 that are recorded in the syslog at each boot. This patch adds --quiet (or -q) option to suppress those error messages from alsa-lib, and applies to the systemd services as default. Signed-off-by: Takashi Iwai <tiwai@xxxxxxx> --- alsactl/alsa-restore.service.in | 4 ++-- alsactl/alsa-state.service.in | 4 ++-- alsactl/alsactl.1 | 4 ++++ alsactl/alsactl.c | 5 +++++ alsactl/alsactl.h | 2 ++ alsactl/utils.c | 2 ++ 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/alsactl/alsa-restore.service.in b/alsactl/alsa-restore.service.in index 80fd5fd48203..06bc21c355de 100644 --- a/alsactl/alsa-restore.service.in +++ b/alsactl/alsa-restore.service.in @@ -11,5 +11,5 @@ ConditionPathExistsGlob=/dev/snd/control* [Service] Type=oneshot RemainAfterExit=true -ExecStart=-@sbindir@/alsactl restore -ExecStop=-@sbindir@/alsactl store +ExecStart=-@sbindir@/alsactl -q restore +ExecStop=-@sbindir@/alsactl -q store diff --git a/alsactl/alsa-state.service.in b/alsactl/alsa-state.service.in index 5a8fe5eeed7e..6b6e704ad8e5 100644 --- a/alsactl/alsa-state.service.in +++ b/alsactl/alsa-state.service.in @@ -9,5 +9,5 @@ ConditionPathExists=@daemonswitch@ [Service] Type=simple -ExecStart=-@sbindir@/alsactl -s -n 19 -c rdaemon -ExecStop=-@sbindir@/alsactl -s kill save_and_quit +ExecStart=-@sbindir@/alsactl -q -s -n 19 -c rdaemon +ExecStop=-@sbindir@/alsactl -q -s kill save_and_quit diff --git a/alsactl/alsactl.1 b/alsactl/alsactl.1 index 8296663a7c2d..0a0b4597a137 100644 --- a/alsactl/alsactl.1 +++ b/alsactl/alsactl.1 @@ -94,6 +94,10 @@ Use debug mode: a bit more verbose. \fI\-v, \-\-version\fP Print alsactl version number. +.TP +\fI\-q, \-\-quiet\fP +Suppress error messages from alsa-lib. + .TP \fI\-f, \-\-file\fP Select the configuration file to use. The default is /var/lib/alsa/asound.state. diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c index 05738fb6b35f..e3bef2c69558 100644 --- a/alsactl/alsactl.c +++ b/alsactl/alsactl.c @@ -52,6 +52,7 @@ int use_syslog = 0; char *command; char *statefile = NULL; char *lockfile = SYS_LOCKFILE; +int verbose_error = 1; #define TITLE 0x0100 #define HEADER 0x0200 @@ -74,6 +75,7 @@ static struct arg args[] = { { 'h', "help", "this help" }, { 'd', "debug", "debug mode" }, { 'v', "version", "print version of this program" }, +{ 'q', "quiet", "suppress errors from alsa-lib" }, { HEADER, NULL, "Available state options:" }, { FILEARG | 'f', "file", "configuration file (default " SYS_ASOUNDRC ")" }, { FILEARG | 'a', "config-dir", "boot / hotplug configuration directory (default " SYS_ASOUND_DIR ")" }, @@ -370,6 +372,9 @@ int main(int argc, char *argv[]) printf("alsactl version " SND_UTIL_VERSION_STR "\n"); res = EXIT_SUCCESS; goto out; + case 'q': + verbose_error = 0; + break; case '?': // error msg already printed help(); res = EXIT_FAILURE; diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h index bbdf6c88baeb..f9c25931c924 100644 --- a/alsactl/alsactl.h +++ b/alsactl/alsactl.h @@ -83,3 +83,5 @@ static inline int hextodigit(int c) } #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a)[0]) + +extern int verbose_error; diff --git a/alsactl/utils.c b/alsactl/utils.c index a50797259f21..dfb06e1a4a15 100644 --- a/alsactl/utils.c +++ b/alsactl/utils.c @@ -182,6 +182,8 @@ void error_handler(const char *file, int line, const char *function, int err, co char buf[2048]; va_list arg; + if (!verbose_error) + return; va_start(arg, fmt); vsnprintf(buf, sizeof(buf), fmt, arg); va_end(arg); -- 2.31.1