From 26c91e6295dcdd5b6eac3188db936b188cbb592d Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 15 Oct 2026 13:22:24 +0200 Subject: [PATCH] Test phase alignment after device silence and keep diagnostics current --- src/call/call_jitter.cpp | 1 + tools/chatgui/tests/test_call_delay.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/call/call_jitter.cpp b/src/call/call_jitter.cpp index 93d78ab3..aba46c16 100644 --- a/src/call/call_jitter.cpp +++ b/src/call/call_jitter.cpp @@ -204,6 +204,7 @@ void call_jitter_silence(struct call_jitter* j, unsigned samples) { if (!j) return; std::lock_guard lock(j->mtx); j->delay.silence(samples); + j->diagnostics.phase_samples = j->delay.stats().phase; j->timeline.silence(samples); } diff --git a/tools/chatgui/tests/test_call_delay.cpp b/tools/chatgui/tests/test_call_delay.cpp index f6e34cf8..3457798d 100644 --- a/tools/chatgui/tests/test_call_delay.cpp +++ b/tools/chatgui/tests/test_call_delay.cpp @@ -127,9 +127,25 @@ static void tail_and_reset() { DEBUG_INFO(DEBUG_CATEGORY_CALL, "PASS delay final tail preserved without flush, reset clears phase/history"); } +static void phase_after_silence() { + for (unsigned block : {240, 480, 777, 960}) for (unsigned silence : {1, 239, 480, 777, 959}) { + Trial t; + t.timeline.silence(silence); t.delay.silence(silence); t.device += silence; + t.available = 5 * 960; // Прямой режим без SoundTouch; стартовая фаза произвольна. + uint64_t next = 960; + for (uint64_t time = 0; time < 20 * 48000; time += block) { + while (next <= time) { t.available += 960; next += 960; } + t.pull(block); + } + auto s = t.delay.stats(); + CHECK(!s.entered && !s.exited && s.cuts > 0 && !s.phase && s.tempo == 1); + } + DEBUG_INFO(DEBUG_CATEGORY_CALL, "PASS delay phase: 20 arbitrary initial silence/block combinations converge using cuts only"); +} + int main() { debug_config_init(); debug_set_level(DEBUG_LEVEL_INFO); for (unsigned block : {240, 480, 777, 960}) for (unsigned phase : {0, 239, 479, 719, 959}) steady(block, phase); - switching(); tail_and_reset(); + switching(); tail_and_reset(); phase_after_silence(); return 0; }