44 #ifndef PA_UNIX_UTIL_H
45 #define PA_UNIX_UTIL_H
59 #define PA_MIN(x,y) ( (x) < (y) ? (x) : (y) )
60 #define PA_MAX(x,y) ( (x) > (y) ? (x) : (y) )
63 #if defined __GNUC__ && __GNUC__ >= 3
64 #define UNLIKELY(expr) __builtin_expect( (expr), 0 )
66 #define UNLIKELY(expr) (expr)
69 #define PA_UNLESS(expr, code) \
71 if( UNLIKELY( (expr) == 0 ) ) \
73 PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " PA_STRINGIZE( __LINE__ ) "\n" )); \
82 #define PA_ENSURE(expr) \
84 if( UNLIKELY( (paUtilErr_ = (expr)) < paNoError ) ) \
86 PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " PA_STRINGIZE( __LINE__ ) "\n" )); \
87 result = paUtilErr_; \
92 #define PA_ASSERT_CALL(expr, success) \
93 paUtilErr_ = (expr); \
94 assert( success == paUtilErr_ );
96 #define PA_ENSURE_SYSTEM(expr, success) \
98 if( UNLIKELY( (paUtilErr_ = (expr)) != success ) ) \
101 if( pthread_equal(pthread_self(), paUnixMainThread) ) \
103 PaUtil_SetLastHostErrorInfo( paALSA, paUtilErr_, strerror( paUtilErr_ ) ); \
105 PaUtil_DebugPrint( "Expression '" #expr "' failed in '" __FILE__ "', line: " PA_STRINGIZE( __LINE__ ) "\n" ); \
106 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:186
PaError PaUnixThread_Terminate(PaUnixThread *self, int wait, PaError *exitResult)
Definition: pa_unix_util.c:418
PaError PaUnixThread_NotifyParent(PaUnixThread *self)
Definition: pa_unix_util.c:492
PaError PaUnixMutex_Initialize(PaUnixMutex *self)
Definition: pa_unix_util.c:516
PaError PaUnixThreading_Initialize(void)
Definition: pa_unix_util.c:247
Definition: pa_unix_util.h:111
PaError PaUtil_InitializeThreading(PaUtilThreading *threading)
Definition: pa_unix_util.c:180
int locked
Definition: pa_unix_util.h:151
Definition: pa_unix_util.h:136
int parentWaiting
Definition: pa_unix_util.h:149
pthread_t thread
Definition: pa_unix_util.h:148
int stopRequested
Definition: pa_unix_util.h:150
PaUnixMutex mtx
Definition: pa_unix_util.h:152
int PaUnixThread_StopRequested(PaUnixThread *self)
Definition: pa_unix_util.c:511
pthread_t paUnixMainThread
Definition: pa_unix_util.c:244
#define PaUtilClockId
Definition: pa_pthread_util.h:85
pthread_cond_t cond
Definition: pa_unix_util.h:153
pthread_mutex_t mtx
Definition: pa_unix_util.h:138
int PaError
Definition: portaudio.h:122
PaError PaUnixMutex_Terminate(PaUnixMutex *self)
Definition: pa_unix_util.c:523
PaError PaUtil_StartThreading(PaUtilThreading *threading, void *(*threadRoutine)(void *), void *data)
Definition: pa_unix_util.c:190
PaError PaUnixThread_New(PaUnixThread *self, void *(*threadFunc)(void *), void *threadArg, PaTime waitForChild, int rtSched)
Definition: pa_unix_util.c:276
PaError PaUnixMutex_Unlock(PaUnixMutex *self)
Definition: pa_unix_util.c:553
PaError PaUtil_CancelThreading(PaUtilThreading *threading, int wait, PaError *exitResult)
Definition: pa_unix_util.c:196
pthread_t callbackThread
Definition: pa_unix_util.h:112
PaError PaUnixThread_PrepareNotify(PaUnixThread *self)
Definition: pa_unix_util.c:480
Prototypes for utility functions used by PortAudio implementations.
PaError PaUnixMutex_Lock(PaUnixMutex *self)
Definition: pa_unix_util.c:535
Functions to assist in measuring the CPU utilization of a callback stream. Used to implement the Pa_G...
double PaTime
Definition: portaudio.h:465
volatile sig_atomic_t stopRequest
Definition: pa_unix_util.h:155
Definition: pa_unix_util.h:146
PaUtilClockId condClockId
Definition: pa_unix_util.h:154