Explicitly set timer resolution on windows

This commit is contained in:
Thilo Schulz 2011-01-31 20:23:05 +00:00
parent 14c5a82c14
commit e0a85521c9
3 changed files with 45 additions and 0 deletions

View file

@ -51,6 +51,7 @@ char *Sys_StripAppBundle( char *pwd );
void Sys_GLimpSafeInit( void );
void Sys_GLimpInit( void );
void Sys_PlatformInit( void );
void Sys_PlatformExit( void );
void Sys_SigHandler( int signal );
void Sys_ErrorDialog( const char *error );
void Sys_AnsiColorPrint( const char *msg );

View file

@ -739,6 +739,17 @@ void Sys_PlatformInit( void )
!( term && ( !strcmp( term, "raw" ) || !strcmp( term, "dumb" ) ) );
}
/*
==============
Sys_PlatformExit
Unix specific deinitialisation
==============
*/
void Sys_PlatformExit( void )
{
}
/*
==============
Sys_SetEnv

View file

@ -41,6 +41,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Used to determine where to store user-specific files
static char homePath[ MAX_OSPATH ] = { 0 };
static UINT timerResolution = 0;
#ifdef __WIN64__
void Sys_SnapVector( float *v )
{
@ -696,6 +698,9 @@ Windows specific initialisation
*/
void Sys_PlatformInit( void )
{
TIMECAPS ptc;
UINT res;
#ifndef DEDICATED
const char *SDL_VIDEODRIVER = getenv( "SDL_VIDEODRIVER" );
@ -708,6 +713,34 @@ void Sys_PlatformInit( void )
else
SDL_VIDEODRIVER_externallySet = qfalse;
#endif
if(timeGetDevCaps(&ptc, sizeof(ptc)) == MMSYSERR_NOERROR)
{
timerResolution = ptc.wPeriodMin;
if(timerResolution > 1)
{
Com_Printf("Warning: Minimum supported timer resolution is %ums "
"on this system, recommended resolution 1ms\n", timerResolution);
}
timeBeginPeriod(timerResolution);
}
else
timerResolution = 0;
}
/*
==============
Sys_PlatformExit
Windows specific initialisation
==============
*/
void Sys_PlatformExit( void )
{
if(timerResolution)
timeEndPeriod(timerResolution);
}
/*