mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Add support for customizing pthread priorities at compile time.
Use the MA_PTHREAD_REALTTIME_THREAD_PRIORITY define.
This commit is contained in:
+10
-1
@@ -16147,16 +16147,25 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority
|
|||||||
if (priority == ma_thread_priority_idle) {
|
if (priority == ma_thread_priority_idle) {
|
||||||
sched.sched_priority = priorityMin;
|
sched.sched_priority = priorityMin;
|
||||||
} else if (priority == ma_thread_priority_realtime) {
|
} 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;
|
sched.sched_priority = priorityMax;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
sched.sched_priority += ((int)priority + 5) * priorityStep; /* +5 because the lowest priority is -5. */
|
sched.sched_priority += ((int)priority + 5) * priorityStep; /* +5 because the lowest priority is -5. */
|
||||||
|
}
|
||||||
|
|
||||||
if (sched.sched_priority < priorityMin) {
|
if (sched.sched_priority < priorityMin) {
|
||||||
sched.sched_priority = priorityMin;
|
sched.sched_priority = priorityMin;
|
||||||
}
|
}
|
||||||
if (sched.sched_priority > priorityMax) {
|
if (sched.sched_priority > priorityMax) {
|
||||||
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. */
|
/* 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) {
|
if (pthread_attr_setschedparam(&attr, &sched) == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user