aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-06-07 15:42:15 -0700
committerChris Robinson <[email protected]>2009-06-07 15:42:15 -0700
commit1454c46b5fed42dca9d509a66d4cefac2800289c (patch)
tree601fb44ba06b839d952c7ecda5fcbf154a7938dd /OpenAL32
parent0fac1e911565791e50c0d23ce515042a64c40696 (diff)
Use a thread-safe static inline function for printing
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h38
1 files changed, 25 insertions, 13 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 5efbbbe7..fee0c315 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -3,6 +3,7 @@
#include <string.h>
#include <stdio.h>
+#include <stdarg.h>
#ifdef HAVE_FENV_H
#include <fenv.h>
@@ -107,19 +108,30 @@ static inline void Sleep(ALuint t)
extern "C" {
#endif
-extern char _alDebug[256];
-
-#define AL_PRINT(...) do { \
- int _al_print_i; \
- const char *_al_print_fn = strrchr(__FILE__, '/'); \
- if(!_al_print_fn) _al_print_fn = __FILE__; \
- else _al_print_fn += 1; \
- _al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
- if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
- snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
- _alDebug[sizeof(_alDebug)-1] = 0; \
- fprintf(stderr, "%s", _alDebug); \
-} while(0)
+static __inline void al_print(const char *fname, unsigned int line, const char *fmt, ...)
+{
+ const char *fn;
+ char str[256];
+ int i;
+
+ fn = strrchr(fname, '/');
+ if(!fn) fn = strrchr(fname, '\\');;
+ if(!fn) fn = fname;
+ else fn += 1;
+
+ i = snprintf(str, sizeof(str), "AL lib: %s:%d: ", fn, line);
+ if(i < (int)sizeof(str) && i > 0)
+ {
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(str+i, sizeof(str)-i, fmt, ap);
+ va_end(ap);
+ }
+ str[sizeof(str)-1] = 0;
+
+ fprintf(stderr, "%s", str);
+}
+#define AL_PRINT(...) al_print(__FILE__, __LINE__, __VA_ARGS__)
#define SWMIXER_OUTPUT_RATE 44100