# HG changeset patch # User cladisch # Date 1141034945 0 # Node ID b73103a824169bea2b4bf7c1316a97b53f0bec5e # Parent 9ca95aee84495ab0e92d971fbdacf3c633e39738 Output error messages from the ALSA library through mp_msg() instead of the default stderr. diff -r 9ca95aee8449 -r b73103a82416 libao2/ao_alsa.c --- a/libao2/ao_alsa.c Mon Feb 27 10:06:27 2006 +0000 +++ b/libao2/ao_alsa.c Mon Feb 27 10:09:05 2006 +0000 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -72,6 +73,25 @@ #undef BUFFERTIME #define SET_CHUNKSIZE +static void alsa_error_handler(const char *file, int line, const char *function, + int err, const char *format, ...) +{ + char tmp[0xc00]; + va_list va; + + va_start(va, format); + vsnprintf(tmp, sizeof tmp, format, va); + va_end(va); + tmp[sizeof tmp - 1] = '\0'; + + if (err) + mp_msg(MSGT_AO, MSGL_ERR, "alsa-lib: %s:%i:(%s) %s: %s\n", + file, line, function, tmp, snd_strerror(err)); + else + mp_msg(MSGT_AO, MSGL_ERR, "alsa-lib: %s:%i:(%s) %s\n", + file, line, function, tmp); +} + /* to set/get/query special features/parameters */ static int control(int cmd, void *arg) { @@ -275,6 +295,8 @@ #else mp_msg(MSGT_AO,MSGL_V,"alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); #endif + + snd_lib_error_set_handler(alsa_error_handler); if ((err = snd_card_next(&cards)) < 0 || cards < 0) {