From c041882f5f7f0ceac37e7d1608e5f65b87507d75 Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 14 Oct 2026 19:30:28 +0200 Subject: [PATCH] Observe capture timestamps and device progress in voice tests --- tools/chatgui/tests/test_voice_audio_io.cpp | 8 +++++++- tools/chatgui/tests/test_voice_tx.cpp | 8 +++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/chatgui/tests/test_voice_audio_io.cpp b/tools/chatgui/tests/test_voice_audio_io.cpp index 7ee4ef0d..b3b7e2cc 100644 --- a/tools/chatgui/tests/test_voice_audio_io.cpp +++ b/tools/chatgui/tests/test_voice_audio_io.cpp @@ -35,6 +35,10 @@ extern "C" int radio_audio_pull_pcm(uint64_t, int16_t* out, int count) { ++pulls; for (int i = 0; i < count; ++i) out[i] = i % 2 ? 2000 : 1000; return count; } extern "C" void call_audio_reset_io(uint64_t, int) {} +extern "C" int call_audio_get_clock(uint64_t, int64_t, call_clock_snapshot* out) { *out = {}; out->epoch = 1; return 0; } +extern "C" void call_audio_playback_progress(uint64_t, uint64_t, uint64_t position, int64_t at, int64_t now, int) { + output_position = position; output_delay = at > now ? (at - now) / 100 : 0; +} extern "C" void radio_audio_reset_playback(uint64_t) {} extern "C" void radio_audio_capture_discontinuity(uint64_t) {} extern "C" void radio_audio_talk_begin(uint64_t) { std::lock_guard lock(mutex); talking = true; } @@ -46,8 +50,10 @@ extern "C" int radio_audio_feed_pcm(uint64_t, const int16_t* pcm, int count) { if (talking) transmitted.insert(transmitted.end(), pcm, pcm + count); ++blocks; return 0; } -extern "C" int call_audio_feed_prepared_pcm(uint64_t, const int16_t* pcm, const uint8_t* mask) { +static int64_t capture_time; +extern "C" int call_audio_feed_prepared_pcm(uint64_t, const int16_t* pcm, const uint8_t* mask, int64_t pts) { std::lock_guard lock(mutex); + capture_time = pts; capture.insert(capture.end(), pcm, pcm + 960); masks.insert(masks.end(), mask, mask + 960); ++blocks; return 0; } diff --git a/tools/chatgui/tests/test_voice_tx.cpp b/tools/chatgui/tests/test_voice_tx.cpp index 74eda223..501000ac 100644 --- a/tools/chatgui/tests/test_voice_tx.cpp +++ b/tools/chatgui/tests/test_voice_tx.cpp @@ -48,7 +48,9 @@ extern "C" int __wrap_radio_talk_end(UTUN_INSTANCE*, uint64_t) { events.push_bac extern "C" int __wrap_radio_talk_send(UTUN_INSTANCE*, uint64_t, const uint8_t* data, int len) { events.push_back('M'); packets.emplace_back(data, data + len); return 0; } -extern "C" int __wrap_call_send_media(UTUN_INSTANCE*, uint64_t, const uint8_t* data, int len) { +static call_capture_time last_call_timing{}; +extern "C" int __wrap_call_send_media(UTUN_INSTANCE*, uint64_t, const uint8_t* data, int len, const call_capture_time* timing) { + REQUIRE(timing); last_call_timing = *timing; packets.emplace_back(data, data + len); return 0; } extern "C" int __real_chat_setting_get_int(UTUN_INSTANCE*, const char*, int); @@ -570,10 +572,10 @@ int main() { // Prepared policy исключает повторный core AEC; mute применяется только к нужной части кадра. packets.clear(); REQUIRE(call_audio_start_prepared(42) == 0); REQUIRE(call_audio_start(42) == -1); - REQUIRE(call_audio_feed_pcm(42, input.data(), 960) == -1); + REQUIRE(call_audio_feed_pcm(42, input.data(), 960, INT64_MIN) == -1); std::array mask{}; std::fill(mask.begin() + 300, mask.end(), 1); - REQUIRE(call_audio_feed_prepared_pcm(42, input.data(), mask.data()) == 0); + REQUIRE(call_audio_feed_prepared_pcm(42, input.data(), mask.data(), 123456789) == 0); uasync_poll(instance.ua, 0); encoder = opus_codec_encoder_create(48000, 1); REQUIRE(encoder); tail.fill(0); memcpy(tail.data(), input.data(), 300 * sizeof(int16_t)); check_packet(encoder, tail.data(), 0);