summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-06-11 20:05:36 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-06-11 20:05:36 +0200
commit64dea656becd8c914a3c8dc3f3b4f0d71bd3f2d0 (patch)
tree17aecacbb6d6c7c663ccd465ab92703dc52d51cf /FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
parent2f85648fe4b6ec33adb2fa90be16da49acd1ad71 (diff)
Defer PT apply to avoid deadlock
Diffstat (limited to 'FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp')
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
index cbc1f1dc..787a5128 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
@@ -26,7 +26,9 @@ Tracker::Tracker()
: commands(0),
video_widget(NULL),
video_frame(NULL),
- tracking_valid(false)
+ tracking_valid(false),
+ need_apply(false),
+ new_settings(nullptr)
{
qDebug()<<"Tracker::Tracker";
}
@@ -73,7 +75,7 @@ void Tracker::run()
if (commands & ABORT) break;
if (commands & PAUSE) continue;
commands = 0;
-
+ apply_inner();
dt = time.start() / 1000.0;
new_frame = camera.get_frame(dt, &frame);
@@ -111,11 +113,23 @@ void Tracker::run()
qDebug()<<"Tracker:: Thread stopping";
}
-
void Tracker::apply(settings& s)
{
- qDebug()<<"Tracker:: Applying settings";
QMutexLocker lock(&mutex);
+ need_apply = true;
+ // caller guarantees object lifetime
+ new_settings = &s;
+}
+
+void Tracker::apply_inner()
+{
+ QMutexLocker lock(&mutex);
+ if (!need_apply)
+ return;
+ qDebug()<<"Tracker:: Applying settings";
+ auto& s = *new_settings;
+ new_settings = nullptr;
+ need_apply = false;
camera.set_device_index(s.cam_index);
camera.set_res(s.cam_res_x, s.cam_res_y);
camera.set_fps(s.cam_fps);