diff options
author | Daniel Caujolle-Bert <f1rmb@users.sourceforge.net> | 2003-07-18 20:51:51 +0000 |
---|---|---|
committer | Daniel Caujolle-Bert <f1rmb@users.sourceforge.net> | 2003-07-18 20:51:51 +0000 |
commit | 0aecf9651cb31e1825bbca35b92464c18a6d67bd (patch) | |
tree | 937eb1deeed5550ec01a183453e269e3e736bce5 | |
parent | 24643faedd3f0cedafc1421da703c1489a28ac5e (diff) | |
download | xine-lib-0aecf9651cb31e1825bbca35b92464c18a6d67bd.tar.gz xine-lib-0aecf9651cb31e1825bbca35b92464c18a6d67bd.tar.bz2 |
made alsa-lib silent with non DEBUG builds
CVS patchset: 5174
CVS date: 2003/07/18 20:51:51
-rw-r--r-- | src/audio_out/audio_alsa_out.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 8c0beed1b..5a3545077 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -26,7 +26,7 @@ * (c) 2001 James Courtier-Dutton <James@superbug.demon.co.uk> * * - * $Id: audio_alsa_out.c,v 1.96 2003/07/02 12:56:10 jcdutton Exp $ + * $Id: audio_alsa_out.c,v 1.97 2003/07/18 20:51:51 f1rmb Exp $ */ #ifdef HAVE_CONFIG_H @@ -34,6 +34,7 @@ #endif #include <stdio.h> +#include <stdarg.h> #include <errno.h> #include <string.h> #include <unistd.h> @@ -227,6 +228,45 @@ static long ao_alsa_get_volume_from_percent(int val, long min, long max) { return tmp; } +/* + * Error callback, we need to control this, + * error message should be printed in non DEBUG mode. + */ +static void error_callback(const char *file, int line, + const char *function, int err, const char *fmt, ...) { +#ifdef DEBUG + va_list args; + char *buf; + int n, size = 100; + + if((buf = xine_xmalloc(size)) == NULL) + return; + + while(1) { + + va_start(args, fmt); + n = vsnprintf(buf, size, fmt, args); + va_end(args); + + if(n > -1 && n < size) + break; + + if(n > -1) + size = n + 1; + else + size *= 2; + + if((buf = realloc(buf, size)) == NULL) + return; + } + + + printf("%s: %s() %s.\n", file, function, buf); + + if(buf) + free(buf); +#endif +} /* * open the audio device for writing to @@ -1086,6 +1126,7 @@ static void ao_alsa_mixer_init(ao_driver_t *this_gen) { /* * Initialize plugin */ + static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *data) { alsa_class_t *class = (alsa_class_t *) class_gen; @@ -1097,6 +1138,11 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da this = (alsa_driver_t *) malloc (sizeof (alsa_driver_t)); this->class = class; + + err = snd_lib_error_set_handler(error_callback); + if(err < 0) + xine_log(this->class->xine, XINE_LOG_MSG, "snd_lib_error_set_handler() failed: %d", err); + snd_pcm_hw_params_alloca(¶ms); /* Fill the .xinerc file with options */ this->mmap = config->register_bool (config, |