The open source OpenXR runtime
0
fork

Configure Feed

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

d/vive: Reduce relation history lock contention

Relation history was being accessed guarded by an external lock in a couple of
places. This is redundant since its implementation already defines an internal
lock.

authored by

Mateo de Mayo and committed by
Jakob Bornecrantz
c6ca7d23 3bf927f0

+4 -9
+2 -5
src/xrt/drivers/vive/vive_controller.c
··· 128 128 { 129 129 struct xrt_space_relation imu_relation = {0}; 130 130 imu_relation.relation_flags = XRT_SPACE_RELATION_BITMASK_ALL; 131 - 132 - os_mutex_lock(&d->fusion.mutex); 133 131 m_relation_history_get(d->fusion.relation_hist, at_timestamp_ns, &imu_relation); 134 - os_mutex_unlock(&d->fusion.mutex); 135 - 136 132 imu_relation.relation_flags = XRT_SPACE_RELATION_BITMASK_ALL; // Needed after history_get 137 133 138 134 // Get the offset to the pose (this is from libsurvive's reporting position currently) ··· 629 625 os_mutex_lock(&d->fusion.mutex); 630 626 m_imu_3dof_update(&d->fusion.i3dof, d->imu.last_sample_ts_ns, &acceleration, &angular_velocity); 631 627 rel.pose.orientation = d->fusion.i3dof.rot; 628 + os_mutex_unlock(&d->fusion.mutex); 629 + 632 630 m_relation_history_push(d->fusion.relation_hist, &rel, now_ns); 633 - os_mutex_unlock(&d->fusion.mutex); 634 631 635 632 // Update the pose we show in the GUI. 636 633 d->pose = rel.pose;
+2 -4
src/xrt/drivers/vive/vive_device.c
··· 117 117 struct xrt_space_relation relation = {0}; 118 118 relation.relation_flags = XRT_SPACE_RELATION_BITMASK_ALL; 119 119 120 - os_mutex_lock(&d->fusion.mutex); 121 120 m_relation_history_get(d->fusion.relation_hist, at_timestamp_ns, &relation); 122 - os_mutex_unlock(&d->fusion.mutex); 123 - 124 121 relation.relation_flags = XRT_SPACE_RELATION_BITMASK_ALL; // Needed after history_get 125 122 relation.pose.position = d->pose.position; 126 123 relation.linear_velocity = (struct xrt_vec3){0, 0, 0}; ··· 444 441 os_mutex_lock(&d->fusion.mutex); 445 442 m_imu_3dof_update(&d->fusion.i3dof, d->imu.last_sample_ts_ns, &acceleration, &angular_velocity); 446 443 rel.pose.orientation = d->fusion.i3dof.rot; 444 + os_mutex_unlock(&d->fusion.mutex); 445 + 447 446 m_relation_history_push(d->fusion.relation_hist, &rel, now_ns); 448 - os_mutex_unlock(&d->fusion.mutex); 449 447 450 448 assert(j > 0); 451 449 uint32_t age = j <= 0 ? 0 : (uint32_t)(j - 1);