Add support for customizing pthread priorities at compile time.

Use the MA_PTHREAD_REALTTIME_THREAD_PRIORITY define.
This commit is contained in:
David Reid
2023-12-23 09:21:13 +10:00
parent 766a155fb3
commit fde3a27d93
+10 -1
View File
@@ -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) {