Playlist Generator  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines
CADebugMacros.h
Go to the documentation of this file.
00001 /*
00002 
00003     File: CADebugMacros.h
00004 Abstract: Helper class for printing debug messages
00005  Version: 1.5
00006 
00007 Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
00008 Inc. ("Apple") in consideration of your agreement to the following
00009 terms, and your use, installation, modification or redistribution of
00010 this Apple software constitutes acceptance of these terms.  If you do
00011 not agree with these terms, please do not use, install, modify or
00012 redistribute this Apple software.
00013 
00014 In consideration of your agreement to abide by the following terms, and
00015 subject to these terms, Apple grants you a personal, non-exclusive
00016 license, under Apple's copyrights in this original Apple software (the
00017 "Apple Software"), to use, reproduce, modify and redistribute the Apple
00018 Software, with or without modifications, in source and/or binary forms;
00019 provided that if you redistribute the Apple Software in its entirety and
00020 without modifications, you must retain this notice and the following
00021 text and disclaimers in all such redistributions of the Apple Software.
00022 Neither the name, trademarks, service marks or logos of Apple Inc. may
00023 be used to endorse or promote products derived from the Apple Software
00024 without specific prior written permission from Apple.  Except as
00025 expressly stated in this notice, no other rights or licenses, express or
00026 implied, are granted by Apple herein, including but not limited to any
00027 patent rights that may be infringed by your derivative works or by other
00028 works in which the Apple Software may be incorporated.
00029 
00030 The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
00031 MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
00032 THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
00033 FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
00034 OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
00035 
00036 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
00037 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00038 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00039 INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
00040 MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
00041 AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
00042 STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
00043 POSSIBILITY OF SUCH DAMAGE.
00044 
00045 Copyright (C) 2008 Apple Inc. All Rights Reserved.
00046 
00047 
00048 */
00049 
00050 #if !defined(__CADebugMacros_h__)
00051 #define __CADebugMacros_h__
00052 
00053 //=============================================================================
00054 //      Includes
00055 //=============================================================================
00056 
00057 #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
00058         #include <CoreAudio/CoreAudioTypes.h>
00059 #else
00060         #include "CoreAudioTypes.h"
00061 #endif
00062 
00063 //=============================================================================
00064 //      CADebugMacros
00065 //=============================================================================
00066 
00067 //#define       CoreAudio_StopOnFailure                 1
00068 //#define       CoreAudio_TimeStampMessages             1
00069 //#define       CoreAudio_ThreadStampMessages   1
00070 //#define       CoreAudio_FlushDebugMessages    1
00071 
00072 #if TARGET_RT_BIG_ENDIAN
00073         #define CA4CCToCString(the4CC)                                  { ((char*)&the4CC)[0], ((char*)&the4CC)[1], ((char*)&the4CC)[2], ((char*)&the4CC)[3], 0 }
00074         #define CACopy4CCToCString(theCString, the4CC)  { theCString[0] = ((char*)&the4CC)[0]; theCString[1] = ((char*)&the4CC)[1]; theCString[2] = ((char*)&the4CC)[2]; theCString[3] = ((char*)&the4CC)[3]; theCString[4] = 0; }
00075 #else
00076         #define CA4CCToCString(the4CC)                                  { ((char*)&the4CC)[3], ((char*)&the4CC)[2], ((char*)&the4CC)[1], ((char*)&the4CC)[0], 0 }
00077         #define CACopy4CCToCString(theCString, the4CC)  { theCString[0] = ((char*)&the4CC)[3]; theCString[1] = ((char*)&the4CC)[2]; theCString[2] = ((char*)&the4CC)[1]; theCString[3] = ((char*)&the4CC)[0]; theCString[4] = 0; }
00078 #endif
00079 
00080 #pragma mark    Basic Definitions
00081 
00082 #if     DEBUG || CoreAudio_Debug
00083         
00084         // can be used to break into debugger immediately, also see CADebugger
00085         #define BusError()              (*(long *)0 = 0)
00086         
00087         //      basic debugging print routines
00088         #if     TARGET_OS_MAC && !TARGET_API_MAC_CARBON
00089                 extern void DebugStr(const unsigned char* debuggerMsg);
00090                 #define DebugMessage(msg)       DebugStr("\p"msg)
00091                 #define DebugMessageN1(msg, N1)
00092                 #define DebugMessageN2(msg, N1, N2)
00093                 #define DebugMessageN3(msg, N1, N2, N3)
00094         #else
00095                 #include "CADebugPrintf.h"
00096                 
00097                 #if     (CoreAudio_FlushDebugMessages && !CoreAudio_UseSysLog) || defined(CoreAudio_UseSideFile)
00098                         #define FlushRtn        ,fflush(DebugPrintfFile)
00099                 #else
00100                         #define FlushRtn
00101                 #endif
00102                 
00103                 #if             CoreAudio_ThreadStampMessages
00104                         #include <pthread.h>
00105                         #include "CAHostTimeBase.h"
00106                         #define DebugMessage(msg)                                                                               DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: %s"DebugPrintfLineEnding, pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), msg) FlushRtn
00107                         #define DebugMessageN1(msg, N1)                                                                 DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1) FlushRtn
00108                         #define DebugMessageN2(msg, N1, N2)                                                             DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2) FlushRtn
00109                         #define DebugMessageN3(msg, N1, N2, N3)                                                 DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3) FlushRtn
00110                         #define DebugMessageN4(msg, N1, N2, N3, N4)                                             DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4) FlushRtn
00111                         #define DebugMessageN5(msg, N1, N2, N3, N4, N5)                                 DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5) FlushRtn
00112                         #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)                             DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6) FlushRtn
00113                         #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)                 DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7) FlushRtn
00114                         #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)             DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
00115                         #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
00116                 #elif   CoreAudio_TimeStampMessages
00117                         #include "CAHostTimeBase.h"
00118                         #define DebugMessage(msg)                                                                               DebugPrintfRtn(DebugPrintfFileComma "%.4f: %s"DebugPrintfLineEnding, pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), msg) FlushRtn
00119                         #define DebugMessageN1(msg, N1)                                                                 DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1) FlushRtn
00120                         #define DebugMessageN2(msg, N1, N2)                                                             DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2) FlushRtn
00121                         #define DebugMessageN3(msg, N1, N2, N3)                                                 DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3) FlushRtn
00122                         #define DebugMessageN4(msg, N1, N2, N3, N4)                                             DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4) FlushRtn
00123                         #define DebugMessageN5(msg, N1, N2, N3, N4, N5)                                 DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5) FlushRtn
00124                         #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)                             DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6) FlushRtn
00125                         #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)                 DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7) FlushRtn
00126                         #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)             DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
00127                         #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
00128                 #else
00129                         #define DebugMessage(msg)                                                                               DebugPrintfRtn(DebugPrintfFileComma "%s"DebugPrintfLineEnding, msg) FlushRtn
00130                         #define DebugMessageN1(msg, N1)                                                                 DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1) FlushRtn
00131                         #define DebugMessageN2(msg, N1, N2)                                                             DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2) FlushRtn
00132                         #define DebugMessageN3(msg, N1, N2, N3)                                                 DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3) FlushRtn
00133                         #define DebugMessageN4(msg, N1, N2, N3, N4)                                             DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4) FlushRtn
00134                         #define DebugMessageN5(msg, N1, N2, N3, N4, N5)                                 DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5) FlushRtn
00135                         #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)                             DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6) FlushRtn
00136                         #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)                 DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7) FlushRtn
00137                         #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)             DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
00138                         #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
00139                 #endif
00140         #endif
00141         void    DebugPrint(const char *fmt, ...);       // can be used like printf
00142         #ifndef DEBUGPRINT
00143                 #define DEBUGPRINT(msg) DebugPrint msg          // have to double-parenthesize arglist (see Debugging.h)
00144         #endif
00145         #if VERBOSE
00146                 #define vprint(msg) DEBUGPRINT(msg)
00147         #else
00148                 #define vprint(msg)
00149         #endif
00150         
00151         #if     CoreAudio_StopOnFailure
00152                 #include "CADebugger.h"
00153                 #define STOP    CADebuggerStop()
00154         #else
00155                 #define STOP
00156         #endif
00157 
00158 #else
00159         #define DebugMessage(msg)
00160         #define DebugMessageN1(msg, N1)
00161         #define DebugMessageN2(msg, N1, N2)
00162         #define DebugMessageN3(msg, N1, N2, N3)
00163         #define DebugMessageN4(msg, N1, N2, N3, N4)
00164         #define DebugMessageN5(msg, N1, N2, N3, N4, N5)
00165         #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)
00166         #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)
00167         #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)
00168         #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9)
00169         #define DEBUGPRINT(msg)
00170         #define vprint(msg)
00171         #define STOP
00172 #endif
00173 
00174 void    LogError(const char *fmt, ...);                 // writes to syslog (and stderr if debugging)
00175 void    LogWarning(const char *fmt, ...);               // writes to syslog (and stderr if debugging)
00176 
00177 #if     DEBUG || CoreAudio_Debug
00178 
00179 #pragma mark    Debug Macros
00180 
00181 #define Assert(inCondition, inMessage)                                                                                                  \
00182                         if(!(inCondition))                                                                                                                      \
00183                         {                                                                                                                                                       \
00184                                 DebugMessage(inMessage);                                                                                                \
00185                                 STOP;                                                                                                                                   \
00186                         }
00187 
00188 #define AssertNoError(inError, inMessage)                                                                                               \
00189                         {                                                                                                                                                       \
00190                                 SInt32 __Err = (inError);                                                                                               \
00191                                 if(__Err != 0)                                                                                                                  \
00192                                 {                                                                                                                                               \
00193                                         char __4CC[5] = CA4CCToCString(__Err);                                                          \
00194                                         DebugMessageN2(inMessage ", Error: %d (%s)", (int)__Err, __4CC);                \
00195                                         STOP;                                                                                                                           \
00196                                 }                                                                                                                                               \
00197                         }
00198 
00199 #define AssertNoKernelError(inError, inMessage)                                                                                 \
00200                         {                                                                                                                                                       \
00201                                 unsigned int __Err = (unsigned int)(inError);                                                   \
00202                                 if(__Err != 0)                                                                                                                  \
00203                                 {                                                                                                                                               \
00204                                         DebugMessageN1(inMessage ", Error: 0x%X", __Err);                                       \
00205                                         STOP;                                                                                                                           \
00206                                 }                                                                                                                                               \
00207                         }
00208 
00209 #define FailIf(inCondition, inHandler, inMessage)                                                                               \
00210                         if(inCondition)                                                                                                                         \
00211                         {                                                                                                                                                       \
00212                                 DebugMessage(inMessage);                                                                                                \
00213                                 STOP;                                                                                                                                   \
00214                                 goto inHandler;                                                                                                                 \
00215                         }
00216 
00217 #define FailWithAction(inCondition, inAction, inHandler, inMessage)                                             \
00218                         if(inCondition)                                                                                                                         \
00219                         {                                                                                                                                                       \
00220                                 DebugMessage(inMessage);                                                                                                \
00221                                 STOP;                                                                                                                                   \
00222                                 { inAction; }                                                                                                                   \
00223                                 goto inHandler;                                                                                                                 \
00224                         }
00225 
00226 #define FailIfNULL(inPointer, inAction, inHandler, inMessage)                                                   \
00227                         if((inPointer) == NULL)                                                                                                         \
00228                         {                                                                                                                                                       \
00229                                 DebugMessage(inMessage);                                                                                                \
00230                                 STOP;                                                                                                                                   \
00231                                 { inAction; }                                                                                                                   \
00232                                 goto inHandler;                                                                                                                 \
00233                         }
00234 
00235 #define FailIfKernelError(inKernelError, inAction, inHandler, inMessage)                                \
00236                         {                                                                                                                                                       \
00237                                 kern_return_t __Err = (inKernelError);                                                                  \
00238                                 if(__Err != 0)                                                                                                                  \
00239                                 {                                                                                                                                               \
00240                                         DebugMessageN1(inMessage ", Error: 0x%X", __Err);                                       \
00241                                         STOP;                                                                                                                           \
00242                                         { inAction; }                                                                                                           \
00243                                         goto inHandler;                                                                                                         \
00244                                 }                                                                                                                                               \
00245                         }
00246 
00247 #define FailIfError(inError, inAction, inHandler, inMessage)                                                    \
00248                         {                                                                                                                                                       \
00249                                 SInt32 __Err = (inError);                                                                                               \
00250                                 if(__Err != 0)                                                                                                                  \
00251                                 {                                                                                                                                               \
00252                                         char __4CC[5] = CA4CCToCString(__Err);                                                          \
00253                                         DebugMessageN2(inMessage ", Error: %ld (%s)", __Err, __4CC);            \
00254                                         STOP;                                                                                                                           \
00255                                         { inAction; }                                                                                                           \
00256                                         goto inHandler;                                                                                                         \
00257                                 }                                                                                                                                               \
00258                         }
00259 
00260 #if defined(__cplusplus)
00261 
00262 #define Throw(inException)  STOP; throw (inException)
00263 
00264 #define ThrowIf(inCondition, inException, inMessage)                                                                    \
00265                         if(inCondition)                                                                                                                         \
00266                         {                                                                                                                                                       \
00267                                 DebugMessage(inMessage);                                                                                                \
00268                                 Throw(inException);                                                                                                             \
00269                         }
00270 
00271 #define ThrowIfNULL(inPointer, inException, inMessage)                                                                  \
00272                         if((inPointer) == NULL)                                                                                                         \
00273                         {                                                                                                                                                       \
00274                                 DebugMessage(inMessage);                                                                                                \
00275                                 Throw(inException);                                                                                                             \
00276                         }
00277 
00278 #define ThrowIfKernelError(inKernelError, inException, inMessage)                                               \
00279                         {                                                                                                                                                       \
00280                                 kern_return_t __Err = (inKernelError);                                                                  \
00281                                 if(__Err != 0)                                                                                                                  \
00282                                 {                                                                                                                                               \
00283                                         DebugMessageN1(inMessage ", Error: 0x%X", __Err);                                       \
00284                                         Throw(inException);                                                                                                     \
00285                                 }                                                                                                                                               \
00286                         }
00287 
00288 #define ThrowIfError(inError, inException, inMessage)                                                                   \
00289                         {                                                                                                                                                       \
00290                                 SInt32 __Err = (inError);                                                                                               \
00291                                 if(__Err != 0)                                                                                                                  \
00292                                 {                                                                                                                                               \
00293                                         char __4CC[5] = CA4CCToCString(__Err);                                                          \
00294                                         DebugMessageN2(inMessage ", Error: %d (%s)", (int)__Err, __4CC);                \
00295                                         Throw(inException);                                                                                                     \
00296                                 }                                                                                                                                               \
00297                         }
00298 
00299 #if TARGET_OS_WIN32
00300 #define ThrowIfWinError(inError, inException, inMessage)                                                                \
00301                         {                                                                                                                                                       \
00302                                 HRESULT __Err = (inError);                                                                                              \
00303                                 if(FAILED(__Err))                                                                                                               \
00304                                 {                                                                                                                                               \
00305                                         DebugMessageN2(inMessage ", Code: %d, Facility: 0x%X", HRESULT_CODE(__Err), HRESULT_FACILITY(__Err));                   \
00306                                         Throw(inException);                                                                                                     \
00307                                 }                                                                                                                                               \
00308                         }
00309 #endif
00310 
00311 #define SubclassResponsibility(inMethodName, inException)                                                               \
00312                         {                                                                                                                                                       \
00313                                 DebugMessage(inMethodName": Subclasses must implement this method");    \
00314                                 Throw(inException);                                                                                                             \
00315                         }
00316 
00317 #endif  //      defined(__cplusplus)
00318 
00319 #else
00320 
00321 #pragma mark    Release Macros
00322 
00323 #define Assert(inCondition, inMessage)                                                                                                  \
00324                         if(!(inCondition))                                                                                                                      \
00325                         {                                                                                                                                                       \
00326                                 STOP;                                                                                                                                   \
00327                         }
00328 
00329 #define AssertNoError(inError, inMessage)                                                                                               \
00330                         {                                                                                                                                                       \
00331                                 SInt32 __Err = (inError);                                                                                               \
00332                                 if(__Err != 0)                                                                                                                  \
00333                                 {                                                                                                                                               \
00334                                         STOP;                                                                                                                           \
00335                                 }                                                                                                                                               \
00336                         }
00337 
00338 #define AssertNoKernelError(inError, inMessage)                                                                                 \
00339                         {                                                                                                                                                       \
00340                                 unsigned int __Err = (unsigned int)(inError);                                                   \
00341                                 if(__Err != 0)                                                                                                                  \
00342                                 {                                                                                                                                               \
00343                                         STOP;                                                                                                                           \
00344                                 }                                                                                                                                               \
00345                         }
00346 
00347 #define FailIf(inCondition, inHandler, inMessage)                                                                               \
00348                         if(inCondition)                                                                                                                         \
00349                         {                                                                                                                                                       \
00350                                 STOP;                                                                                                                                   \
00351                                 goto inHandler;                                                                                                                 \
00352                         }
00353 
00354 #define FailWithAction(inCondition, inAction, inHandler, inMessage)                                             \
00355                         if(inCondition)                                                                                                                         \
00356                         {                                                                                                                                                       \
00357                                 STOP;                                                                                                                                   \
00358                                 { inAction; }                                                                                                                   \
00359                                 goto inHandler;                                                                                                                 \
00360                         }
00361 
00362 #define FailIfNULL(inPointer, inAction, inHandler, inMessage)                                                   \
00363                         if((inPointer) == NULL)                                                                                                         \
00364                         {                                                                                                                                                       \
00365                                 STOP;                                                                                                                                   \
00366                                 { inAction; }                                                                                                                   \
00367                                 goto inHandler;                                                                                                                 \
00368                         }
00369 
00370 #define FailIfKernelError(inKernelError, inAction, inHandler, inMessage)                                \
00371                         if((inKernelError) != 0)                                                                                                        \
00372                         {                                                                                                                                                       \
00373                                 STOP;                                                                                                                                   \
00374                                 { inAction; }                                                                                                                   \
00375                                 goto inHandler;                                                                                                                 \
00376                         }
00377 
00378 #define FailIfError(inError, inAction, inHandler, inMessage)                                                    \
00379                         if((inError) != 0)                                                                                                                      \
00380                         {                                                                                                                                                       \
00381                                 STOP;                                                                                                                                   \
00382                                 { inAction; }                                                                                                                   \
00383                                 goto inHandler;                                                                                                                 \
00384                         }
00385 
00386 #if defined(__cplusplus)
00387 
00388 #define Throw(inException)  STOP; throw (inException)
00389 
00390 #define ThrowIf(inCondition, inException, inMessage)                                                                    \
00391                         if(inCondition)                                                                                                                         \
00392                         {                                                                                                                                                       \
00393                                 Throw(inException);                                                                                                             \
00394                         }
00395 
00396 #define ThrowIfNULL(inPointer, inException, inMessage)                                                                  \
00397                         if((inPointer) == NULL)                                                                                                         \
00398                         {                                                                                                                                                       \
00399                                 Throw(inException);                                                                                                             \
00400                         }
00401 
00402 #define ThrowIfKernelError(inKernelError, inException, inMessage)                                               \
00403                         {                                                                                                                                                       \
00404                                 kern_return_t __Err = (inKernelError);                                                                  \
00405                                 if(__Err != 0)                                                                                                                  \
00406                                 {                                                                                                                                               \
00407                                         Throw(inException);                                                                                                     \
00408                                 }                                                                                                                                               \
00409                         }
00410 
00411 #define ThrowIfError(inError, inException, inMessage)                                                                   \
00412                         {                                                                                                                                                       \
00413                                 SInt32 __Err = (inError);                                                                                               \
00414                                 if(__Err != 0)                                                                                                                  \
00415                                 {                                                                                                                                               \
00416                                         Throw(inException);                                                                                                     \
00417                                 }                                                                                                                                               \
00418                         }
00419 
00420 #if TARGET_OS_WIN32
00421 #define ThrowIfWinError(inError, inException, inMessage)                                                                \
00422                         {                                                                                                                                                       \
00423                                 HRESULT __Err = (inError);                                                                                              \
00424                                 if(FAILED(__Err))                                                                                                               \
00425                                 {                                                                                                                                               \
00426                                         Throw(inException);                                                                                                     \
00427                                 }                                                                                                                                               \
00428                         }
00429 #endif
00430 
00431 #define SubclassResponsibility(inMethodName, inException)                                                               \
00432                         {                                                                                                                                                       \
00433                                 Throw(inException);                                                                                                             \
00434                         }
00435 
00436 #endif  //      defined(__cplusplus)
00437 
00438 #endif  //  DEBUG || CoreAudio_Debug
00439 
00440 #endif