Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Initialize timers first so the tick counter is valid by the time the …
Browse files Browse the repository at this point in the history
…audio and video systems initialize.
  • Loading branch information
slouken committed Dec 30, 2011
1 parent 37f2ce1 commit d2a1e8e
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/SDL.c
Expand Up @@ -49,6 +49,25 @@ static Uint32 ticks_started = 0;
int
SDL_InitSubSystem(Uint32 flags)
{
#if !SDL_TIMERS_DISABLED
/* Initialize the timer subsystem */
if (!ticks_started) {
SDL_StartTicks();
ticks_started = 1;
}
if ((flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER)) {
if (SDL_TimerInit() < 0) {
return (-1);
}
SDL_initialized |= SDL_INIT_TIMER;
}
#else
if (flags & SDL_INIT_TIMER) {
SDL_SetError("SDL not built with timer support");
return (-1);
}
#endif

#if !SDL_VIDEO_DISABLED
/* Initialize the video/event subsystem */
if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) {
Expand Down Expand Up @@ -79,25 +98,6 @@ SDL_InitSubSystem(Uint32 flags)
}
#endif

#if !SDL_TIMERS_DISABLED
/* Initialize the timer subsystem */
if (!ticks_started) {
SDL_StartTicks();
ticks_started = 1;
}
if ((flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER)) {
if (SDL_TimerInit() < 0) {
return (-1);
}
SDL_initialized |= SDL_INIT_TIMER;
}
#else
if (flags & SDL_INIT_TIMER) {
SDL_SetError("SDL not built with timer support");
return (-1);
}
#endif

#if !SDL_JOYSTICK_DISABLED
/* Initialize the joystick subsystem */
if ((flags & SDL_INIT_JOYSTICK) && !(SDL_initialized & SDL_INIT_JOYSTICK)) {
Expand Down Expand Up @@ -175,12 +175,6 @@ SDL_QuitSubSystem(Uint32 flags)
SDL_initialized &= ~SDL_INIT_HAPTIC;
}
#endif
#if !SDL_TIMERS_DISABLED
if ((flags & SDL_initialized & SDL_INIT_TIMER)) {
SDL_TimerQuit();
SDL_initialized &= ~SDL_INIT_TIMER;
}
#endif
#if !SDL_AUDIO_DISABLED
if ((flags & SDL_initialized & SDL_INIT_AUDIO)) {
SDL_AudioQuit();
Expand All @@ -193,6 +187,12 @@ SDL_QuitSubSystem(Uint32 flags)
SDL_initialized &= ~SDL_INIT_VIDEO;
}
#endif
#if !SDL_TIMERS_DISABLED
if ((flags & SDL_initialized & SDL_INIT_TIMER)) {
SDL_TimerQuit();
SDL_initialized &= ~SDL_INIT_TIMER;
}
#endif
}

Uint32
Expand Down

0 comments on commit d2a1e8e

Please sign in to comment.