diff --git a/client/scenes/stream_tracking.cpp b/client/scenes/stream_tracking.cpp index d9c25dbe..d786649e 100644 --- a/client/scenes/stream_tracking.cpp +++ b/client/scenes/stream_tracking.cpp @@ -229,7 +229,7 @@ void scenes::stream::tracking() control = tracking_control; } - XrDuration prediction = std::min(control.offset.count(), 80'000'000); + XrDuration prediction = std::clamp(control.offset.count(), 0, 80'000'000); auto period = std::max(display_time_period.load(), 1'000'000); for (XrDuration Δt = 0; Δt <= prediction + period / 2; Δt += period, ++samples) { @@ -311,7 +311,7 @@ void scenes::stream::tracking() // Target: polling between 1 and 5ms, with 20% busy time tracking_period = std::clamp(std::lerp(tracking_period, busy_time * 5, 0.2), 1'000'000, 5'000'000); - if (busy_time / samples > 2'000'000) + if (samples and busy_time / samples > 2'000'000) { skip_samples = busy_time / 2'000'000; }