[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

@@ -262,11 +262,11 @@ void frameScheduler_feedback(uint64_t frameSerial, uint32_t generation,
int64_t error = measuredPhase > FRAME_SCHEDULER_TARGET_SLACK_NS ?
(int64_t)(measuredPhase - FRAME_SCHEDULER_TARGET_SLACK_NS) :
-(int64_t)(FRAME_SCHEDULER_TARGET_SLACK_NS - measuredPhase);
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 (!l_frameScheduler.feedbackSamples)
l_frameScheduler.phaseError = error;