alsactl: Add --quiet option to suppress alsa-lib error messages
PATCH 1/1 alsactl: Add --quiet option to suppress alsa-lib error messages
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.
--- 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(-)
alsactl/alsa-restore.service.in +2 -2
@@ -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
alsactl/alsa-state.service.in +2 -2
@@ -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
alsactl/alsactl.1 +4 -0
@@ -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.
alsactl/alsactl.c +5 -0
@@ -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 ;
alsactl/alsactl.h +2 -0
@@ -83,3 +83,5 @@ static inline int hextodigit(int c) }#define ARRAY_SIZE (a) (sizeof (a) / sizeof (a)[0]) + +extern int verbose_error;
alsactl/utils.c +2 -0
@@ -182,6 +182,8 @@ void error_handler(const char *file, int line, const char *function, int err, cochar buf[2048 ];va_list arg; +if (!verbose_error) +return ;va_start (arg, fmt);vsnprintf (buf,sizeof (buf), fmt, arg);va_end (arg);
Signature · 1 line
2.31.1
Quoted 11 lines · Takashi Iwai
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.
The fix is inaccurate as it's just a warning not an error. The question is, how to signal those warnings to users to eliminate the confusion.
The suppression of all alsa-lib errors does not seem like a good idea to me.
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Quoted 8 lines · Jaroslav Kysela
Quoted 6 lines · Takashi Iwai
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
Quoted 7 lines
Quoted 5 lines
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.
The fix is inaccurate as it's just a warning not an error.
But it says "error" :)
Quoted 5 lines
The
question is, how to signal those warnings to users to eliminate the confusion.The suppression of all alsa-lib errors does not seem like a good idea to me.
At least the messages that are no real errors should not be shown in that way. It's nothing but confusing.
thanks,
Takashi
Quoted 20 lines · Takashi Iwai
Quoted 8 lines · Jaroslav Kysela
Quoted 6 lines · Takashi Iwai
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
Quoted 7 lines
Quoted 5 lines
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.
The fix is inaccurate as it's just a warning not an error.
But it says "error" :)
Quoted 8 lines
Quoted 5 lines
The
question is, how to signal those warnings to users to eliminate the confusion.The suppression of all alsa-lib errors does not seem like a good idea to me.
At least the messages that are no real errors should not be shown in that way. It's nothing but confusing.
From the UCM perspective, it's an error, because the configuration is missing. UCM does not know anything about the legacy fallback. But yes, we should not confuse users. I tried to fix this in another way. It should hide only those specific messages.
https://github.com/alsa-project/alsa-utils/commit/af62c72e2d6db960405eb1bd8d50206d1600c392
https://github.com/alsa-project/alsa-lib/commit/23198a72cd4f8f8759e650362b4adb485fc9fb12
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.