Commit fde3a27d authored by David Reid's avatar David Reid

Add support for customizing pthread priorities at compile time.

Use the MA_PTHREAD_REALTTIME_THREAD_PRIORITY define.
parent 766a155f
......@@ -16147,16 +16147,25 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority
if (priority == ma_thread_priority_idle) {
sched.sched_priority = priorityMin;
} else if (priority == ma_thread_priority_realtime) {
#if defined(MA_PTHREAD_REALTTIME_THREAD_PRIORITY)
{
sched.sched_priority = MA_PTHREAD_REALTTIME_THREAD_PRIORITY;
}
#else
{
sched.sched_priority = priorityMax;
}
#endif
} else {
sched.sched_priority += ((int)priority + 5) * priorityStep; /* +5 because the lowest priority is -5. */
}
if (sched.sched_priority < priorityMin) {
sched.sched_priority = priorityMin;
}
if (sched.sched_priority > priorityMax) {
sched.sched_priority = priorityMax;
}
}
/* I'm not treating a failure of setting the priority as a critical error so not aborting on failure here. */
if (pthread_attr_setschedparam(&attr, &sched) == 0) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment