From d2a2005212474e07a3fe6f8a8757ad509e037193 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 26 May 2022 20:52:08 +0100 Subject: [PATCH] a/tracking: Document and fix cond var loop in psmv --- src/xrt/auxiliary/tracking/t_tracker_psmv.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/xrt/auxiliary/tracking/t_tracker_psmv.cpp b/src/xrt/auxiliary/tracking/t_tracker_psmv.cpp index d9fb7a19d..ac0ea24e0 100644 --- a/src/xrt/auxiliary/tracking/t_tracker_psmv.cpp +++ b/src/xrt/auxiliary/tracking/t_tracker_psmv.cpp @@ -355,13 +355,17 @@ run(TrackerPSMV &t) os_thread_helper_lock(&t.oth); while (os_thread_helper_is_running_locked(&t.oth)) { + // No data if (!t.has_imu || t.frame == NULL) { os_thread_helper_wait_locked(&t.oth); - } - if (!os_thread_helper_is_running_locked(&t.oth)) { - break; + /* + * Loop back to the top to check if we should stop, + * also handles spurious wakeups by re-checking the + * condition in the if case. Essentially two loops. + */ + continue; } // Take a reference on the current frame, this keeps it alive