Initialize timers first so the tick counter is valid by the time the audio and video systems initialize. SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Fri, 30 Dec 2011 06:41:12 -0500
branchSDL-1.2
changeset 612773a1a4c35259
parent 6126 36f33f295c97
child 6129 19c7412a6345
Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
src/SDL.c
     1.1 --- a/src/SDL.c	Fri Dec 30 06:29:06 2011 -0500
     1.2 +++ b/src/SDL.c	Fri Dec 30 06:41:12 2011 -0500
     1.3 @@ -64,6 +64,25 @@
     1.4  
     1.5  int SDL_InitSubSystem(Uint32 flags)
     1.6  {
     1.7 +#if !SDL_TIMERS_DISABLED
     1.8 +	/* Initialize the timer subsystem */
     1.9 +	if ( ! ticks_started ) {
    1.10 +		SDL_StartTicks();
    1.11 +		ticks_started = 1;
    1.12 +	}
    1.13 +	if ( (flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER) ) {
    1.14 +		if ( SDL_TimerInit() < 0 ) {
    1.15 +			return(-1);
    1.16 +		}
    1.17 +		SDL_initialized |= SDL_INIT_TIMER;
    1.18 +	}
    1.19 +#else
    1.20 +	if ( flags & SDL_INIT_TIMER ) {
    1.21 +		SDL_SetError("SDL not built with timer support");
    1.22 +		return(-1);
    1.23 +	}
    1.24 +#endif
    1.25 +
    1.26  #if !SDL_VIDEO_DISABLED
    1.27  	/* Initialize the video/event subsystem */
    1.28  	if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) {
    1.29 @@ -95,25 +114,6 @@
    1.30  	}
    1.31  #endif
    1.32  
    1.33 -#if !SDL_TIMERS_DISABLED
    1.34 -	/* Initialize the timer subsystem */
    1.35 -	if ( ! ticks_started ) {
    1.36 -		SDL_StartTicks();
    1.37 -		ticks_started = 1;
    1.38 -	}
    1.39 -	if ( (flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER) ) {
    1.40 -		if ( SDL_TimerInit() < 0 ) {
    1.41 -			return(-1);
    1.42 -		}
    1.43 -		SDL_initialized |= SDL_INIT_TIMER;
    1.44 -	}
    1.45 -#else
    1.46 -	if ( flags & SDL_INIT_TIMER ) {
    1.47 -		SDL_SetError("SDL not built with timer support");
    1.48 -		return(-1);
    1.49 -	}
    1.50 -#endif
    1.51 -
    1.52  #if !SDL_JOYSTICK_DISABLED
    1.53  	/* Initialize the joystick subsystem */
    1.54  	if ( (flags & SDL_INIT_JOYSTICK) &&
    1.55 @@ -185,12 +185,6 @@
    1.56  		SDL_initialized &= ~SDL_INIT_JOYSTICK;
    1.57  	}
    1.58  #endif
    1.59 -#if !SDL_TIMERS_DISABLED
    1.60 -	if ( (flags & SDL_initialized & SDL_INIT_TIMER) ) {
    1.61 -		SDL_TimerQuit();
    1.62 -		SDL_initialized &= ~SDL_INIT_TIMER;
    1.63 -	}
    1.64 -#endif
    1.65  #if !SDL_AUDIO_DISABLED
    1.66  	if ( (flags & SDL_initialized & SDL_INIT_AUDIO) ) {
    1.67  		SDL_AudioQuit();
    1.68 @@ -203,6 +197,12 @@
    1.69  		SDL_initialized &= ~SDL_INIT_VIDEO;
    1.70  	}
    1.71  #endif
    1.72 +#if !SDL_TIMERS_DISABLED
    1.73 +	if ( (flags & SDL_initialized & SDL_INIT_TIMER) ) {
    1.74 +		SDL_TimerQuit();
    1.75 +		SDL_initialized &= ~SDL_INIT_TIMER;
    1.76 +	}
    1.77 +#endif
    1.78  }
    1.79  
    1.80  Uint32 SDL_WasInit(Uint32 flags)