mirror of
https://github.com/libsdl-org/SDL.git
synced 2024-11-23 10:53:27 +08:00
Removed SDL_INIT_TIMER
This is no longer necessary before calling SDL_AddTimer()
This commit is contained in:
parent
9275c533ca
commit
f3e419596b
@ -895,6 +895,7 @@ The following symbols have been renamed:
|
|||||||
The following symbols have been removed:
|
The following symbols have been removed:
|
||||||
* SDL_INIT_NOPARACHUTE
|
* SDL_INIT_NOPARACHUTE
|
||||||
* SDL_INIT_EVERYTHING - you should only initialize the subsystems you are using
|
* 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
|
## SDL_joystick.h
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
|
|||||||
|
|
||||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
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;
|
return SDL_APP_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
typedef Uint32 SDL_InitFlags;
|
typedef Uint32 SDL_InitFlags;
|
||||||
|
|
||||||
#define SDL_INIT_TIMER 0x00000001u
|
|
||||||
#define SDL_INIT_AUDIO 0x00000010u /**< `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` */
|
#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_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 */
|
#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:
|
* `flags` may be any of the following OR'd together:
|
||||||
*
|
*
|
||||||
* - `SDL_INIT_TIMER`: timer subsystem
|
|
||||||
* - `SDL_INIT_AUDIO`: audio subsystem; automatically initializes the events
|
* - `SDL_INIT_AUDIO`: audio subsystem; automatically initializes the events
|
||||||
* subsystem
|
* subsystem
|
||||||
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
|
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
|
||||||
|
@ -160,8 +160,6 @@ typedef Uint32 (SDLCALL *SDL_TimerCallback)(void *userdata, SDL_TimerID timerID,
|
|||||||
/**
|
/**
|
||||||
* Call a callback function at a future time.
|
* 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
|
* The callback function is passed the current timer interval and the user
|
||||||
* supplied parameter from the SDL_AddTimer() call and should return the next
|
* 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
|
* 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.
|
* 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
|
* The callback function is passed the current timer interval and the user
|
||||||
* supplied parameter from the SDL_AddTimerNS() call and should return the
|
* supplied parameter from the SDL_AddTimerNS() call and should return the
|
||||||
* next timer interval. If the value returned from the callback is 0, the
|
* next timer interval. If the value returned from the callback is 0, the
|
||||||
|
23
src/SDL.c
23
src/SDL.c
@ -307,20 +307,6 @@ SDL_bool SDL_InitSubSystem(SDL_InitFlags flags)
|
|||||||
flags_initialized |= SDL_INIT_EVENTS;
|
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
|
// Initialize the video subsystem
|
||||||
if (flags & SDL_INIT_VIDEO) {
|
if (flags & SDL_INIT_VIDEO) {
|
||||||
#ifndef SDL_VIDEO_DISABLED
|
#ifndef SDL_VIDEO_DISABLED
|
||||||
@ -573,13 +559,6 @@ void SDL_QuitSubSystem(SDL_InitFlags flags)
|
|||||||
}
|
}
|
||||||
#endif
|
#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 (flags & SDL_INIT_EVENTS) {
|
||||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
||||||
SDL_QuitEvents();
|
SDL_QuitEvents();
|
||||||
@ -632,6 +611,8 @@ void SDL_Quit(void)
|
|||||||
SDL_DBus_Quit();
|
SDL_DBus_Quit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SDL_QuitTimers();
|
||||||
|
|
||||||
SDL_SetObjectsInvalid();
|
SDL_SetObjectsInvalid();
|
||||||
SDL_AssertionsQuit();
|
SDL_AssertionsQuit();
|
||||||
|
|
||||||
|
@ -178,8 +178,6 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName
|
|||||||
/**
|
/**
|
||||||
* Set timeout handler for test.
|
* 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 timeout Timeout interval in seconds.
|
||||||
* \param callback Function that will be called after timeout has elapsed.
|
* \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;
|
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 */
|
/* Set timer */
|
||||||
timeoutInMilliseconds = timeout * 1000;
|
timeoutInMilliseconds = timeout * 1000;
|
||||||
timerID = SDL_AddTimer(timeoutInMilliseconds, callback, 0x0);
|
timerID = SDL_AddTimer(timeoutInMilliseconds, callback, 0x0);
|
||||||
|
@ -22,13 +22,6 @@ static int g_timerCallbackCalled = 0;
|
|||||||
|
|
||||||
static void SDLCALL timerSetUp(void **arg)
|
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 */
|
/* Test case functions */
|
||||||
|
@ -79,7 +79,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the force feedbackness */
|
/* 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);
|
haptics = SDL_GetHaptics(&num_haptics);
|
||||||
SDL_Log("%d Haptic devices detected.\n", num_haptics);
|
SDL_Log("%d Haptic devices detected.\n", num_haptics);
|
||||||
for (i = 0; i < num_haptics; ++i) {
|
for (i = 0; i < num_haptics; ++i) {
|
||||||
|
@ -82,7 +82,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the force feedbackness */
|
/* 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);
|
haptics = SDL_GetHaptics(&num_haptics);
|
||||||
SDL_Log("%d Haptic devices detected.\n", num_haptics);
|
SDL_Log("%d Haptic devices detected.\n", num_haptics);
|
||||||
if (num_haptics == 0) {
|
if (num_haptics == 0) {
|
||||||
|
@ -116,11 +116,6 @@ int main(int argc, char *argv[])
|
|||||||
i += consumed;
|
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) {
|
if (SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "SDL_TESTS_QUICK") != NULL) {
|
||||||
SDL_Log("Not running slower tests");
|
SDL_Log("Not running slower tests");
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
Loading…
Reference in New Issue
Block a user