From 3ac2f782e39a3ec15d36dcf99adb958a880b7386 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 6 Dec 2014 22:07:08 +0100 Subject: [PATCH] Added functions to influence the system timer precision. --- include/MUtils/OSSupport.h | 4 ++++ src/OSSupport_Win32.cpp | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/MUtils/OSSupport.h b/include/MUtils/OSSupport.h index fd66c1f..b21d3c1 100644 --- a/include/MUtils/OSSupport.h +++ b/include/MUtils/OSSupport.h @@ -152,6 +152,10 @@ namespace MUtils //Process ID MUTILS_API quint32 process_id(const QProcess *proc); + //System timer resolution + MUTILS_API bool setup_timer_resolution(const quint32 &interval = 1); + MUTILS_API bool reset_timer_resolution(const quint32 &interval = 1); + //Check if debugger is present MUTILS_API void check_debugger(void); diff --git a/src/OSSupport_Win32.cpp b/src/OSSupport_Win32.cpp index 33d3934..3df1dba 100644 --- a/src/OSSupport_Win32.cpp +++ b/src/OSSupport_Win32.cpp @@ -29,6 +29,7 @@ #include #include #include +#include //Internal #include @@ -933,6 +934,20 @@ quint32 MUtils::OS::process_id(const QProcess *proc) return (procInf) ? procInf->dwProcessId : NULL; } +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM TIMER +/////////////////////////////////////////////////////////////////////////////// + +bool MUtils::OS::setup_timer_resolution(const quint32 &interval) +{ + return timeBeginPeriod(interval) == TIMERR_NOERROR; +} + +bool MUtils::OS::reset_timer_resolution(const quint32 &interval) +{ + return timeEndPeriod(interval) == TIMERR_NOERROR; +} + /////////////////////////////////////////////////////////////////////////////// // DEBUGGER CHECK ///////////////////////////////////////////////////////////////////////////////