summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd/windows_timer_utils.h
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2015-09-16 23:21:38 +1000
committerTim Mayberry <mojofunk@gmail.com>2015-09-16 23:59:38 +1000
commit119e56e7eb9c58df0ac69e0e94dd6e008701b69c (patch)
treed3c08c99336a94660faed00367b1a3374e3039f5 /libs/pbd/pbd/windows_timer_utils.h
parent9bd893a6a28912ed2905a6d01d7a7abea79e58eb (diff)
Add PBD::QPC::initialize to initialize timer and call it from PBD::init
Check timer for invalid frequency Precalculate timer tick rate to save a few instructions Don't use static variables inside functions to avoid checking for initialization Use static functions inside anonymous namespace for internal linkage
Diffstat (limited to 'libs/pbd/pbd/windows_timer_utils.h')
-rw-r--r--libs/pbd/pbd/windows_timer_utils.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/libs/pbd/pbd/windows_timer_utils.h b/libs/pbd/pbd/windows_timer_utils.h
index 4ebeacd6eb..a8772590d7 100644
--- a/libs/pbd/pbd/windows_timer_utils.h
+++ b/libs/pbd/pbd/windows_timer_utils.h
@@ -60,19 +60,28 @@ bool reset_resolution();
namespace QPC {
/**
+ * Initialize the QPC timer, must be called before QPC::get_microseconds will
+ * return a valid value.
+ * @return true if QPC timer is usable, use check_timer_valid to try to check
+ * if it is monotonic.
+ */
+bool initialize ();
+
+/**
* @return true if QueryPerformanceCounter is usable as a timer source
* This should always return true for systems > XP as those versions of windows
* have there own tests to check timer validity and will select an appropriate
- * timer source.
+ * timer source. This check is not conclusive and there are probably conditions
+ * under which this check will return true but the timer is not monotonic.
*/
bool check_timer_valid ();
/**
* @return the value of the performance counter converted to microseconds
*
- * If get_counter_valid returns true then get_microseconds will always
- * return a positive value. If QPC is not supported(OS < XP) then -1 is
- * returned but the MS docs say that this won't occur for systems >= XP.
+ * If initialize returns true then get_microseconds will always return a
+ * positive value. If QPC is not supported(OS < XP) then -1 is returned but the
+ * MS docs say that this won't occur for systems >= XP.
*/
int64_t get_microseconds ();