[MPlayer-cvslog] CVS: main/libao2 ao_alsa.c,1.37,1.38

Clemens Ladisch CVS syncmail at mplayerhq.hu
Mon Feb 27 11:09:07 CET 2006


CVS change done by Clemens Ladisch CVS

Update of /cvsroot/mplayer/main/libao2
In directory mail:/var2/tmp/cvs-serv922/libao2

Modified Files:
	ao_alsa.c 
Log Message:
Output error messages from the ALSA library through mp_msg() instead of
the default stderr.

Index: ao_alsa.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- ao_alsa.c	27 Feb 2006 10:06:27 -0000	1.37
+++ ao_alsa.c	27 Feb 2006 10:09:05 -0000	1.38
@@ -15,6 +15,7 @@
 #include <errno.h>
 #include <sys/time.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <math.h>
 #include <string.h>
 
@@ -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)
     {




More information about the MPlayer-cvslog mailing list