Mercurial > mplayer.hg
comparison libao2/ao_alsa.c @ 17691:b73103a82416
Output error messages from the ALSA library through mp_msg() instead of
the default stderr.
author | cladisch |
---|---|
date | Mon, 27 Feb 2006 10:09:05 +0000 |
parents | 9ca95aee8449 |
children | 4e32c2caf696 |
comparison
equal
deleted
inserted
replaced
17690:9ca95aee8449 | 17691:b73103a82416 |
---|---|
13 */ | 13 */ |
14 | 14 |
15 #include <errno.h> | 15 #include <errno.h> |
16 #include <sys/time.h> | 16 #include <sys/time.h> |
17 #include <stdlib.h> | 17 #include <stdlib.h> |
18 #include <stdarg.h> | |
18 #include <math.h> | 19 #include <math.h> |
19 #include <string.h> | 20 #include <string.h> |
20 | 21 |
21 #include "config.h" | 22 #include "config.h" |
22 #include "subopt-helper.h" | 23 #include "subopt-helper.h" |
69 | 70 |
70 #define ALSA_DEVICE_SIZE 256 | 71 #define ALSA_DEVICE_SIZE 256 |
71 | 72 |
72 #undef BUFFERTIME | 73 #undef BUFFERTIME |
73 #define SET_CHUNKSIZE | 74 #define SET_CHUNKSIZE |
75 | |
76 static void alsa_error_handler(const char *file, int line, const char *function, | |
77 int err, const char *format, ...) | |
78 { | |
79 char tmp[0xc00]; | |
80 va_list va; | |
81 | |
82 va_start(va, format); | |
83 vsnprintf(tmp, sizeof tmp, format, va); | |
84 va_end(va); | |
85 tmp[sizeof tmp - 1] = '\0'; | |
86 | |
87 if (err) | |
88 mp_msg(MSGT_AO, MSGL_ERR, "alsa-lib: %s:%i:(%s) %s: %s\n", | |
89 file, line, function, tmp, snd_strerror(err)); | |
90 else | |
91 mp_msg(MSGT_AO, MSGL_ERR, "alsa-lib: %s:%i:(%s) %s\n", | |
92 file, line, function, tmp); | |
93 } | |
74 | 94 |
75 /* to set/get/query special features/parameters */ | 95 /* to set/get/query special features/parameters */ |
76 static int control(int cmd, void *arg) | 96 static int control(int cmd, void *arg) |
77 { | 97 { |
78 switch(cmd) { | 98 switch(cmd) { |
273 #if SND_LIB_VERSION >= 0x010005 | 293 #if SND_LIB_VERSION >= 0x010005 |
274 mp_msg(MSGT_AO,MSGL_V,"alsa-init: using ALSA %s\n", snd_asoundlib_version()); | 294 mp_msg(MSGT_AO,MSGL_V,"alsa-init: using ALSA %s\n", snd_asoundlib_version()); |
275 #else | 295 #else |
276 mp_msg(MSGT_AO,MSGL_V,"alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); | 296 mp_msg(MSGT_AO,MSGL_V,"alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); |
277 #endif | 297 #endif |
298 | |
299 snd_lib_error_set_handler(alsa_error_handler); | |
278 | 300 |
279 if ((err = snd_card_next(&cards)) < 0 || cards < 0) | 301 if ((err = snd_card_next(&cards)) < 0 || cards < 0) |
280 { | 302 { |
281 mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: no soundcards found: %s\n", snd_strerror(err)); | 303 mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: no soundcards found: %s\n", snd_strerror(err)); |
282 return(0); | 304 return(0); |