xref: /haiku/src/add-ons/media/media-add-ons/mixer/MixerDebug.h (revision 16d5c24e533eb14b7b8a99ee9f3ec9ba66335b1e)
1 /*
2  * Copyright 2002 David Shipman,
3  * Copyright 2003-2007 Marcus Overhagen
4  * Copyright 2007 Haiku Inc. All rights reserved.
5  * Distributed under the terms of the MIT License.
6  */
7 #ifndef _MIXER_DEBUG_H_
8 #define _MIXER_DEBUG_H_
9 
10 #ifndef DEBUG
11   #define DEBUG 0
12 #endif
13 
14 #include <Debug.h>
15 #include <stdio.h>
16 
17 #undef TRACE
18 #undef PRINT
19 
20 #if DEBUG > 0
21 
22   inline void ERROR(const char *fmt, ...) { va_list ap; va_start(ap, fmt); printf("### ERROR: "); vprintf(fmt, ap); va_end(ap); }
23   inline void PRINT(int level, const char *fmt, ...) { va_list ap; if (level > DEBUG) return; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); }
24 
25   #define PRINT_FORMAT(_text, _fmt)	do { char _buf[300]; string_for_format((_fmt), _buf, sizeof(_buf)); printf("%s %s\n", (_text), (_buf)); } while (0)
26   #define PRINT_INPUT(_text, _in) 	do { char _buf[300]; string_for_format((_in).format, _buf, sizeof(_buf)); printf("%s node(node %ld, port %ld); source(port %ld, id %ld); dest(port %ld, id %ld); fmt(%s); name(%s)\n", (_text), (_in).node.node, (_in).node.port, (_in).source.port, (_in).source.id, (_in).destination.port, (_in).destination.id, _buf, (_in).name); } while (0)
27   #define PRINT_OUTPUT(_text, _out)	do { char _buf[300]; string_for_format((_out).format, _buf, sizeof(_buf)); printf("%s node(node %ld, port %ld); source(port %ld, id %ld); dest(port %ld, id %ld); fmt(%s); name(%s)\n", (_text), (_out).node.node, (_out).node.port, (_out).source.port, (_out).source.id, (_out).destination.port, (_out).destination.id, _buf, (_out).name); } while (0)
28   #define PRINT_CHANNEL_MASK(fmt)   do { char s[200]; StringForChannelMask(s, (fmt).u.raw_audio.channel_mask); printf(" channel_mask 0x%08lX %s\n", (fmt).u.raw_audio.channel_mask, s); } while (0)
29 
30   #if DEBUG >= 2
31 	#define TRACE 				printf
32   #else
33 	#define TRACE(a...)			((void)0)
34   #endif
35 
36 #else
37 
38 	#define PRINT_FORMAT(_text, _fmt)	((void)0)
39 	#define PRINT_INPUT(_text, _in)		((void)0)
40 	#define PRINT_OUTPUT(_text, _out)	((void)0)
41 	#define PRINT_CHANNEL_MASK(fmt) ((void)0)
42 	#define PRINT(l, a...)				((void)0)
43 	#define ERROR(a...)					((void)0)
44 	#define TRACE(a...)					((void)0)
45 
46 #endif
47 
48 #endif /* _MIXER_DEBUG_H_ */
49