Rename SDL_SetThreadPriority() to SDL_SetCurrentThreadPriority()

Fixes https://github.com/libsdl-org/SDL/issues/11055
This commit is contained in:
Sam Lantinga 2024-10-04 08:57:03 -07:00
parent 69196ab30d
commit fe2880fcda
17 changed files with 30 additions and 22 deletions

View File

@ -3705,3 +3705,8 @@ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAltern
- SDL_IsAndroidTV - SDL_IsAndroidTV
+ SDL_IsTV + SDL_IsTV
(...) (...)
@@
@@
- SDL_SetThreadPriority
+ SDL_SetCurrentThreadPriority
(...)

View File

@ -2028,6 +2028,7 @@ SDL_CreateThread and SDL_CreateThreadWithProperties now take beginthread/endthre
SDL_GetTLS() and SDL_SetTLS() take a pointer to a TLS ID, and will automatically initialize it in a thread-safe way as needed. SDL_GetTLS() and SDL_SetTLS() take a pointer to a TLS ID, and will automatically initialize it in a thread-safe way as needed.
The following functions have been renamed: The following functions have been renamed:
* SDL_SetThreadPriority() => SDL_SetCurrentThreadPriority()
* SDL_TLSCleanup() => SDL_CleanupTLS() * SDL_TLSCleanup() => SDL_CleanupTLS()
* SDL_TLSGet() => SDL_GetTLS() * SDL_TLSGet() => SDL_GetTLS()
* SDL_TLSSet() => SDL_SetTLS(), returns bool * SDL_TLSSet() => SDL_SetTLS(), returns bool

View File

@ -3002,7 +3002,7 @@ extern "C" {
* - "1": Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling * - "1": Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling
* policy * policy
* *
* This hint should be set before calling SDL_SetThreadPriority() * This hint should be set before calling SDL_SetCurrentThreadPriority()
* *
* \since This hint is available since SDL 3.0.0. * \since This hint is available since SDL 3.0.0.
*/ */
@ -3010,9 +3010,9 @@ extern "C" {
/** /**
* A string specifying additional information to use with * A string specifying additional information to use with
* SDL_SetThreadPriority. * SDL_SetCurrentThreadPriority.
* *
* By default SDL_SetThreadPriority will make appropriate system changes in * By default SDL_SetCurrentThreadPriority will make appropriate system changes in
* order to apply a thread priority. For example on systems using pthreads the * order to apply a thread priority. For example on systems using pthreads the
* scheduler policy is changed automatically to a policy that works well with * scheduler policy is changed automatically to a policy that works well with
* a given priority. Code which has specific requirements can override SDL's * a given priority. Code which has specific requirements can override SDL's
@ -3023,9 +3023,9 @@ extern "C" {
* *
* On Linux, the kernel may send SIGKILL to realtime tasks which exceed the * On Linux, the kernel may send SIGKILL to realtime tasks which exceed the
* distro configured execution budget for rtkit. This budget can be queried * distro configured execution budget for rtkit. This budget can be queried
* through RLIMIT_RTTIME after calling SDL_SetThreadPriority(). * through RLIMIT_RTTIME after calling SDL_SetCurrentThreadPriority().
* *
* This hint should be set before calling SDL_SetThreadPriority() * This hint should be set before calling SDL_SetCurrentThreadPriority()
* *
* \since This hint is available since SDL 3.0.0. * \since This hint is available since SDL 3.0.0.
*/ */

View File

@ -644,6 +644,7 @@
#define SDL_iPhoneSetEventPump SDL_SetiOSEventPump #define SDL_iPhoneSetEventPump SDL_SetiOSEventPump
/* ##SDL_thread.h */ /* ##SDL_thread.h */
#define SDL_SetThreadPriority SDL_SetCurrentThreadPriority
#define SDL_TLSCleanup SDL_CleanupTLS #define SDL_TLSCleanup SDL_CleanupTLS
#define SDL_TLSGet SDL_GetTLS #define SDL_TLSGet SDL_GetTLS
#define SDL_TLSSet SDL_SetTLS #define SDL_TLSSet SDL_SetTLS
@ -1281,6 +1282,7 @@
#define SDL_iPhoneSetEventPump SDL_iPhoneSetEventPump_renamed_SDL_iOSSetEventPump #define SDL_iPhoneSetEventPump SDL_iPhoneSetEventPump_renamed_SDL_iOSSetEventPump
/* ##SDL_thread.h */ /* ##SDL_thread.h */
#define SDL_SetThreadPriority SDL_SetThreadPriority_renamed_SDL_SetCurrentThreadPriority
#define SDL_TLSCleanup SDL_TLSCleanup_renamed_SDL_CleanupTLS #define SDL_TLSCleanup SDL_TLSCleanup_renamed_SDL_CleanupTLS
#define SDL_TLSGet SDL_TLSGet_renamed_SDL_GetTLS #define SDL_TLSGet SDL_TLSGet_renamed_SDL_GetTLS
#define SDL_TLSSet SDL_TLSSet_renamed_SDL_SetTLS #define SDL_TLSSet SDL_TLSSet_renamed_SDL_SetTLS

View File

@ -89,7 +89,7 @@ typedef SDL_AtomicInt SDL_TLSID;
* *
* SDL will make system changes as necessary in order to apply the thread * SDL will make system changes as necessary in order to apply the thread
* priority. Code which attempts to control thread state related to priority * priority. Code which attempts to control thread state related to priority
* should be aware that calling SDL_SetThreadPriority may alter such state. * should be aware that calling SDL_SetCurrentThreadPriority may alter such state.
* SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of this * SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of this
* behavior. * behavior.
* *
@ -385,7 +385,7 @@ extern SDL_DECLSPEC SDL_ThreadID SDLCALL SDL_GetThreadID(SDL_Thread *thread);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); extern SDL_DECLSPEC bool SDLCALL SDL_SetCurrentThreadPriority(SDL_ThreadPriority priority);
/** /**
* Wait for a thread to finish. * Wait for a thread to finish.

View File

@ -781,7 +781,7 @@ static void SDL_AudioFreeDeviceHandle_Default(SDL_AudioDevice *device) { /* no-o
static void SDL_AudioThreadInit_Default(SDL_AudioDevice *device) static void SDL_AudioThreadInit_Default(SDL_AudioDevice *device)
{ {
SDL_SetThreadPriority(device->recording ? SDL_THREAD_PRIORITY_HIGH : SDL_THREAD_PRIORITY_TIME_CRITICAL); SDL_SetCurrentThreadPriority(device->recording ? SDL_THREAD_PRIORITY_HIGH : SDL_THREAD_PRIORITY_TIME_CRITICAL);
} }
static void SDL_AudioDetectDevices_Default(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording) static void SDL_AudioDetectDevices_Default(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)

View File

@ -823,7 +823,7 @@ static SDL_Thread *ALSA_hotplug_thread;
static int SDLCALL ALSA_HotplugThread(void *arg) static int SDLCALL ALSA_HotplugThread(void *arg)
{ {
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW); SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_LOW);
while (!SDL_GetAtomicInt(&ALSA_hotplug_shutdown)) { while (!SDL_GetAtomicInt(&ALSA_hotplug_shutdown)) {
// Block awhile before checking again, unless we're told to stop. // Block awhile before checking again, unless we're told to stop.

View File

@ -892,7 +892,7 @@ static int SDLCALL HotplugThread(void *data)
{ {
pa_operation *op; pa_operation *op;
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW); SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_LOW);
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
PULSEAUDIO_pa_context_set_subscribe_callback(pulseaudio_context, HotplugCallback, NULL); PULSEAUDIO_pa_context_set_subscribe_callback(pulseaudio_context, HotplugCallback, NULL);

View File

@ -143,7 +143,7 @@ void WASAPI_PlatformThreadInit(SDL_AudioDevice *device)
DWORD idx = 0; DWORD idx = 0;
device->hidden->task = pAvSetMmThreadCharacteristicsW(L"Pro Audio", &idx); device->hidden->task = pAvSetMmThreadCharacteristicsW(L"Pro Audio", &idx);
} else { } else {
SDL_SetThreadPriority(device->recording ? SDL_THREAD_PRIORITY_HIGH : SDL_THREAD_PRIORITY_TIME_CRITICAL); SDL_SetCurrentThreadPriority(device->recording ? SDL_THREAD_PRIORITY_HIGH : SDL_THREAD_PRIORITY_TIME_CRITICAL);
} }
} }

View File

@ -785,7 +785,7 @@ void SDL_CameraThreadSetup(SDL_Camera *device)
}*/ }*/
#else #else
// The camera capture is always a high priority thread // The camera capture is always a high priority thread
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH); SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_HIGH);
#endif #endif
} }

View File

@ -600,8 +600,8 @@ SDL3_0.0.0 {
SDL_IsJoystickHaptic; SDL_IsJoystickHaptic;
SDL_IsJoystickVirtual; SDL_IsJoystickVirtual;
SDL_IsMouseHaptic; SDL_IsMouseHaptic;
SDL_IsTablet;
SDL_IsTV; SDL_IsTV;
SDL_IsTablet;
SDL_JoystickConnected; SDL_JoystickConnected;
SDL_JoystickEventsEnabled; SDL_JoystickEventsEnabled;
SDL_KillProcess; SDL_KillProcess;
@ -796,6 +796,7 @@ SDL3_0.0.0 {
SDL_SetBooleanProperty; SDL_SetBooleanProperty;
SDL_SetClipboardData; SDL_SetClipboardData;
SDL_SetClipboardText; SDL_SetClipboardText;
SDL_SetCurrentThreadPriority;
SDL_SetCursor; SDL_SetCursor;
SDL_SetEnvironmentVariable; SDL_SetEnvironmentVariable;
SDL_SetError; SDL_SetError;
@ -869,7 +870,6 @@ SDL3_0.0.0 {
SDL_SetTextureColorMod; SDL_SetTextureColorMod;
SDL_SetTextureColorModFloat; SDL_SetTextureColorModFloat;
SDL_SetTextureScaleMode; SDL_SetTextureScaleMode;
SDL_SetThreadPriority;
SDL_SetWindowAlwaysOnTop; SDL_SetWindowAlwaysOnTop;
SDL_SetWindowAspectRatio; SDL_SetWindowAspectRatio;
SDL_SetWindowBordered; SDL_SetWindowBordered;

View File

@ -625,8 +625,8 @@
#define SDL_IsJoystickHaptic SDL_IsJoystickHaptic_REAL #define SDL_IsJoystickHaptic SDL_IsJoystickHaptic_REAL
#define SDL_IsJoystickVirtual SDL_IsJoystickVirtual_REAL #define SDL_IsJoystickVirtual SDL_IsJoystickVirtual_REAL
#define SDL_IsMouseHaptic SDL_IsMouseHaptic_REAL #define SDL_IsMouseHaptic SDL_IsMouseHaptic_REAL
#define SDL_IsTablet SDL_IsTablet_REAL
#define SDL_IsTV SDL_IsTV_REAL #define SDL_IsTV SDL_IsTV_REAL
#define SDL_IsTablet SDL_IsTablet_REAL
#define SDL_JoystickConnected SDL_JoystickConnected_REAL #define SDL_JoystickConnected SDL_JoystickConnected_REAL
#define SDL_JoystickEventsEnabled SDL_JoystickEventsEnabled_REAL #define SDL_JoystickEventsEnabled SDL_JoystickEventsEnabled_REAL
#define SDL_KillProcess SDL_KillProcess_REAL #define SDL_KillProcess SDL_KillProcess_REAL
@ -821,6 +821,7 @@
#define SDL_SetBooleanProperty SDL_SetBooleanProperty_REAL #define SDL_SetBooleanProperty SDL_SetBooleanProperty_REAL
#define SDL_SetClipboardData SDL_SetClipboardData_REAL #define SDL_SetClipboardData SDL_SetClipboardData_REAL
#define SDL_SetClipboardText SDL_SetClipboardText_REAL #define SDL_SetClipboardText SDL_SetClipboardText_REAL
#define SDL_SetCurrentThreadPriority SDL_SetCurrentThreadPriority_REAL
#define SDL_SetCursor SDL_SetCursor_REAL #define SDL_SetCursor SDL_SetCursor_REAL
#define SDL_SetEnvironmentVariable SDL_SetEnvironmentVariable_REAL #define SDL_SetEnvironmentVariable SDL_SetEnvironmentVariable_REAL
#define SDL_SetError SDL_SetError_REAL #define SDL_SetError SDL_SetError_REAL
@ -894,7 +895,6 @@
#define SDL_SetTextureColorMod SDL_SetTextureColorMod_REAL #define SDL_SetTextureColorMod SDL_SetTextureColorMod_REAL
#define SDL_SetTextureColorModFloat SDL_SetTextureColorModFloat_REAL #define SDL_SetTextureColorModFloat SDL_SetTextureColorModFloat_REAL
#define SDL_SetTextureScaleMode SDL_SetTextureScaleMode_REAL #define SDL_SetTextureScaleMode SDL_SetTextureScaleMode_REAL
#define SDL_SetThreadPriority SDL_SetThreadPriority_REAL
#define SDL_SetWindowAlwaysOnTop SDL_SetWindowAlwaysOnTop_REAL #define SDL_SetWindowAlwaysOnTop SDL_SetWindowAlwaysOnTop_REAL
#define SDL_SetWindowAspectRatio SDL_SetWindowAspectRatio_REAL #define SDL_SetWindowAspectRatio SDL_SetWindowAspectRatio_REAL
#define SDL_SetWindowBordered SDL_SetWindowBordered_REAL #define SDL_SetWindowBordered SDL_SetWindowBordered_REAL

View File

@ -645,8 +645,8 @@ SDL_DYNAPI_PROC(bool,SDL_IsGamepad,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_IsJoystickHaptic,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(bool,SDL_IsJoystickHaptic,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_IsJoystickVirtual,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(bool,SDL_IsJoystickVirtual,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_IsMouseHaptic,(void),(),return) SDL_DYNAPI_PROC(bool,SDL_IsMouseHaptic,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_IsTablet,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_IsTV,(void),(),return) SDL_DYNAPI_PROC(bool,SDL_IsTV,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_IsTablet,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_JoystickConnected,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(bool,SDL_JoystickConnected,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_JoystickEventsEnabled,(void),(),return) SDL_DYNAPI_PROC(bool,SDL_JoystickEventsEnabled,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_KillProcess,(SDL_Process *a, bool b),(a,b),return) SDL_DYNAPI_PROC(bool,SDL_KillProcess,(SDL_Process *a, bool b),(a,b),return)
@ -832,6 +832,7 @@ SDL_DYNAPI_PROC(bool,SDL_SetAudioStreamPutCallback,(SDL_AudioStream *a, SDL_Audi
SDL_DYNAPI_PROC(bool,SDL_SetBooleanProperty,(SDL_PropertiesID a, const char *b, bool c),(a,b,c),return) SDL_DYNAPI_PROC(bool,SDL_SetBooleanProperty,(SDL_PropertiesID a, const char *b, bool c),(a,b,c),return)
SDL_DYNAPI_PROC(bool,SDL_SetClipboardData,(SDL_ClipboardDataCallback a, SDL_ClipboardCleanupCallback b, void *c, const char **d, size_t e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(bool,SDL_SetClipboardData,(SDL_ClipboardDataCallback a, SDL_ClipboardCleanupCallback b, void *c, const char **d, size_t e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(bool,SDL_SetClipboardText,(const char *a),(a),return) SDL_DYNAPI_PROC(bool,SDL_SetClipboardText,(const char *a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_SetCurrentThreadPriority,(SDL_ThreadPriority a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_SetCursor,(SDL_Cursor *a),(a),return) SDL_DYNAPI_PROC(bool,SDL_SetCursor,(SDL_Cursor *a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_SetEnvironmentVariable,(SDL_Environment *a, const char *b, const char *c, bool d),(a,b,c,d),return) SDL_DYNAPI_PROC(bool,SDL_SetEnvironmentVariable,(SDL_Environment *a, const char *b, const char *c, bool d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_SetEventEnabled,(Uint32 a, bool b),(a,b),) SDL_DYNAPI_PROC(void,SDL_SetEventEnabled,(Uint32 a, bool b),(a,b),)
@ -904,7 +905,6 @@ SDL_DYNAPI_PROC(bool,SDL_SetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode b),(
SDL_DYNAPI_PROC(bool,SDL_SetTextureColorMod,(SDL_Texture *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return) SDL_DYNAPI_PROC(bool,SDL_SetTextureColorMod,(SDL_Texture *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(bool,SDL_SetTextureColorModFloat,(SDL_Texture *a, float b, float c, float d),(a,b,c,d),return) SDL_DYNAPI_PROC(bool,SDL_SetTextureColorModFloat,(SDL_Texture *a, float b, float c, float d),(a,b,c,d),return)
SDL_DYNAPI_PROC(bool,SDL_SetTextureScaleMode,(SDL_Texture *a, SDL_ScaleMode b),(a,b),return) SDL_DYNAPI_PROC(bool,SDL_SetTextureScaleMode,(SDL_Texture *a, SDL_ScaleMode b),(a,b),return)
SDL_DYNAPI_PROC(bool,SDL_SetThreadPriority,(SDL_ThreadPriority a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_SetWindowAlwaysOnTop,(SDL_Window *a, bool b),(a,b),return) SDL_DYNAPI_PROC(bool,SDL_SetWindowAlwaysOnTop,(SDL_Window *a, bool b),(a,b),return)
SDL_DYNAPI_PROC(bool,SDL_SetWindowAspectRatio,(SDL_Window *a, float b, float c),(a,b,c),return) SDL_DYNAPI_PROC(bool,SDL_SetWindowAspectRatio,(SDL_Window *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(bool,SDL_SetWindowBordered,(SDL_Window *a, bool b),(a,b),return) SDL_DYNAPI_PROC(bool,SDL_SetWindowBordered,(SDL_Window *a, bool b),(a,b),return)

View File

@ -59,7 +59,7 @@ static int SDLCALL SDL_HIDAPI_RumbleThread(void *data)
{ {
SDL_HIDAPI_RumbleContext *ctx = (SDL_HIDAPI_RumbleContext *)data; SDL_HIDAPI_RumbleContext *ctx = (SDL_HIDAPI_RumbleContext *)data;
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH); SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_HIGH);
while (SDL_GetAtomicInt(&ctx->running)) { while (SDL_GetAtomicInt(&ctx->running)) {
SDL_HIDAPI_RumbleRequest *request = NULL; SDL_HIDAPI_RumbleRequest *request = NULL;

View File

@ -62,7 +62,7 @@ static int SDLCALL SDL_ANDROID_SensorThread(void *data)
ASensorEvent event; ASensorEvent event;
struct android_poll_source *source; struct android_poll_source *source;
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH); SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_HIGH);
SDL_sensor_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); SDL_sensor_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
SDL_SignalSemaphore(ctx->sem); SDL_SignalSemaphore(ctx->sem);

View File

@ -439,7 +439,7 @@ const char *SDL_GetThreadName(SDL_Thread *thread)
} }
} }
bool SDL_SetThreadPriority(SDL_ThreadPriority priority) bool SDL_SetCurrentThreadPriority(SDL_ThreadPriority priority)
{ {
return SDL_SYS_SetThreadPriority(priority); return SDL_SYS_SetThreadPriority(priority);
} }

View File

@ -66,7 +66,7 @@ ThreadFunc(void *data)
SDL_Log("Thread '%s' is alive!\n", (char *)data); SDL_Log("Thread '%s' is alive!\n", (char *)data);
if (testprio) { if (testprio) {
SDL_Log("SDL_SetThreadPriority(%s):%d\n", getprioritystr(prio), SDL_SetThreadPriority(prio)); SDL_Log("SDL_SetCurrentThreadPriority(%s):%d\n", getprioritystr(prio), SDL_SetCurrentThreadPriority(prio));
if (++prio > SDL_THREAD_PRIORITY_TIME_CRITICAL) { if (++prio > SDL_THREAD_PRIORITY_TIME_CRITICAL) {
prio = SDL_THREAD_PRIORITY_LOW; prio = SDL_THREAD_PRIORITY_LOW;
} }