summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/tracker.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-06-14 18:33:23 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-06-14 18:33:23 +0200
commit8e6d217dca098b5b508dc09185abeda3331fc4e7 (patch)
tree7048434c9bfbac708850b8b047608ea1959489ef /facetracknoir/tracker.cpp
parentac2f93f6dbd16b4283987cc18f55d3a66eadcced (diff)
tracker: reduce sleep if taking too long
Diffstat (limited to 'facetracknoir/tracker.cpp')
-rw-r--r--facetracknoir/tracker.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp
index ebc8246d..094264ff 100644
--- a/facetracknoir/tracker.cpp
+++ b/facetracknoir/tracker.cpp
@@ -108,6 +108,8 @@ void Tracker::run() {
for (;;)
{
+ t.start();
+
if (should_quit)
break;
@@ -163,7 +165,9 @@ void Tracker::run() {
}
}
- msleep(sleep_ms);
+ const long q = std::max(0L, sleep_ms * 1000L - std::max(0L, t.elapsed()));
+
+ usleep(q);
}
#if defined(_WIN32)
(void) timeEndPeriod(1);