From bd5b47484f196d414bc474cd2c591b9316fdfe81 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 19 Jul 2014 12:41:14 +0100 Subject: [PATCH] Added an internal flag JUCE_WIN32_TIMER_PERIOD, which can be set to change the value that is passed to the timeBeginPeriod function, or to prevent this function being called at all. --- .../juce_core/native/juce_win32_SystemStats.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/juce_core/native/juce_win32_SystemStats.cpp b/modules/juce_core/native/juce_win32_SystemStats.cpp index 44065cdb8f..901bc761fe 100644 --- a/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -253,9 +253,23 @@ public: HiResCounterHandler() : hiResTicksOffset (0) { - const MMRESULT res = timeBeginPeriod (1); + // This macro allows you to override the default timer-period + // used on Windows. By default this is set to 1, because that has + // always been the value used in JUCE apps, and changing it could + // affect the behaviour of existing code, but you may wish to make + // it larger (or set it to 0 to use the system default) to make your + // app less demanding on the CPU. + // For more info, see win32 documentation about the timeBeginPeriod + // function. + #ifndef JUCE_WIN32_TIMER_PERIOD + #define JUCE_WIN32_TIMER_PERIOD 1 + #endif + + #if JUCE_WIN32_TIMER_PERIOD > 0 + const MMRESULT res = timeBeginPeriod (JUCE_WIN32_TIMER_PERIOD); (void) res; jassert (res == TIMERR_NOERROR); + #endif LARGE_INTEGER f; QueryPerformanceFrequency (&f);