]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: use new logging for hw_params dump, add pcm_params log interface
authorJaroslav Kysela <perex@perex.cz>
Thu, 28 May 2026 09:32:25 +0000 (11:32 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 28 May 2026 10:11:12 +0000 (12:11 +0200)
This change was omitted.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
include/error.h
src/error.c
src/pcm/pcm_params.c

index 042cf1575f5b7ca108da9ffa0eba4a93cbf4c530..a525845cceb40ce014ffff2e3b12e962ed1f68fe 100644 (file)
@@ -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.
index df8ba522a86436ba852d3e293b391900737c527b..ad874202dc7bbbe5faca8c5a324da0ebf2a04c3b 100644 (file)
@@ -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",
 };
 
 /**
index 0536252e7eb1f9be0129cda246d21fd4eae9eeea..e40c87dfd26b79cc5fe5f37428a5e6016a3fabc6 100644 (file)
 #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