The open source OpenXR runtime
0
fork

Configure Feed

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

d/vive: Run watchman poll in separate thread

Watchman polling times out after 1 second when basestations are not present/off.
This should not block reading the IMU.

authored by

Christoph Haag and committed by
Christoph Haag
3a68f60d 07f2e62e

+30 -4
+29 -4
src/xrt/drivers/vive/vive_device.c
··· 51 51 52 52 // Destroy the thread object. 53 53 os_thread_helper_destroy(&d->sensors_thread); 54 + os_thread_helper_destroy(&d->watchman_thread); 54 55 os_thread_helper_destroy(&d->mainboard_thread); 55 56 56 57 m_imu_3dof_close(&d->fusion); ··· 725 726 } 726 727 727 728 static void * 729 + vive_watchman_run_thread(void *ptr) 730 + { 731 + struct vive_device *d = (struct vive_device *)ptr; 732 + 733 + os_thread_helper_lock(&d->watchman_thread); 734 + while (os_thread_helper_is_running_locked(&d->watchman_thread)) { 735 + os_thread_helper_unlock(&d->watchman_thread); 736 + 737 + if (d->watchman_dev) 738 + if (!vive_sensors_read_lighthouse_msg(d)) 739 + return NULL; 740 + 741 + // Just keep swimming. 742 + os_thread_helper_lock(&d->watchman_thread); 743 + } 744 + 745 + return NULL; 746 + } 747 + 748 + static void * 728 749 vive_sensors_run_thread(void *ptr) 729 750 { 730 751 struct vive_device *d = (struct vive_device *)ptr; ··· 738 759 update_imu)) { 739 760 return NULL; 740 761 } 741 - 742 - if (d->watchman_dev) 743 - if (!vive_sensors_read_lighthouse_msg(d)) 744 - return NULL; 745 762 746 763 // Just keep swimming. 747 764 os_thread_helper_lock(&d->sensors_thread); ··· 960 977 vive_sensors_run_thread, d); 961 978 if (ret != 0) { 962 979 VIVE_ERROR(d, "Failed to start sensors thread!"); 980 + vive_device_destroy((struct xrt_device *)d); 981 + return NULL; 982 + } 983 + 984 + ret = os_thread_helper_start(&d->watchman_thread, 985 + vive_watchman_run_thread, d); 986 + if (ret != 0) { 987 + VIVE_ERROR(d, "Failed to start watchman thread!"); 963 988 vive_device_destroy((struct xrt_device *)d); 964 989 return NULL; 965 990 }
+1
src/xrt/drivers/vive/vive_device.h
··· 66 66 enum VIVE_VARIANT variant; 67 67 68 68 struct os_thread_helper sensors_thread; 69 + struct os_thread_helper watchman_thread; 69 70 struct os_thread_helper mainboard_thread; 70 71 71 72 struct lh_model lh;