From 38ae62b54213181ca420d2467fde36370d7471c5 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Fri, 27 Mar 2026 19:41:45 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20raise=20drift=20cap=20to=201s=20?= =?UTF-8?q?=E2=80=94=20stops=20constant=20resetting=20on=20jittery=20links?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 150ms cap was too tight for Iran relay (high jitter), causing constant audio drops. Raised to 1s — packet bursts are absorbed smoothly, drift reset only fires on real accumulation. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/wzp-web/static/index.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/wzp-web/static/index.html b/crates/wzp-web/static/index.html index c9ef2f7..8f56593 100644 --- a/crates/wzp-web/static/index.html +++ b/crates/wzp-web/static/index.html @@ -193,9 +193,14 @@ function playAudio(pcmInt16) { const now = audioCtx.currentTime; - if (nextPlayTime < now || nextPlayTime > now + 0.2) { - // Behind or drifted too far ahead — snap to now + 40ms - nextPlayTime = now + 0.04; + const drift = nextPlayTime - now; + if (drift < 0) { + // Fell behind — catch up + nextPlayTime = now + 0.02; + } else if (drift > 1.0) { + // More than 1 second ahead — hard reset (real drift) + console.log('drift reset:', drift.toFixed(3) + 's'); + nextPlayTime = now + 0.02; } source.start(nextPlayTime); nextPlayTime += buffer.duration;