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: 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
This commit is contained in:
Sam Lantinga 2014-03-01 09:50:52 -08:00
parent cff6eb5155
commit b7435a3ad3
9 changed files with 68 additions and 20 deletions

View file

@ -1542,6 +1542,7 @@ SDLTest_CommonQuit(SDLTest_CommonState * state)
SDL_AudioQuit();
}
SDL_free(state);
SDL_Quit();
}
/* vi: set ts=4 sw=4 expandtab: */