Removed SDL_INIT_TIMER

This is no longer necessary before calling SDL_AddTimer()
This commit is contained in:
Sam Lantinga 2024-09-16 22:57:42 -07:00
parent 9275c533ca
commit f3e419596b
10 changed files with 6 additions and 52 deletions

View File

@ -895,6 +895,7 @@ The following symbols have been renamed:
The following symbols have been removed:
* SDL_INIT_NOPARACHUTE
* SDL_INIT_EVERYTHING - you should only initialize the subsystems you are using
* SDL_INIT_TIMER - no longer needed before calling SDL_AddTimer()
## SDL_joystick.h

View File

@ -283,7 +283,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
return SDL_APP_FAILURE;
}

View File

@ -57,7 +57,6 @@ extern "C" {
*/
typedef Uint32 SDL_InitFlags;
#define SDL_INIT_TIMER 0x00000001u
#define SDL_INIT_AUDIO 0x00000010u /**< `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` */
#define SDL_INIT_VIDEO 0x00000020u /**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS` */
#define SDL_INIT_JOYSTICK 0x00000200u /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS`, should be initialized on the same thread as SDL_INIT_VIDEO on Windows if you don't set SDL_HINT_JOYSTICK_THREAD */
@ -117,7 +116,6 @@ typedef void (SDLCALL *SDL_AppQuit_func)(void *appstate);
*
* `flags` may be any of the following OR'd together:
*
* - `SDL_INIT_TIMER`: timer subsystem
* - `SDL_INIT_AUDIO`: audio subsystem; automatically initializes the events
* subsystem
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events

View File

@ -160,8 +160,6 @@ typedef Uint32 (SDLCALL *SDL_TimerCallback)(void *userdata, SDL_TimerID timerID,
/**
* Call a callback function at a future time.
*
* If you use this function, you must pass `SDL_INIT_TIMER` to SDL_Init().
*
* The callback function is passed the current timer interval and the user
* supplied parameter from the SDL_AddTimer() call and should return the next
* timer interval. If the value returned from the callback is 0, the timer is
@ -224,8 +222,6 @@ typedef Uint64 (SDLCALL *SDL_NSTimerCallback)(void *userdata, SDL_TimerID timerI
/**
* Call a callback function at a future time.
*
* If you use this function, you must pass `SDL_INIT_TIMER` to SDL_Init().
*
* The callback function is passed the current timer interval and the user
* supplied parameter from the SDL_AddTimerNS() call and should return the
* next timer interval. If the value returned from the callback is 0, the

View File

@ -307,20 +307,6 @@ SDL_bool SDL_InitSubSystem(SDL_InitFlags flags)
flags_initialized |= SDL_INIT_EVENTS;
}
// Initialize the timer subsystem
if (flags & SDL_INIT_TIMER) {
if (SDL_ShouldInitSubsystem(SDL_INIT_TIMER)) {
SDL_IncrementSubsystemRefCount(SDL_INIT_TIMER);
if (!SDL_InitTimers()) {
SDL_DecrementSubsystemRefCount(SDL_INIT_TIMER);
goto quit_and_error;
}
} else {
SDL_IncrementSubsystemRefCount(SDL_INIT_TIMER);
}
flags_initialized |= SDL_INIT_TIMER;
}
// Initialize the video subsystem
if (flags & SDL_INIT_VIDEO) {
#ifndef SDL_VIDEO_DISABLED
@ -573,13 +559,6 @@ void SDL_QuitSubSystem(SDL_InitFlags flags)
}
#endif
if (flags & SDL_INIT_TIMER) {
if (SDL_ShouldQuitSubsystem(SDL_INIT_TIMER)) {
SDL_QuitTimers();
}
SDL_DecrementSubsystemRefCount(SDL_INIT_TIMER);
}
if (flags & SDL_INIT_EVENTS) {
if (SDL_ShouldQuitSubsystem(SDL_INIT_EVENTS)) {
SDL_QuitEvents();
@ -632,6 +611,8 @@ void SDL_Quit(void)
SDL_DBus_Quit();
#endif
SDL_QuitTimers();
SDL_SetObjectsInvalid();
SDL_AssertionsQuit();

View File

@ -178,8 +178,6 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName
/**
* Set timeout handler for test.
*
* Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before.
*
* \param timeout Timeout interval in seconds.
* \param callback Function that will be called after timeout has elapsed.
*
@ -200,14 +198,6 @@ static SDL_TimerID SDLTest_SetTestTimeout(int timeout, SDL_TimerCallback callbac
return 0;
}
/* Init SDL timer if not initialized before */
if (!SDL_WasInit(SDL_INIT_TIMER)) {
if (!SDL_InitSubSystem(SDL_INIT_TIMER)) {
SDLTest_LogError("Failed to init timer subsystem: %s", SDL_GetError());
return 0;
}
}
/* Set timer */
timeoutInMilliseconds = timeout * 1000;
timerID = SDL_AddTimer(timeoutInMilliseconds, callback, 0x0);

View File

@ -22,13 +22,6 @@ static int g_timerCallbackCalled = 0;
static void SDLCALL timerSetUp(void **arg)
{
/* Start SDL timer subsystem */
SDL_bool ret = SDL_InitSubSystem(SDL_INIT_TIMER);
SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_TIMER)");
SDLTest_AssertCheck(ret == SDL_TRUE, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)");
if (!ret) {
SDLTest_LogError("%s", SDL_GetError());
}
}
/* Test case functions */

View File

@ -79,7 +79,7 @@ int main(int argc, char **argv)
}
/* Initialize the force feedbackness */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
haptics = SDL_GetHaptics(&num_haptics);
SDL_Log("%d Haptic devices detected.\n", num_haptics);
for (i = 0; i < num_haptics; ++i) {

View File

@ -82,7 +82,7 @@ int main(int argc, char **argv)
}
/* Initialize the force feedbackness */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
haptics = SDL_GetHaptics(&num_haptics);
SDL_Log("%d Haptic devices detected.\n", num_haptics);
if (num_haptics == 0) {

View File

@ -116,11 +116,6 @@ int main(int argc, char *argv[])
i += consumed;
}
if (!SDL_Init(SDL_INIT_TIMER)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
if (SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "SDL_TESTS_QUICK") != NULL) {
SDL_Log("Not running slower tests");
SDL_Quit();