From c099f7add7c08a04eef974ebe5ace6289358bab3 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 18 Jan 2003 04:27:33 +0000 Subject: [PATCH] add BoostAppPri this smooths out skips for some people --- stepmania/src/StepMania.cpp | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 184bb6a573..766a1e552f 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -165,6 +165,40 @@ static void SetIcon() SDL_FreeSurface(srf); } +static void BoostAppPri() +{ + if(PREFSMAN->m_iBoostAppPriority == 0) + return; + + /* If -1 and this is a debug build, don't. It makes the debugger sluggish. */ +#ifdef DEBUG + if(PREFSMAN->m_iBoostAppPriority == -1) + return; +#endif + +#ifdef WIN32 + /* 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; + } + + 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 +} + int main(int argc, char* argv[]) { ChangeToDirOfExecutable(argv[0]); @@ -253,6 +287,10 @@ int main(int argc, char* argv[]) FONT = new FontManager; SCREENMAN = new ScreenManager; + /* People may want to do something else while songs are loading, so do + * this after loading songs. */ + BoostAppPri(); + Reset(); /* Run the main loop. */