diff options
Diffstat (limited to 'tracker-pt/ftnoir_tracker_pt.cpp')
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index 84e66221..f980c30d 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -45,24 +45,38 @@ Tracker_PT::~Tracker_PT() camera->stop(); } -void Tracker_PT::run() +bool Tracker_PT::check_camera() { - portable::set_curthread_name("tracker/pt"); - - while(!isInterruptionRequested()) + if (reopen_camera_flag) { - if (reopen_camera_flag) + reopen_camera_flag = false; + if (!camera || last_camera_name != s.camera_name) { - reopen_camera_flag = false; + // deadlock avoidance + + decltype(camera) camera_; { QMutexLocker l(&camera_mtx); - camera = nullptr; + camera_ = std::move(camera); } - auto camera_ = traits->make_camera(); + camera_ = traits->make_camera(); if (!camera_ || !camera_->start(s)) - break; + return false; camera = std::move(camera_); + last_camera_name = s.camera_name; } + } + return true; +} + +void Tracker_PT::run() +{ + portable::set_curthread_name("tracker/pt"); + + while(!isInterruptionRequested()) + { + if (!check_camera()) + break; pt_camera_info info; bool new_frame = false; |