44 #ifndef PA_UNIX_UTIL_H
45 #define PA_UNIX_UTIL_H
57 #define PA_MIN(x,y) ( (x) < (y) ? (x) : (y) )
58 #define PA_MAX(x,y) ( (x) > (y) ? (x) : (y) )
61 #if defined __GNUC__ && __GNUC__ >= 3
62 #define UNLIKELY(expr) __builtin_expect( (expr), 0 )
64 #define UNLIKELY(expr) (expr)
67 #define STRINGIZE_HELPER(expr) #expr
68 #define STRINGIZE(expr) STRINGIZE_HELPER(expr)
70 #define PA_UNLESS(expr, code) \
72 if( UNLIKELY( (expr) == 0 ) ) \
74 PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" )); \
83 #define PA_ENSURE(expr) \
85 if( UNLIKELY( (paUtilErr_ = (expr)) < paNoError ) ) \
87 PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" )); \
88 result = paUtilErr_; \
93 #define PA_ASSERT_CALL(expr, success) \
94 paUtilErr_ = (expr); \
95 assert( success == paUtilErr_ );
97 #define PA_ENSURE_SYSTEM(expr, success) \
99 if( UNLIKELY( (paUtilErr_ = (expr)) != success ) ) \
102 if( pthread_equal(pthread_self(), paUnixMainThread) ) \
104 PaUtil_SetLastHostErrorInfo( paALSA, paUtilErr_, strerror( paUtilErr_ ) ); \
106 PaUtil_DebugPrint( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" ); \
107 result = paUnanticipatedHostError; \
171 #define PaUnixThreading_EXIT(result) \
173 PaError* pres = NULL; \
174 if( paNoError != (result) ) \
176 pres = malloc( sizeof (PaError) ); \
179 pthread_exit( pres ); \
void PaUtil_TerminateThreading(PaUtilThreading *threading)
Definition: pa_unix_util.c:178
PaError PaUnixThread_Terminate(PaUnixThread *self, int wait, PaError *exitResult)
Definition: pa_unix_util.c:402
PaError PaUnixThread_NotifyParent(PaUnixThread *self)
Definition: pa_unix_util.c:476
PaError PaUnixMutex_Initialize(PaUnixMutex *self)
Definition: pa_unix_util.c:500
Definition: pa_unix_util.h:112
PaError PaUtil_InitializeThreading(PaUtilThreading *threading)
Definition: pa_unix_util.c:172
int locked
Definition: pa_unix_util.h:152
Definition: pa_unix_util.h:137
PaError PaUnixThreading_Initialize()
Definition: pa_unix_util.c:239
int parentWaiting
Definition: pa_unix_util.h:150
pthread_t thread
Definition: pa_unix_util.h:149
int stopRequested
Definition: pa_unix_util.h:151
PaUnixMutex mtx
Definition: pa_unix_util.h:153
int PaUnixThread_StopRequested(PaUnixThread *self)
Definition: pa_unix_util.c:495
pthread_t paUnixMainThread
Definition: pa_unix_util.c:236
pthread_cond_t cond
Definition: pa_unix_util.h:154
pthread_mutex_t mtx
Definition: pa_unix_util.h:139
int PaError
Definition: portaudio.h:121
PaError PaUnixMutex_Terminate(PaUnixMutex *self)
Definition: pa_unix_util.c:507
PaError PaUtil_StartThreading(PaUtilThreading *threading, void *(*threadRoutine)(void *), void *data)
Definition: pa_unix_util.c:182
PaError PaUnixThread_New(PaUnixThread *self, void *(*threadFunc)(void *), void *threadArg, PaTime waitForChild, int rtSched)
Definition: pa_unix_util.c:268
PaError PaUnixMutex_Unlock(PaUnixMutex *self)
Definition: pa_unix_util.c:537
PaError PaUtil_CancelThreading(PaUtilThreading *threading, int wait, PaError *exitResult)
Definition: pa_unix_util.c:188
pthread_t callbackThread
Definition: pa_unix_util.h:113
PaError PaUnixThread_PrepareNotify(PaUnixThread *self)
Definition: pa_unix_util.c:464
PaError PaUnixMutex_Lock(PaUnixMutex *self)
Definition: pa_unix_util.c:519
Functions to assist in measuring the CPU utilization of a callback stream. Used to implement the Pa_G...
double PaTime
Definition: portaudio.h:460
volatile sig_atomic_t stopRequest
Definition: pa_unix_util.h:155
Definition: pa_unix_util.h:147