Fix TX mic hoarseness: pre-roll flush bug and wider stall margin

Pre-roll bug: when MIC_PREROLL_SAMP is an exact multiple of OPUS_FRAME_SAMP
(1920/960=2), the N<=Want branch filled the buffer but never flushed it,
losing the first 40ms of audio and leaving the ring empty long enough for
silence blocks to be injected into WDSP.

StallCount threshold raised from 2 to 4 (~43ms) to cover OS scheduler
jitter of up to 22ms, preventing false silence injection when an Opus
frame arrives slightly late relative to the DSP tick.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-21 20:30:14 +03:00
co-authored by Claude Sonnet 4.6
parent ebca3b4137
commit 65545982e3
2 changed files with 29 additions and 10 deletions
+3 -1
View File
@@ -603,9 +603,11 @@ begin
Want := MIC_PREROLL_SAMP - FMicPreRollPos;
if N <= Want then
begin
// Pre-roll ещё не набран: просто копим
Move(P^, FMicPreRoll[FMicPreRollPos], N * SizeOf(Single));
Inc(FMicPreRollPos, N);
// N = Want точно заполняет pre-roll — надо слить (иначе буфер потерян)
if FMicPreRollPos = MIC_PREROLL_SAMP then
FlushMicToCallback(@FMicPreRoll[0], MIC_PREROLL_SAMP);
end
else
begin