diff options
author | Sam Lantinga <slouken@libsdl.org> | 2014-03-01 09:50:52 -0800 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2014-03-01 09:50:52 -0800 |
commit | 34d80ff6f02e39a698709803cce194bfc8cc66f3 (patch) | |
tree | d0cf29ed1e76d38a5a2b8f55c2b53b59f76b9295 /src/SDL.c | |
parent | a22f31f4e8b36a38397b094f4337e7b23cb3c4b3 (diff) |
Fixed bug 2423 - timeBeginPeriod & timeEndPeriod mismatch
Coriiander
In src\timer\windows\SDL_systimer.c there is an error with regards to timeBeginPeriod and timeEndPeriod. These functions typically get called when no high resolution timer is available, and GetTickCount is not used.
According to MSDN (link: http://msdn.microsoft.com/en-us/library/windows/desktop/dd757624(v=vs.85).aspx), for every call to timeBeginPeriod a subsequent call to timeEndPeriod is required. While SDL is currently doing this, it fails to call timeEndPeriod when cleaning up/shutting down SDL. Please note that these functions affect things on a system level. Failing to call timeEndPeriod, disables applications for using WINMM-timers after usage&shutdown of SDL, as effectively they the mechanism is now broken.
Solution:
Ensure this code gets called when shutting down the timer subsystem:
#ifndef USE_GETTICKCOUNT
if (!hires_timer_available)
{
timeSetPeriod(0);
}
#endif
Diffstat (limited to 'src/SDL.c')
-rw-r--r-- | src/SDL.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -38,7 +38,8 @@ #if !SDL_TIMERS_DISABLED extern int SDL_TimerInit(void); extern void SDL_TimerQuit(void); -extern void SDL_InitTicks(void); +extern void SDL_TicksInit(void); +extern void SDL_TicksQuit(void); #endif #if SDL_VIDEO_DRIVER_WINDOWS extern int SDL_HelperWindowCreate(void); @@ -123,7 +124,7 @@ SDL_InitSubSystem(Uint32 flags) #endif #if !SDL_TIMERS_DISABLED - SDL_InitTicks(); + SDL_TicksInit(); #endif if ((flags & SDL_INIT_GAMECONTROLLER)) { @@ -355,6 +356,10 @@ SDL_Quit(void) #endif SDL_QuitSubSystem(SDL_INIT_EVERYTHING); +#if !SDL_TIMERS_DISABLED + SDL_TicksQuit(); +#endif + SDL_ClearHints(); SDL_AssertionsQuit(); SDL_LogResetPriorities(); |