From 58e4aa3e33317bb8c109f46b080d321dc7e9b9b5 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 28 May 2026 11:32:25 +0200 Subject: [PATCH] pcm: use new logging for hw_params dump, add pcm_params log interface This change was omitted. Signed-off-by: Jaroslav Kysela --- include/error.h | 3 ++- src/error.c | 1 + src/pcm/pcm_params.c | 35 ++++++++++++++++++++--------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/error.h b/include/error.h index 042cf157..a525845c 100644 --- a/include/error.h +++ b/include/error.h @@ -68,7 +68,8 @@ const char *snd_strerror(int errnum); #define SND_ILOG_UCM 10 /**< UCM API */ #define SND_ILOG_TOPOLOGY 11 /**< topology API */ #define SND_ILOG_ASERVER 12 /**< aserver */ -#define SND_ILOG_LAST SND_ILOG_ASERVER /**< last known value for interface */ +#define SND_ILOG_PCM_PARAMS 13 /**< PCM hw_params operations */ +#define SND_ILOG_LAST SND_ILOG_PCM_PARAMS /**< last known value for interface */ /** * \brief Log handler callback. diff --git a/src/error.c b/src/error.c index df8ba522..ad874202 100644 --- a/src/error.c +++ b/src/error.c @@ -114,6 +114,7 @@ static const char *snd_ilog_interface_names[SND_ILOG_LAST + 1] = { [SND_ILOG_UCM] = "ucm", [SND_ILOG_TOPOLOGY] = "topology", [SND_ILOG_ASERVER] = "aserver", + [SND_ILOG_PCM_PARAMS] = "pcmpar", }; /** diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 0536252e..e40c87df 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -22,37 +22,42 @@ #include "pcm_local.h" #ifndef NDEBUG -/* - * dump hw_params when $LIBASOUND_DEBUG is set to >= 1 - */ static void dump_hw_params(snd_pcm_hw_params_t *params, const char *type, snd_pcm_hw_param_t var, unsigned int val, int err) { - const char *verbose = getenv("LIBASOUND_DEBUG"); snd_output_t *out; + const char *s; + char *p, *buf; - if (! verbose || ! *verbose || atoi(verbose) < 1) - return; - if (snd_output_stdio_attach(&out, stderr, 0) < 0) + if (!snd_lib_log_filter(SND_LOG_DEBUG, SND_ILOG_PCM_PARAMS, NULL)) return; - fprintf(stderr, "ALSA ERROR hw_params: %s (%s)\n", - type, snd_pcm_hw_param_name(var)); - fprintf(stderr, " value = "); switch (var) { case SND_PCM_HW_PARAM_ACCESS: - fprintf(stderr, "%s", snd_pcm_access_name(val)); + s = snd_pcm_access_name(val); break; case SND_PCM_HW_PARAM_FORMAT: - fprintf(stderr, "%s", snd_pcm_format_name(val)); + s = snd_pcm_format_name(val); break; case SND_PCM_HW_PARAM_SUBFORMAT: - fprintf(stderr, "%s", snd_pcm_subformat_name(val)); + s = snd_pcm_subformat_name(val); break; default: - fprintf(stderr, "%u", val); + s = NULL; } - fprintf(stderr, " : %s\n", snd_strerror(err)); + if (snd_output_buffer_open(&out) < 0) + return; snd_pcm_hw_params_dump(params, out); + snd_output_putc(out, '\0'); + snd_output_buffer_string(out, &buf); + for (p = buf; *p; p++) + if (*p == '\n') + *p = '|'; + if (s) + snd_debug(PCM_PARAMS, "hw_params: %s (%s), value = %s : %s {%s}", + type, snd_pcm_hw_param_name(var), s, snd_strerror(err), buf); + else + snd_debug(PCM_PARAMS, "hw_params: %s (%s), value = %u : %s {%s}", + type, snd_pcm_hw_param_name(var), val, snd_strerror(err), buf); snd_output_close(out); } #else -- 2.52.0