radio: add activation controls, live VAD meters and signal diagnostics

This commit is contained in:
evgeny committed 2026-10-09 16:11:11 +02:00
1 parent fddbba217d
commit 7f3247bfcc
23 files changed
+818 -182

No files matched your search

@@ -14,6 +14,7 @@ extern "C" {
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#define REQUIRE(x) do { if (!(x)) { fprintf(stderr, "voice-io:%d %s\n", __LINE__, #x); abort(); } } while (0)
static std::mutex mutex;
static std::vector<int16_t> capture, transmitted;
@@ -21,6 +22,10 @@ static std::vector<uint8_t> masks;
static bool talking;
static std::atomic<int> pulls{0}, blocks{0};
static std::atomic<bool> stall{false}, stalled{false};
static std::atomic<bool> idleReported{false};
static void capture_diagnostic(int, const char*, const char* message) {
if (std::strstr(message, "voice-io: capture stalled")) idleReported = true;
}
static std::atomic<uint64_t> output_position{0}, output_delay{0};
extern "C" void radio_audio_playback_progress(uint64_t, uint64_t position, uint64_t delay) {
output_delay = delay; output_position = position;
@@ -58,6 +63,15 @@ int main() {
debug_config_init(); debug_set_level(DEBUG_LEVEL_WARN);
VoiceAudioIo voice;
std::array<int16_t, 960> pcm{}; pcm.fill(1234);
// Отсутствие PCM должно попадать в лог без необходимости ждать следующего кадра.
debug_set_log_hook(capture_diagnostic);
REQUIRE(voice.start(VoiceAudioIo::Kind::Radio, 7) && voice.startCapture(1, false));
await([] { return idleReported.load(); });
voice.capture(pcm.data(), 960, 0);
await([] { return blocks.load() == 1; });
voice.stop(); debug_set_log_hook(nullptr);
REQUIRE(capture.size() == 960 && capture.front() == 1234 && capture.back() == 1234);
reset(); pulls = 0; output_position = 0;
// Выдача RX worker не подтверждает вывод; частичный callback сохраняет позицию и backend delay.
REQUIRE(voice.start(VoiceAudioIo::Kind::Radio, 7));
await([] { return pulls.load() >= 2; });