From 96725caf03975c2ae40696c0a4fef7be51b7a1d1 Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 15 Oct 2026 11:35:53 +0200 Subject: [PATCH] Request 20 ms call capture and test output latency reports --- tools/chatgui/src/call_audio_engine.cpp | 2 ++ tools/chatgui/tests/test_audio_diagnostics.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/tools/chatgui/src/call_audio_engine.cpp b/tools/chatgui/src/call_audio_engine.cpp index dc4db125..d4459c00 100644 --- a/tools/chatgui/src/call_audio_engine.cpp +++ b/tools/chatgui/src/call_audio_engine.cpp @@ -59,6 +59,8 @@ bool CallAudioEngine::openCapture() { if (!context) return false; ma_device_config config = ma_device_config_init(ma_device_type_capture); config.capture.format = ma_format_s16; config.capture.channels = 1; config.sampleRate = CALL_AUDIO_SAMPLE_RATE; + config.periodSizeInMilliseconds = CALL_AUDIO_FRAME_MS; + DEBUG_INFO(DEBUG_CATEGORY_CALL, "CallAudio: capture requested period=%dms; actual period reported by device", CALL_AUDIO_FRAME_MS); ma_device_id id; bool selected = SoundManager::deviceId(m_captureId, &id); if (selected) config.capture.pDeviceID = &id; diff --git a/tools/chatgui/tests/test_audio_diagnostics.cpp b/tools/chatgui/tests/test_audio_diagnostics.cpp index 2fe32823..ad475c53 100644 --- a/tools/chatgui/tests/test_audio_diagnostics.cpp +++ b/tools/chatgui/tests/test_audio_diagnostics.cpp @@ -39,6 +39,19 @@ int main() { assert(take(e)); consume(e, devices); assert(capture.captureJumps == 0 && capture.captureMissing == 0 && capture.captureEstimated == 1); assert(capture.captureSequence == 1920 && capture.captureBlocks == 1 && capture.captureFrames == 480); + // Отсутствующий timestamp не превращается в измеренную нулевую задержку. + audio_playback_timing output{30000, 1000, 1200, 48000, 1}; + audio_diag_playback_clock(nullptr, &output); + output.latency_us = -1000; output.frames = 960; + audio_diag_playback_clock(nullptr, &output); + output.latency_us = 999999; output.measured = 0; + audio_diag_playback_clock(nullptr, &output); + while (take(e)) consume(e, devices); + assert(capture.playbackBlocks == 3 && capture.playbackFrames == 3120 && capture.playbackMeasured == 2); + assert(capture.playbackMinLatency == -1000 && capture.playbackMaxLatency == 30000); + assert(capture.playbackMaxBlock == 25000 && capture.playbackMaxConverter == 1000); + report(devices, now(CLOCK_MONOTONIC), 1.0); + assert(capture.playbackBlocks == 0 && capture.playbackMeasured == 0 && capture.playbackMaxBlock == 0); std::vector workers; for (int p = 0; p < producers; ++p) workers.emplace_back([p, &done]() { for (int i = 0; i < perProducer; ++i)