The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

t/slam: Use locks for CSV writers

Fixes a race condition that produced weirdly written csv files.

authored by

Mateo de Mayo and committed by
Jakob Bornecrantz
347ae3ce 28b09733

+7 -1
+7 -1
src/xrt/auxiliary/tracking/t_tracker_slam.cpp
··· 38 38 #include <fstream> 39 39 #include <iomanip> 40 40 #include <map> 41 + #include <mutex> 41 42 #include <string> 42 43 #include <vector> 43 44 ··· 85 86 constexpr int UI_FEATURES_POSE_COUNT = 192; 86 87 constexpr int UI_GTDIFF_POSE_COUNT = 192; 87 88 89 + using os::Mutex; 88 90 using std::deque; 89 91 using std::ifstream; 90 92 using std::make_shared; ··· 95 97 using std::shared_ptr; 96 98 using std::string; 97 99 using std::to_string; 100 + using std::unique_lock; 98 101 using std::vector; 99 102 using std::filesystem::create_directories; 100 103 using Trajectory = map<timepoint_ns, xrt_pose>; ··· 257 260 string filename; 258 261 ofstream file; 259 262 bool created = false; 263 + Mutex mutex; 260 264 261 265 void 262 266 create() ··· 281 285 void 282 286 push(RowType row) 283 287 { 288 + unique_lock lock(mutex); 289 + 284 290 if (!enabled) { 285 291 return; 286 292 } ··· 1338 1344 { 1339 1345 XRT_TRACE_MARKER(); 1340 1346 1341 - if (cam_index == 1) { 1347 + if (cam_index == t.cam_count - 1) { 1342 1348 flush_poses(t); // Useful to flush SLAM poses when no openxr app is open 1343 1349 } 1344 1350 SLAM_DASSERT(t.last_cam_ts[0] != INT64_MIN || cam_index == 0, "First frame was not a cam0 frame");