pcm: use new logging for hw_params dump, add pcm_params log interface

This change was omitted.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2026-05-28 11:32:25 +02:00
parent ef115c4e59
commit 58e4aa3e33
3 changed files with 23 additions and 16 deletions

View file

@ -68,7 +68,8 @@ const char *snd_strerror(int errnum);
#define SND_ILOG_UCM 10 /**< UCM API */ #define SND_ILOG_UCM 10 /**< UCM API */
#define SND_ILOG_TOPOLOGY 11 /**< topology API */ #define SND_ILOG_TOPOLOGY 11 /**< topology API */
#define SND_ILOG_ASERVER 12 /**< aserver */ #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. * \brief Log handler callback.

View file

@ -114,6 +114,7 @@ static const char *snd_ilog_interface_names[SND_ILOG_LAST + 1] = {
[SND_ILOG_UCM] = "ucm", [SND_ILOG_UCM] = "ucm",
[SND_ILOG_TOPOLOGY] = "topology", [SND_ILOG_TOPOLOGY] = "topology",
[SND_ILOG_ASERVER] = "aserver", [SND_ILOG_ASERVER] = "aserver",
[SND_ILOG_PCM_PARAMS] = "pcmpar",
}; };
/** /**

View file

@ -22,37 +22,42 @@
#include "pcm_local.h" #include "pcm_local.h"
#ifndef NDEBUG #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, 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) snd_pcm_hw_param_t var, unsigned int val, int err)
{ {
const char *verbose = getenv("LIBASOUND_DEBUG");
snd_output_t *out; snd_output_t *out;
const char *s;
char *p, *buf;
if (! verbose || ! *verbose || atoi(verbose) < 1) if (!snd_lib_log_filter(SND_LOG_DEBUG, SND_ILOG_PCM_PARAMS, NULL))
return; return;
if (snd_output_stdio_attach(&out, stderr, 0) < 0)
return;
fprintf(stderr, "ALSA ERROR hw_params: %s (%s)\n",
type, snd_pcm_hw_param_name(var));
fprintf(stderr, " value = ");
switch (var) { switch (var) {
case SND_PCM_HW_PARAM_ACCESS: case SND_PCM_HW_PARAM_ACCESS:
fprintf(stderr, "%s", snd_pcm_access_name(val)); s = snd_pcm_access_name(val);
break; break;
case SND_PCM_HW_PARAM_FORMAT: case SND_PCM_HW_PARAM_FORMAT:
fprintf(stderr, "%s", snd_pcm_format_name(val)); s = snd_pcm_format_name(val);
break; break;
case SND_PCM_HW_PARAM_SUBFORMAT: case SND_PCM_HW_PARAM_SUBFORMAT:
fprintf(stderr, "%s", snd_pcm_subformat_name(val)); s = snd_pcm_subformat_name(val);
break; break;
default: 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_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); snd_output_close(out);
} }
#else #else