Send both min and max prediction times

This commit is contained in:
Patrick Nicolas
2025-01-30 08:58:31 +01:00
parent b97c8b29b5
commit 06b5fd7e6c
5 changed files with 18 additions and 17 deletions
+2 -1
View File
@@ -104,7 +104,8 @@ void wivrn::tracking_control_t::send(wivrn_connection & connection, bool now)
return;
connection.send_stream(to_headset::tracking_control{
.offset = std::chrono::nanoseconds(max.exchange(0)),
.min_offset = std::chrono::nanoseconds(min.exchange(80'000'000)),
.max_offset = std::chrono::nanoseconds(max.exchange(0)),
.enabled = enabled,
});
if (not now)
+8
View File
@@ -50,6 +50,7 @@ struct wivrn_comp_target_factory;
class tracking_control_t
{
using T = std::chrono::nanoseconds::rep;
std::atomic<T> min;
std::atomic<T> max;
std::chrono::steady_clock::time_point next_sample;
std::mutex mutex;
@@ -68,6 +69,13 @@ public:
while (prev < sample and max.compare_exchange_weak(prev, sample))
{
}
if (sample > 0)
{
prev = min;
while (prev > sample and min.compare_exchange_weak(prev, sample))
{
}
}
}
void send(wivrn_connection & connection, bool now = false);