[client/obs] scheduler: correct phase feedback

Only report the client queue lead when JIT rendering provides a valid
measurement. Clamp linear phase errors instead of wrapping them into the
opposite direction at half of a refresh period.

Timestamp OBS frames after the shared framebuffer becomes ready.
This commit is contained in:
Geoffrey McRae
2026-08-05 11:52:44 +10:00
parent 2c74f4a0f9
commit 12f6485e52
4 changed files with 25 additions and 25 deletions

View File

@@ -98,11 +98,11 @@ void lgFrameSchedulerFeedback(LGFrameScheduler * scheduler,
(int64_t)(measuredPhase - FRAME_SCHEDULER_TARGET_SLACK_NS) :
-(int64_t)(FRAME_SCHEDULER_TARGET_SLACK_NS - measuredPhase);
const int64_t period = (int64_t)scheduler->period;
error %= period;
if (error > period / 2)
error -= period;
else if (error < -period / 2)
error += period;
const int64_t limit = period / 2;
if (error > limit)
error = limit;
else if (error < -limit)
error = -limit;
if (!scheduler->feedbackSamples)
scheduler->phaseError = error;