|
|
@@ -5881,22 +5881,21 @@ bool RtApiAlsa :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne |
|
|
|
pthread_attr_t attr;
|
|
|
|
pthread_attr_init( &attr );
|
|
|
|
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE );
|
|
|
|
|
|
|
|
#ifdef SCHED_RR // Undefined with some OSes (eg: NetBSD 1.6.x with GNU Pthread)
|
|
|
|
if ( options && options->flags & RTAUDIO_SCHEDULE_REALTIME ) {
|
|
|
|
struct sched_param param;
|
|
|
|
// We previously attempted to increase the audio callback priority
|
|
|
|
// to SCHED_RR here via the attributes. However, while no errors
|
|
|
|
// were reported in doing so, it did not work. So, now this is
|
|
|
|
// done in the alsaCallbackHandler function.
|
|
|
|
stream_.callbackInfo.doRealtime = true;
|
|
|
|
int priority = options->priority;
|
|
|
|
int min = sched_get_priority_min( SCHED_RR );
|
|
|
|
int max = sched_get_priority_max( SCHED_RR );
|
|
|
|
if ( priority < min ) priority = min;
|
|
|
|
else if ( priority > max ) priority = max;
|
|
|
|
param.sched_priority = priority;
|
|
|
|
pthread_attr_setschedpolicy( &attr, SCHED_RR );
|
|
|
|
pthread_attr_setschedparam( &attr, ¶m );
|
|
|
|
stream_.callbackInfo.priority = priority;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pthread_attr_setschedpolicy( &attr, SCHED_OTHER );
|
|
|
|
#else
|
|
|
|
pthread_attr_setschedpolicy( &attr, SCHED_OTHER );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
stream_.callbackInfo.isRunning = true;
|
|
|
@@ -6314,6 +6313,14 @@ extern "C" void *alsaCallbackHandler( void *ptr ) |
|
|
|
RtApiAlsa *object = (RtApiAlsa *) info->object;
|
|
|
|
bool *isRunning = &info->isRunning;
|
|
|
|
|
|
|
|
#ifdef SCHED_RR // Undefined with some OSes (eg: NetBSD 1.6.x with GNU Pthread)
|
|
|
|
if ( &info->doRealtime ) {
|
|
|
|
pthread_t tID = pthread_self(); // ID of this thread
|
|
|
|
sched_param prio = { info->priority }; // scheduling priority of thread
|
|
|
|
pthread_setschedparam( tID, SCHED_RR, &prio );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
while ( *isRunning == true ) {
|
|
|
|
pthread_testcancel();
|
|
|
|
object->callbackEvent();
|
|
|
|