ReactOS 0.4.16-dev-13-ge2fc578
mmebuddy_debug.h
Go to the documentation of this file.
1#ifndef ROS_AUDIO_MMEBUDDY_DEBUG_H
2#define ROS_AUDIO_MMEBUDDY_DEBUG_H
3
4/*
5 Hacky debug macro
6*/
7// TODO: Use a string-safe function instead of wsprintf().
8
9// FIXME: sdk\lib\...\mmebuddy compilation would fail: wsprintf() and MessageBoxW() are undefined!
10#if DBG && !defined(NDEBUG) // #if DBG
11
12 // Helper for SND_ASSERT().
13 #define POPUP(...) \
14 { \
15 WCHAR dbg_popup_msg[1024], dbg_popup_title[256]; \
16 wsprintf(dbg_popup_title, L"%hS(%d)", __FILE__, __LINE__); \
17 wsprintf(dbg_popup_msg, __VA_ARGS__); \
18 MessageBoxW(NULL, dbg_popup_msg, dbg_popup_title, MB_OK | MB_TASKMODAL); \
19 }
20
21 #define SND_ERR(...) \
22 { \
23 WCHAR dbg_popup_msg[1024]; \
24 wsprintf(dbg_popup_msg, __VA_ARGS__); \
25 OutputDebugStringW(dbg_popup_msg); \
26 }
27
28 #define SND_ASSERT(condition) \
29 { \
30 if ( ! ( condition ) ) \
31 { \
32 SND_ERR(L"ASSERT FAILED: %hS File %hS Line %u\n", #condition, __FILE__, __LINE__); \
33 POPUP(L"ASSERT FAILED: %hS\n", #condition); \
34 ExitProcess(1); \
35 } \
36 }
37
38#else // DBG
39
40 #define SND_ERR(...) do {} while ( 0 )
41 #define SND_ASSERT(condition) do {(void)(condition);} while ( 0 )
42
43#endif // DBG
44
45#if DBG && !defined(NDEBUG)
46
47 #define SND_WARN(...) \
48 { \
49 WCHAR dbg_popup_msg[1024]; \
50 wsprintf(dbg_popup_msg, __VA_ARGS__); \
51 OutputDebugStringW(dbg_popup_msg); \
52 }
53
54 #define SND_TRACE(...) \
55 { \
56 WCHAR dbg_popup_msg[1024]; \
57 wsprintf(dbg_popup_msg, __VA_ARGS__); \
58 OutputDebugStringW(dbg_popup_msg); \
59 }
60
61 #define DUMP_WAVEHDR_QUEUE(sound_device_instance) \
62 { \
63 PWAVEHDR CurrDumpHdr = sound_device_instance->HeadWaveHeader; \
64 SND_TRACE(L"-- Current wave header list --\n"); \
65 while ( CurrDumpHdr ) \
66 { \
67 SND_TRACE(L"%x | %d bytes | flags: %x\n", CurrDumpHdr, \
68 CurrDumpHdr->dwBufferLength, \
69 CurrDumpHdr->dwFlags); \
70 CurrDumpHdr = CurrDumpHdr->lpNext; \
71 } \
72 }
73
74#else // DBG && !defined(NDEBUG)
75
76 #define SND_WARN(...) do {} while ( 0 )
77 #define SND_TRACE(...) do {} while ( 0 )
78 #define DUMP_WAVEHDR_QUEUE(sound_device_instance) do {} while ( 0 )
79
80#endif // DBG && !defined(NDEBUG)
81
82#endif /* ROS_AUDIO_MMEBUDDY_DEBUG_H */