[Audio] Set timer resolution to 0.5ms

This commit is contained in:
zilmar 2018-12-02 15:06:37 +10:30
parent b957cac73d
commit 9e35a1afc3
1 changed files with 21 additions and 0 deletions

View File

@ -29,6 +29,10 @@
#include "ConfigUI.h"
#include "SettingsID.h"
#ifdef _WIN32
void SetTimerResolution ( void );
#endif
/* Read header for type definition */
AUDIO_INFO g_AudioInfo;
@ -51,6 +55,9 @@ void PluginInit(void)
SetupTrace();
SetupAudioSettings();
StartTrace();
#ifdef _WIN32
SetTimerResolution();
#endif
g_PluginInit = true;
}
@ -267,3 +274,17 @@ extern "C" void UseUnregisteredSetting(int /*SettingID*/)
DebugBreak();
#endif
}
#ifdef _WIN32
void SetTimerResolution(void)
{
HMODULE hMod = GetModuleHandle("ntdll.dll");
if (hMod != NULL)
{
typedef LONG(NTAPI* tNtSetTimerResolution)(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution);
tNtSetTimerResolution NtSetTimerResolution = (tNtSetTimerResolution)GetProcAddress(hMod, "NtSetTimerResolution");
ULONG CurrentResolution = 0;
NtSetTimerResolution(5000, TRUE, &CurrentResolution);
}
}
#endif