move priority boosting stuff to ArchHooks
This commit is contained in:
@@ -317,38 +317,6 @@ static bool ChangeAppPri()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BoostAppPri()
|
|
||||||
{
|
|
||||||
if( !ChangeAppPri() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
/* We just want a slight boost, so we don't skip needlessly if something happens
|
|
||||||
* in the background. We don't really want to be high-priority--above normal should
|
|
||||||
* be enough. However, ABOVE_NORMAL_PRIORITY_CLASS is only supported in Win2000
|
|
||||||
* and later. */
|
|
||||||
OSVERSIONINFO version;
|
|
||||||
version.dwOSVersionInfoSize=sizeof(version);
|
|
||||||
if( !GetVersionEx(&version) )
|
|
||||||
{
|
|
||||||
LOG->Warn( werr_ssprintf(GetLastError(), "GetVersionEx failed") );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef ABOVE_NORMAL_PRIORITY_CLASS
|
|
||||||
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DWORD pri = HIGH_PRIORITY_CLASS;
|
|
||||||
if( version.dwMajorVersion >= 5 )
|
|
||||||
pri = ABOVE_NORMAL_PRIORITY_CLASS;
|
|
||||||
|
|
||||||
/* Be sure to boost the app, not the thread, to make sure the
|
|
||||||
* sound thread stays higher priority than the main thread. */
|
|
||||||
SetPriorityClass( GetCurrentProcess(), pri );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CheckSettings()
|
static void CheckSettings()
|
||||||
{
|
{
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
@@ -737,17 +705,6 @@ RageDisplay *CreateDisplay()
|
|||||||
RageException::Throw( error );
|
RageException::Throw( error );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RestoreAppPri()
|
|
||||||
{
|
|
||||||
if(!ChangeAppPri())
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define GAMEPREFS_INI_PATH "Data/GamePrefs.ini"
|
#define GAMEPREFS_INI_PATH "Data/GamePrefs.ini"
|
||||||
#define STATIC_INI_PATH "Data/Static.ini"
|
#define STATIC_INI_PATH "Data/Static.ini"
|
||||||
|
|
||||||
@@ -1169,7 +1126,8 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
/* People may want to do something else while songs are loading, so do
|
/* People may want to do something else while songs are loading, so do
|
||||||
* this after loading songs. */
|
* this after loading songs. */
|
||||||
BoostAppPri();
|
if( ChangeAppPri() )
|
||||||
|
HOOKS->BoostPriority();
|
||||||
|
|
||||||
ResetGame();
|
ResetGame();
|
||||||
|
|
||||||
@@ -1489,10 +1447,13 @@ void FocusChanged( bool bHasFocus )
|
|||||||
/* If we lose focus, we may lose input events, especially key releases. */
|
/* If we lose focus, we may lose input events, especially key releases. */
|
||||||
INPUTFILTER->Reset();
|
INPUTFILTER->Reset();
|
||||||
|
|
||||||
if(g_bHasFocus)
|
if( ChangeAppPri() )
|
||||||
BoostAppPri();
|
{
|
||||||
else
|
if( g_bHasFocus )
|
||||||
RestoreAppPri();
|
HOOKS->BoostPriority();
|
||||||
|
else
|
||||||
|
HOOKS->UnBoostPriority();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CheckSkips( float fDeltaTime )
|
static void CheckSkips( float fDeltaTime )
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ public:
|
|||||||
|
|
||||||
virtual void SetTime( tm newtime ) { }
|
virtual void SetTime( tm newtime ) { }
|
||||||
|
|
||||||
|
virtual void BoostPriority() { }
|
||||||
|
virtual void UnBoostPriority() { }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the amount of time since the program started. (This may actually be
|
* Return the amount of time since the program started. (This may actually be
|
||||||
* since the initialization of HOOKS.
|
* since the initialization of HOOKS.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "ArchHooks_Win32.h"
|
#include "ArchHooks_Win32.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
|
#include "RageLog.h"
|
||||||
#include "RageThreads.h"
|
#include "RageThreads.h"
|
||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
#include "ProductInfo.h"
|
#include "ProductInfo.h"
|
||||||
@@ -185,6 +186,38 @@ void ArchHooks_Win32::SetTime( tm newtime )
|
|||||||
SetLocalTime( &st );
|
SetLocalTime( &st );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArchHooks_Win32::BoostPriority()
|
||||||
|
{
|
||||||
|
/* We just want a slight boost, so we don't skip needlessly if something happens
|
||||||
|
* in the background. We don't really want to be high-priority--above normal should
|
||||||
|
* be enough. However, ABOVE_NORMAL_PRIORITY_CLASS is only supported in Win2000
|
||||||
|
* and later. */
|
||||||
|
OSVERSIONINFO version;
|
||||||
|
version.dwOSVersionInfoSize=sizeof(version);
|
||||||
|
if( !GetVersionEx(&version) )
|
||||||
|
{
|
||||||
|
LOG->Warn( werr_ssprintf(GetLastError(), "GetVersionEx failed") );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef ABOVE_NORMAL_PRIORITY_CLASS
|
||||||
|
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DWORD pri = HIGH_PRIORITY_CLASS;
|
||||||
|
if( version.dwMajorVersion >= 5 )
|
||||||
|
pri = ABOVE_NORMAL_PRIORITY_CLASS;
|
||||||
|
|
||||||
|
/* Be sure to boost the app, not the thread, to make sure the
|
||||||
|
* sound thread stays higher priority than the main thread. */
|
||||||
|
SetPriorityClass( GetCurrentProcess(), pri );
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArchHooks_Win32::UnBoostPriority()
|
||||||
|
{
|
||||||
|
SetPriorityClass( GetCurrentProcess(), NORMAL_PRIORITY_CLASS );
|
||||||
|
}
|
||||||
|
|
||||||
static bool g_bTimerInitialized;
|
static bool g_bTimerInitialized;
|
||||||
static DWORD g_iStartTime;
|
static DWORD g_iStartTime;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public:
|
|||||||
void ExitTimeCriticalSection();
|
void ExitTimeCriticalSection();
|
||||||
void SetTime( tm newtime );
|
void SetTime( tm newtime );
|
||||||
|
|
||||||
|
void BoostPriority();
|
||||||
|
void UnBoostPriority();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CheckVideoDriver();
|
void CheckVideoDriver();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user