The open source OpenXR runtime
0
fork

Configure Feed

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

d/wmr: Only take the lock once per received packet

+14 -11
+14 -11
src/xrt/drivers/wmr/wmr_hmd.c
··· 147 147 148 148 hololens_sensors_decode_packet(wh, &wh->packet, buffer, size); 149 149 150 + struct xrt_vec3 raw_gyro[4]; 151 + struct xrt_vec3 raw_accel[4]; 152 + 150 153 for (int i = 0; i < 4; i++) { 151 - struct xrt_vec3 raw_gyro; 152 - struct xrt_vec3 raw_accel; 154 + vec3_from_hololens_gyro(wh->packet.gyro, i, &raw_gyro[i]); 155 + vec3_from_hololens_accel(wh->packet.accel, i, &raw_accel[i]); 156 + } 153 157 154 - vec3_from_hololens_gyro(wh->packet.gyro, i, &raw_gyro); 155 - vec3_from_hololens_accel(wh->packet.accel, i, &raw_accel); 156 - 157 - os_mutex_lock(&wh->fusion.mutex); 158 - wh->fusion.last_imu_timestamp_ns = now_ns; 159 - wh->fusion.last_angular_velocity = raw_gyro; 158 + os_mutex_lock(&wh->fusion.mutex); 159 + for (int i = 0; i < 4; i++) { 160 160 m_imu_3dof_update( // 161 161 &wh->fusion.i3dof, // 162 162 wh->packet.gyro_timestamp[i] * WMR_MS_HOLOLENS_NS_PER_TICK, // 163 - &raw_accel, // 164 - &raw_gyro); // 165 - os_mutex_unlock(&wh->fusion.mutex); 163 + &raw_accel[i], // 164 + &raw_gyro[i]); // 166 165 } 166 + wh->fusion.last_imu_timestamp_ns = now_ns; 167 + wh->fusion.last_angular_velocity = raw_gyro[3]; 168 + os_mutex_unlock(&wh->fusion.mutex); 169 + 167 170 break; 168 171 } 169 172 case WMR_MS_HOLOLENS_MSG_UNKNOWN_05: