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_ON_ERROR(expr, code, _on_error) \
71 if( UNLIKELY( (expr) == 0 ) ) \
73 PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " PA_STRINGIZE( __LINE__ ) "\n" )); \
80 #define PA_UNLESS(expr, code) PA_UNLESS_ON_ERROR(expr, code, goto error)
83 #define PA_UNLESS_NO_GOTO(expr, code) PA_UNLESS_ON_ERROR(expr, code, (void)0)
88 #define PA_ENSURE_ON_ERROR(expr, _on_error) \
90 if( UNLIKELY( (paUtilErr_ = (expr)) < paNoError ) ) \
92 PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " PA_STRINGIZE( __LINE__ ) "\n" )); \
93 result = paUtilErr_; \
99 #define PA_ENSURE(expr) PA_ENSURE_ON_ERROR(expr, goto error)
102 #define PA_ENSURE_NO_GOTO(expr) PA_ENSURE_ON_ERROR(expr, (void)0)
104 #define PA_ASSERT_CALL(expr, success) \
105 paUtilErr_ = (expr); \
106 assert( success == paUtilErr_ );
108 #define PA_ENSURE_SYSTEM(expr, success) \
110 if( UNLIKELY( (paUtilErr_ = (expr)) != success ) ) \
113 if( pthread_equal(pthread_self(), paUnixMainThread) ) \
115 PaUtil_SetLastHostErrorInfo( paALSA, paUtilErr_, strerror( paUtilErr_ ) ); \
117 PaUtil_DebugPrint( "Expression '" #expr "' failed in '" __FILE__ "', line: " PA_STRINGIZE( __LINE__ ) "\n" ); \
118 result = paUnanticipatedHostError; \
183 #define PaUnixThreading_EXIT(result) \
185 PaError* pres = NULL; \
186 if( paNoError != (result) ) \
188 pres = malloc( sizeof (PaError) ); \
191 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:123
PaError PaUtil_InitializeThreading(PaUtilThreading *threading)
Definition: pa_unix_util.c:180
int locked
Definition: pa_unix_util.h:163
Definition: pa_unix_util.h:148
int parentWaiting
Definition: pa_unix_util.h:161
pthread_t thread
Definition: pa_unix_util.h:160
int stopRequested
Definition: pa_unix_util.h:162
PaUnixMutex mtx
Definition: pa_unix_util.h:164
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:165
pthread_mutex_t mtx
Definition: pa_unix_util.h:150
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:124
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:167
Definition: pa_unix_util.h:158
PaUtilClockId condClockId
Definition: pa_unix_util.h:166