Skip to content

Commit 4b87eb4

Browse files
committed
aconnect: add support for new log handler (alsa-lib 1.2.15)
Signed-off-by: Jaroslav Kysela <[email protected]>
1 parent 55017b0 commit 4b87eb4

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

seq/aconnect/aconnect.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131

3232
static int show_all;
3333

34-
static void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...)
34+
35+
#if SND_LIB_VER(1, 2, 15) < SND_LIB_VERSION
36+
static void error_handler(const char *file, int line, const char *function, int errcode, const char *fmt, ...)
3537
{
3638
va_list arg;
3739

38-
if (err == ENOENT) /* Ignore those misleading "warnings" */
40+
if (errcode == ENOENT) /* Ignore those misleading "warnings" */
3941
return;
4042
va_start(arg, fmt);
4143
fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function);
@@ -45,6 +47,16 @@ static void error_handler(const char *file, int line, const char *function, int
4547
putc('\n', stderr);
4648
va_end(arg);
4749
}
50+
#else
51+
static snd_lib_log_handler_t original_log_handler;
52+
static void log_handler(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg)
53+
{
54+
if (prio == SND_LOG_ERROR && errcode == ENOENT) /* Ignore those misleading "warnings" */
55+
return;
56+
if (original_log_handler)
57+
original_log_handler(prio, interface, file, line, function, errcode, fmt, arg);
58+
}
59+
#endif
4860

4961
static void usage(void)
5062
{
@@ -356,7 +368,11 @@ int main(int argc, char **argv)
356368
return 1;
357369
}
358370

371+
#if SND_LIB_VER(1, 2, 15) < SND_LIB_VERSION
359372
snd_lib_error_set_handler(error_handler);
373+
#else
374+
original_log_handler = snd_lib_log_set_handler(log_handler);
375+
#endif
360376

361377
switch (command) {
362378
case LIST:

0 commit comments

Comments
 (0)