summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--facetracknoir/tracker.cpp6
-rw-r--r--facetracknoir/tracker.h2
2 files changed, 7 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);
diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h
index a33d8e0d..46440c32 100644
--- a/facetracknoir/tracker.h
+++ b/facetracknoir/tracker.h
@@ -18,6 +18,7 @@
#include "tracker_types.h"
#include "facetracknoir/main-settings.hpp"
#include "facetracknoir/options.h"
+#include "facetracknoir/timer.hpp"
using namespace options;
class FaceTrackNoIR; // pre-define parent-class to avoid circular includes
@@ -59,6 +60,7 @@ private:
QMutex mtx;
main_settings& s;
volatile bool should_quit;
+ Timer t;
protected:
void run();