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 ); \
Functions to assist in measuring the CPU utilization of a callback stream. Used to implement the Pa_G...
PaError PaUtil_CancelThreading(PaUtilThreading *threading, int wait, PaError *exitResult)
Definition pa_unix_util.c:196
PaError PaUnixMutex_Terminate(PaUnixMutex *self)
Definition pa_unix_util.c:523
PaError PaUnixThread_New(PaUnixThread *self, void *(*threadFunc)(void *), void *threadArg, PaTime waitForChild, int rtSched)
Definition pa_unix_util.c:276
PaError PaUnixMutex_Lock(PaUnixMutex *self)
Definition pa_unix_util.c:535
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 PaUnixMutex_Unlock(PaUnixMutex *self)
Definition pa_unix_util.c:553
PaError PaUnixThreading_Initialize(void)
Definition pa_unix_util.c:247
PaError PaUnixThread_NotifyParent(PaUnixThread *self)
Definition pa_unix_util.c:492
pthread_t paUnixMainThread
Definition pa_unix_util.c:244
int PaUnixThread_StopRequested(PaUnixThread *self)
Definition pa_unix_util.c:511
PaError PaUnixMutex_Initialize(PaUnixMutex *self)
Definition pa_unix_util.c:516
PaError PaUtil_StartThreading(PaUtilThreading *threading, void *(*threadRoutine)(void *), void *data)
Definition pa_unix_util.c:190
PaError PaUnixThread_PrepareNotify(PaUnixThread *self)
Definition pa_unix_util.c:480
PaError PaUtil_InitializeThreading(PaUtilThreading *threading)
Definition pa_unix_util.c:180
Prototypes for utility functions used by PortAudio implementations.
int PaError
Definition portaudio.h:122
double PaTime
Definition portaudio.h:465
Definition pa_unix_util.h:149
pthread_mutex_t mtx
Definition pa_unix_util.h:150
Definition pa_unix_util.h:159
int parentWaiting
Definition pa_unix_util.h:161
pthread_cond_t cond
Definition pa_unix_util.h:165
int stopRequested
Definition pa_unix_util.h:162
volatile sig_atomic_t stopRequest
Definition pa_unix_util.h:167
PaUnixMutex mtx
Definition pa_unix_util.h:164
PaUtilClockId condClockId
Definition pa_unix_util.h:166
pthread_t thread
Definition pa_unix_util.h:160
int locked
Definition pa_unix_util.h:163
Definition pa_unix_util.h:123
pthread_t callbackThread
Definition pa_unix_util.h:124