alsactl: add support for new log handler (alsa-lib 1.2.15)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
8957eb224b
commit
862ba9c1f8
4 changed files with 40 additions and 4 deletions
|
|
@ -441,7 +441,11 @@ int main(int argc, char *argv[])
|
|||
syslog(LOG_INFO, "alsactl " SND_UTIL_VERSION_STR " daemon started");
|
||||
}
|
||||
|
||||
#if SND_LIB_VER(1, 2, 15) < SND_LIB_VERSION
|
||||
snd_lib_error_set_handler(error_handler);
|
||||
#else
|
||||
snd_lib_log_set_handler(log_handler);
|
||||
#endif
|
||||
|
||||
if (!strcmp(cmd, "init")) {
|
||||
res = init(cfgdir, initfile, initflags | FLAG_UCM_FBOOT | FLAG_UCM_BOOT, cardname);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ void info_(const char *fcn, long line, const char *fmt, ...);
|
|||
void error_(const char *fcn, long line, const char *fmt, ...);
|
||||
void cerror_(const char *fcn, long line, int cond, const char *fmt, ...);
|
||||
void dbg_(const char *fcn, long line, const char *fmt, ...);
|
||||
void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...);
|
||||
void error_handler(const char *file, int line, const char *function, int errcode, const char *fmt, ...);
|
||||
void log_handler(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg);
|
||||
|
||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
||||
#define info(...) do { info_(__func__, __LINE__, __VA_ARGS__); } while (0)
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ void dbg_(const char *fcn, long line, const char *fmt, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...)
|
||||
void error_handler(const char *file, int line, const char *function, int errcode, const char *fmt, ...)
|
||||
{
|
||||
char buf[2048];
|
||||
va_list arg;
|
||||
|
|
@ -187,12 +187,36 @@ void error_handler(const char *file, int line, const char *function, int err, co
|
|||
va_end(arg);
|
||||
if (use_syslog)
|
||||
syslog(LOG_ERR, "alsa-lib %s:%i:(%s) %s%s%s\n", file, line, function,
|
||||
buf, err ? ": " : "", err ? snd_strerror(err) : "");
|
||||
buf, errcode ? ": " : "", errcode ? snd_strerror(errcode) : "");
|
||||
else
|
||||
fprintf(stderr, "alsa-lib %s:%i:(%s) %s%s%s\n", file, line, function,
|
||||
buf, err ? ": " : "", err ? snd_strerror(err) : "");
|
||||
buf, errcode ? ": " : "", errcode ? snd_strerror(errcode) : "");
|
||||
}
|
||||
|
||||
#if SND_LIB_VER(1, 2, 15) >= SND_LIB_VERSION
|
||||
void log_handler(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg)
|
||||
{
|
||||
char buf[2048], level[50] = "";
|
||||
const char *text1, *text2;
|
||||
|
||||
if (!snd_lib_log_filter(prio, interface, NULL))
|
||||
return;
|
||||
|
||||
text1 = snd_lib_log_priority(prio);
|
||||
text2 = snd_lib_log_interface(interface);
|
||||
if (text1 || text2)
|
||||
snprintf(level, sizeof(level), "[%s.%s] ", text1 ? text1 : "", text2 ? text2 : "");
|
||||
|
||||
vsnprintf(buf, sizeof(buf), fmt, arg);
|
||||
if (use_syslog)
|
||||
syslog(LOG_ERR, "alsa-lib %s:%i:(%s) %s%s%s%s\n", file, line, function, level,
|
||||
buf, errcode ? ": " : "", errcode ? snd_strerror(errcode) : "");
|
||||
else
|
||||
fprintf(stderr, "alsa-lib %s:%i:(%s) %s%s%s%s\n", file, line, function, level,
|
||||
buf, errcode ? ": " : "", errcode ? snd_strerror(errcode) : "");
|
||||
}
|
||||
#endif
|
||||
|
||||
int load_configuration(const char *file, snd_config_t **top, int *open_failed)
|
||||
{
|
||||
snd_config_t *config;
|
||||
|
|
|
|||
|
|
@ -1464,6 +1464,13 @@ static void set_params(void)
|
|||
chunk_size, buffer_size);
|
||||
prg_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (dump_hw_params) {
|
||||
fprintf(stderr, _("HW Params of device \"%s\":\n"),
|
||||
snd_pcm_name(handle));
|
||||
fprintf(stderr, "--------------------\n");
|
||||
snd_pcm_hw_params_dump(params, log);
|
||||
fprintf(stderr, "--------------------\n");
|
||||
}
|
||||
err = snd_pcm_sw_params_current(handle, swparams);
|
||||
if (err < 0) {
|
||||
error(_("Unable to get current sw params."));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue