diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index 0fa0f4b94..ca2acfdf5 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -3705,3 +3705,8 @@ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAltern - SDL_IsAndroidTV + SDL_IsTV (...) +@@ +@@ +- SDL_SetThreadPriority ++ SDL_SetCurrentThreadPriority + (...) diff --git a/docs/README-migration.md b/docs/README-migration.md index fb4af6afc..08c0f2ab0 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -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. The following functions have been renamed: +* SDL_SetThreadPriority() => SDL_SetCurrentThreadPriority() * SDL_TLSCleanup() => SDL_CleanupTLS() * SDL_TLSGet() => SDL_GetTLS() * SDL_TLSSet() => SDL_SetTLS(), returns bool diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h index 88155b0cf..4055f74e0 100644 --- a/include/SDL3/SDL_hints.h +++ b/include/SDL3/SDL_hints.h @@ -3002,7 +3002,7 @@ extern "C" { * - "1": Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling * 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. */ @@ -3010,9 +3010,9 @@ extern "C" { /** * 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 * scheduler policy is changed automatically to a policy that works well with * 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 * 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. */ diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index 82b4915a4..79fb1184f 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -644,6 +644,7 @@ #define SDL_iPhoneSetEventPump SDL_SetiOSEventPump /* ##SDL_thread.h */ +#define SDL_SetThreadPriority SDL_SetCurrentThreadPriority #define SDL_TLSCleanup SDL_CleanupTLS #define SDL_TLSGet SDL_GetTLS #define SDL_TLSSet SDL_SetTLS @@ -1281,6 +1282,7 @@ #define SDL_iPhoneSetEventPump SDL_iPhoneSetEventPump_renamed_SDL_iOSSetEventPump /* ##SDL_thread.h */ +#define SDL_SetThreadPriority SDL_SetThreadPriority_renamed_SDL_SetCurrentThreadPriority #define SDL_TLSCleanup SDL_TLSCleanup_renamed_SDL_CleanupTLS #define SDL_TLSGet SDL_TLSGet_renamed_SDL_GetTLS #define SDL_TLSSet SDL_TLSSet_renamed_SDL_SetTLS diff --git a/include/SDL3/SDL_thread.h b/include/SDL3/SDL_thread.h index 526ab061d..86e9d0e9c 100644 --- a/include/SDL3/SDL_thread.h +++ b/include/SDL3/SDL_thread.h @@ -89,7 +89,7 @@ typedef SDL_AtomicInt SDL_TLSID; * * SDL will make system changes as necessary in order to apply the thread * 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 * 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. */ -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. diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index fddec476c..b232bef59 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -781,7 +781,7 @@ static void SDL_AudioFreeDeviceHandle_Default(SDL_AudioDevice *device) { /* no-o 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) diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 8b804c4b8..827b54de4 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -823,7 +823,7 @@ static SDL_Thread *ALSA_hotplug_thread; 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)) { // Block awhile before checking again, unless we're told to stop. diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 0961bdaed..240b11e35 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -892,7 +892,7 @@ static int SDLCALL HotplugThread(void *data) { 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_context_set_subscribe_callback(pulseaudio_context, HotplugCallback, NULL); diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index cd13115f2..5ef776d43 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -143,7 +143,7 @@ void WASAPI_PlatformThreadInit(SDL_AudioDevice *device) DWORD idx = 0; device->hidden->task = pAvSetMmThreadCharacteristicsW(L"Pro Audio", &idx); } 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); } } diff --git a/src/camera/SDL_camera.c b/src/camera/SDL_camera.c index 86e1fbab8..d220a3d66 100644 --- a/src/camera/SDL_camera.c +++ b/src/camera/SDL_camera.c @@ -785,7 +785,7 @@ void SDL_CameraThreadSetup(SDL_Camera *device) }*/ #else // The camera capture is always a high priority thread - SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH); + SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_HIGH); #endif } diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index f0141fbd8..ab7704b53 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -600,8 +600,8 @@ SDL3_0.0.0 { SDL_IsJoystickHaptic; SDL_IsJoystickVirtual; SDL_IsMouseHaptic; - SDL_IsTablet; SDL_IsTV; + SDL_IsTablet; SDL_JoystickConnected; SDL_JoystickEventsEnabled; SDL_KillProcess; @@ -796,6 +796,7 @@ SDL3_0.0.0 { SDL_SetBooleanProperty; SDL_SetClipboardData; SDL_SetClipboardText; + SDL_SetCurrentThreadPriority; SDL_SetCursor; SDL_SetEnvironmentVariable; SDL_SetError; @@ -869,7 +870,6 @@ SDL3_0.0.0 { SDL_SetTextureColorMod; SDL_SetTextureColorModFloat; SDL_SetTextureScaleMode; - SDL_SetThreadPriority; SDL_SetWindowAlwaysOnTop; SDL_SetWindowAspectRatio; SDL_SetWindowBordered; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 3892eb547..ab9ac5352 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -625,8 +625,8 @@ #define SDL_IsJoystickHaptic SDL_IsJoystickHaptic_REAL #define SDL_IsJoystickVirtual SDL_IsJoystickVirtual_REAL #define SDL_IsMouseHaptic SDL_IsMouseHaptic_REAL -#define SDL_IsTablet SDL_IsTablet_REAL #define SDL_IsTV SDL_IsTV_REAL +#define SDL_IsTablet SDL_IsTablet_REAL #define SDL_JoystickConnected SDL_JoystickConnected_REAL #define SDL_JoystickEventsEnabled SDL_JoystickEventsEnabled_REAL #define SDL_KillProcess SDL_KillProcess_REAL @@ -821,6 +821,7 @@ #define SDL_SetBooleanProperty SDL_SetBooleanProperty_REAL #define SDL_SetClipboardData SDL_SetClipboardData_REAL #define SDL_SetClipboardText SDL_SetClipboardText_REAL +#define SDL_SetCurrentThreadPriority SDL_SetCurrentThreadPriority_REAL #define SDL_SetCursor SDL_SetCursor_REAL #define SDL_SetEnvironmentVariable SDL_SetEnvironmentVariable_REAL #define SDL_SetError SDL_SetError_REAL @@ -894,7 +895,6 @@ #define SDL_SetTextureColorMod SDL_SetTextureColorMod_REAL #define SDL_SetTextureColorModFloat SDL_SetTextureColorModFloat_REAL #define SDL_SetTextureScaleMode SDL_SetTextureScaleMode_REAL -#define SDL_SetThreadPriority SDL_SetThreadPriority_REAL #define SDL_SetWindowAlwaysOnTop SDL_SetWindowAlwaysOnTop_REAL #define SDL_SetWindowAspectRatio SDL_SetWindowAspectRatio_REAL #define SDL_SetWindowBordered SDL_SetWindowBordered_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 199a72d76..2c1ef580c 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -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_IsJoystickVirtual,(SDL_JoystickID a),(a),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_IsTablet,(void),(),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_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_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_SetCurrentThreadPriority,(SDL_ThreadPriority 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(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_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_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_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) diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index 9abea1c7e..f4a17688a 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -59,7 +59,7 @@ static int SDLCALL SDL_HIDAPI_RumbleThread(void *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)) { SDL_HIDAPI_RumbleRequest *request = NULL; diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index 8a6416ba3..33a0e3050 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -62,7 +62,7 @@ static int SDLCALL SDL_ANDROID_SensorThread(void *data) ASensorEvent event; 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_SignalSemaphore(ctx->sem); diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 177dc2102..e69462cb9 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -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); } diff --git a/test/testthread.c b/test/testthread.c index bdc913940..67a31b0b0 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -66,7 +66,7 @@ ThreadFunc(void *data) SDL_Log("Thread '%s' is alive!\n", (char *)data); 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) { prio = SDL_THREAD_PRIORITY_LOW; }