All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH alsa-utils] alsactl: Add --quiet option to suppress alsa-lib error messages
@ 2021-10-27 14:40 Takashi Iwai
  2021-10-27 17:25 ` Jaroslav Kysela
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2021-10-27 14:40 UTC (permalink / raw)
  To: alsa-devel

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@suse.de>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH alsa-utils] alsactl: Add --quiet option to suppress alsa-lib error messages
  2021-10-27 14:40 [PATCH alsa-utils] alsactl: Add --quiet option to suppress alsa-lib error messages Takashi Iwai
@ 2021-10-27 17:25 ` Jaroslav Kysela
  2021-10-28  6:18   ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Jaroslav Kysela @ 2021-10-27 17:25 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: ALSA development

On 27. 10. 21 16:40, Takashi Iwai wrote:
> 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

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH alsa-utils] alsactl: Add --quiet option to suppress alsa-lib error messages
  2021-10-27 17:25 ` Jaroslav Kysela
@ 2021-10-28  6:18   ` Takashi Iwai
  2021-10-28 10:25     ` Jaroslav Kysela
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2021-10-28  6:18 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: ALSA development

On Wed, 27 Oct 2021 19:25:29 +0200,
Jaroslav Kysela wrote:
> 
> On 27. 10. 21 16:40, Takashi Iwai wrote:
> > 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.

But it says "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.

At least the messages that are no real errors should not be shown in
that way.  It's nothing but confusing.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH alsa-utils] alsactl: Add --quiet option to suppress alsa-lib error messages
  2021-10-28  6:18   ` Takashi Iwai
@ 2021-10-28 10:25     ` Jaroslav Kysela
  0 siblings, 0 replies; 4+ messages in thread
From: Jaroslav Kysela @ 2021-10-28 10:25 UTC (permalink / raw)
  To: ALSA development; +Cc: Takashi Iwai

On 28. 10. 21 8:18, Takashi Iwai wrote:
> On Wed, 27 Oct 2021 19:25:29 +0200,
> Jaroslav Kysela wrote:
>>
>> On 27. 10. 21 16:40, Takashi Iwai wrote:
>>> 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.
> 
> But it says "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.
> 
> 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

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-28 10:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 14:40 [PATCH alsa-utils] alsactl: Add --quiet option to suppress alsa-lib error messages Takashi Iwai
2021-10-27 17:25 ` Jaroslav Kysela
2021-10-28  6:18   ` Takashi Iwai
2021-10-28 10:25     ` Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.