mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-02 16:08:30 +00:00
Added SDL_THREAD_PRIORITY_TIME_CRITICAL
This commit is contained in:
@@ -651,7 +651,7 @@ SDL_RunAudio(void *devicep)
|
||||
SDL_assert(!device->iscapture);
|
||||
|
||||
/* The audio mixing is always a high priority thread */
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
||||
|
||||
/* Perform any thread setup */
|
||||
device->threadid = SDL_ThreadID();
|
||||
|
@@ -97,6 +97,8 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
||||
if (priority == SDL_THREAD_PRIORITY_LOW) {
|
||||
value = 19;
|
||||
} else if (priority == SDL_THREAD_PRIORITY_HIGH) {
|
||||
value = -10;
|
||||
} else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
|
||||
value = -20;
|
||||
} else {
|
||||
value = 0;
|
||||
|
@@ -275,6 +275,8 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
||||
if (priority == SDL_THREAD_PRIORITY_LOW) {
|
||||
value = 19;
|
||||
} else if (priority == SDL_THREAD_PRIORITY_HIGH) {
|
||||
value = -10;
|
||||
} else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
|
||||
value = -20;
|
||||
} else {
|
||||
value = 0;
|
||||
@@ -290,12 +292,15 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
||||
}
|
||||
if (priority == SDL_THREAD_PRIORITY_LOW) {
|
||||
sched.sched_priority = sched_get_priority_min(policy);
|
||||
} else if (priority == SDL_THREAD_PRIORITY_HIGH) {
|
||||
} else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
|
||||
sched.sched_priority = sched_get_priority_max(policy);
|
||||
} else {
|
||||
int min_priority = sched_get_priority_min(policy);
|
||||
int max_priority = sched_get_priority_max(policy);
|
||||
sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
|
||||
if (priority == SDL_THREAD_PRIORITY_HIGH) {
|
||||
sched.sched_priority += (max_priority - min_priority) / 4);
|
||||
}
|
||||
}
|
||||
if (pthread_setschedparam(thread, policy, &sched) != 0) {
|
||||
return SDL_SetError("pthread_setschedparam() failed");
|
||||
|
@@ -231,6 +231,8 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
||||
value = THREAD_PRIORITY_LOWEST;
|
||||
} else if (priority == SDL_THREAD_PRIORITY_HIGH) {
|
||||
value = THREAD_PRIORITY_HIGHEST;
|
||||
} else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
|
||||
value = THREAD_PRIORITY_TIME_CRITICAL;
|
||||
} else {
|
||||
value = THREAD_PRIORITY_NORMAL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user