The open source OpenXR runtime
0
fork

Configure Feed

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

d/survive: Make it possible to add offset to timecode calculation

+13 -4
+13 -4
src/xrt/drivers/survive/survive_driver.c
··· 170 170 enum u_logging_level log_level; 171 171 172 172 float wait_timeout; 173 + double timecode_offset_ms; 173 174 174 175 struct os_thread_helper event_thread; 175 176 struct os_mutex lock; ··· 204 205 205 206 if (survive->sys->hmd == NULL && all_null) { 206 207 U_LOG_D("Tearing down libsurvive context"); 208 + 209 + // Remove the variable tracking. 210 + u_var_remove_root(survive->sys); 207 211 208 212 // Destroy also stops the thread. 209 213 os_thread_helper_destroy(&survive->sys->event_thread); ··· 236 240 } 237 241 238 242 static timepoint_ns 239 - survive_timecode_to_monotonic(double timecode) 243 + survive_timecode_to_monotonic(struct survive_device *survive, double timecode) 240 244 { 241 245 timepoint_ns timecode_ns = time_s_to_ns(timecode); 242 246 timepoint_ns survive_now_ns = time_s_to_ns(survive_timecode_now_s()); ··· 244 248 timepoint_ns timecode_age_ns = survive_now_ns - timecode_ns; 245 249 246 250 timepoint_ns now = os_monotonic_get_ns(); 247 - timepoint_ns timestamp = now - timecode_age_ns; 251 + timepoint_ns timestamp = now - timecode_age_ns + (uint64_t)(survive->sys->timecode_offset_ms * 1000000.0); 248 252 249 253 return timestamp; 250 254 } ··· 668 672 static void 669 673 _process_button_event(struct survive_device *survive, const struct SurviveSimpleButtonEvent *e) 670 674 { 671 - timepoint_ns ts = survive_timecode_to_monotonic(e->time); 675 + timepoint_ns ts = survive_timecode_to_monotonic(survive, e->time); 672 676 ; 673 677 if (e->event_type == SURVIVE_INPUT_EVENT_AXIS_CHANGED) { 674 678 for (int i = 0; i < e->axis_count; i++) { ··· 781 785 struct xrt_space_relation rel; 782 786 timepoint_ns ts; 783 787 pose_to_relation(&e->pose, &e->velocity, &rel); 784 - ts = survive_timecode_to_monotonic(e->time); 788 + ts = survive_timecode_to_monotonic(survive, e->time); 785 789 m_relation_history_push(survive->relation_hist, &rel, ts); 786 790 787 791 SURVIVE_TRACE(survive, "Process pose event for %s", survive->base.str); ··· 1326 1330 ss->base.offset.position.y = 0.0f; 1327 1331 ss->base.offset.position.z = 0.0f; 1328 1332 ss->base.offset.orientation.w = 1.0f; 1333 + ss->timecode_offset_ms = 0.0; 1329 1334 1330 1335 ss->log_level = debug_get_log_option_survive_log(); 1331 1336 ··· 1384 1389 } 1385 1390 return 0; 1386 1391 } 1392 + 1393 + u_var_add_root(ss, "Survive system", true); 1394 + u_var_add_f64(ss, &ss->timecode_offset_ms, "Timecode offset(ms)"); 1395 + 1387 1396 return out_idx; 1388 1397 }