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.
This commit is contained in:
Mateo de Mayo 2023-09-07 11:41:15 -03:00 committed by Jakob Bornecrantz
parent 3bf927f03f
commit c6ca7d2339
2 changed files with 4 additions and 9 deletions

View file

@ -128,11 +128,7 @@ get_pose(struct vive_controller_device *d,
{
struct xrt_space_relation imu_relation = {0};
imu_relation.relation_flags = XRT_SPACE_RELATION_BITMASK_ALL;
os_mutex_lock(&d->fusion.mutex);
m_relation_history_get(d->fusion.relation_hist, at_timestamp_ns, &imu_relation);
os_mutex_unlock(&d->fusion.mutex);
imu_relation.relation_flags = XRT_SPACE_RELATION_BITMASK_ALL; // Needed after history_get
// Get the offset to the pose (this is from libsurvive's reporting position currently)
@ -629,9 +625,10 @@ vive_controller_handle_imu_sample(struct vive_controller_device *d, struct watch
os_mutex_lock(&d->fusion.mutex);
m_imu_3dof_update(&d->fusion.i3dof, d->imu.last_sample_ts_ns, &acceleration, &angular_velocity);
rel.pose.orientation = d->fusion.i3dof.rot;
m_relation_history_push(d->fusion.relation_hist, &rel, now_ns);
os_mutex_unlock(&d->fusion.mutex);
m_relation_history_push(d->fusion.relation_hist, &rel, now_ns);
// Update the pose we show in the GUI.
d->pose = rel.pose;
}

View file

@ -117,10 +117,7 @@ vive_device_get_3dof_tracked_pose(struct xrt_device *xdev,
struct xrt_space_relation relation = {0};
relation.relation_flags = XRT_SPACE_RELATION_BITMASK_ALL;
os_mutex_lock(&d->fusion.mutex);
m_relation_history_get(d->fusion.relation_hist, at_timestamp_ns, &relation);
os_mutex_unlock(&d->fusion.mutex);
relation.relation_flags = XRT_SPACE_RELATION_BITMASK_ALL; // Needed after history_get
relation.pose.position = d->pose.position;
relation.linear_velocity = (struct xrt_vec3){0, 0, 0};
@ -444,9 +441,10 @@ update_imu(struct vive_device *d, const void *buffer)
os_mutex_lock(&d->fusion.mutex);
m_imu_3dof_update(&d->fusion.i3dof, d->imu.last_sample_ts_ns, &acceleration, &angular_velocity);
rel.pose.orientation = d->fusion.i3dof.rot;
m_relation_history_push(d->fusion.relation_hist, &rel, now_ns);
os_mutex_unlock(&d->fusion.mutex);
m_relation_history_push(d->fusion.relation_hist, &rel, now_ns);
assert(j > 0);
uint32_t age = j <= 0 ? 0 : (uint32_t)(j - 1);