mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 04:36:07 +00:00
d/vive: Fix threading primitive initialization
This commit is contained in:
parent
96d3896664
commit
0d055bb740
|
@ -1048,6 +1048,10 @@ vive_controller_create(struct os_hid_device *controller_hid, enum watchman_gen w
|
|||
d->base.get_tracked_pose = vive_controller_device_get_tracked_pose;
|
||||
d->base.set_output = vive_controller_device_set_output;
|
||||
|
||||
// Have to init before destroy is called.
|
||||
os_mutex_init(&d->lock);
|
||||
os_thread_helper_init(&d->controller_thread);
|
||||
|
||||
if (vive_get_imu_range_report(d->controller_hid, &d->config.imu.gyro_range, &d->config.imu.acc_range) != 0) {
|
||||
// reading range report fails for powered off controller
|
||||
vive_controller_device_destroy(&d->base);
|
||||
|
@ -1159,15 +1163,7 @@ vive_controller_create(struct os_hid_device *controller_hid, enum watchman_gen w
|
|||
}
|
||||
|
||||
if (d->controller_hid) {
|
||||
// Mutex before thread.
|
||||
int ret = os_mutex_init(&d->lock);
|
||||
if (ret != 0) {
|
||||
VIVE_ERROR(d, "Failed to init mutex!");
|
||||
vive_controller_device_destroy(&d->base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = os_thread_helper_start(&d->controller_thread, vive_controller_run_thread, d);
|
||||
int ret = os_thread_helper_start(&d->controller_thread, vive_controller_run_thread, d);
|
||||
if (ret != 0) {
|
||||
VIVE_ERROR(d, "Failed to start mainboard thread!");
|
||||
vive_controller_device_destroy(&d->base);
|
||||
|
|
|
@ -863,6 +863,11 @@ vive_device_create(struct os_hid_device *mainboard_dev,
|
|||
}
|
||||
}
|
||||
|
||||
// Init threads.
|
||||
os_thread_helper_init(&d->mainboard_thread);
|
||||
os_thread_helper_init(&d->sensors_thread);
|
||||
os_thread_helper_init(&d->watchman_thread);
|
||||
|
||||
// Init here.
|
||||
m_imu_3dof_init(&d->fusion, M_IMU_3DOF_USE_GRAVITY_DUR_20MS);
|
||||
|
||||
|
|
Loading…
Reference in a new issue