Skip to content

Commit b7abc32

Browse files
committed
Start RX ASAP with readiness retries and startup timeout
1 parent fed33f5 commit b7abc32

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/gui/app.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -815,9 +815,11 @@ App::App(const Options& opts) : options_(opts), sim_ui_visible_(opts.enable_sim)
815815
std::string output_dev = getOutputDeviceName();
816816
if (audio_.openOutput(output_dev)) {
817817
deferred_radio_rx_start_pending_ = true;
818-
deferred_radio_rx_start_deadline_ms_ = SDL_GetTicks() + 250;
818+
uint32_t now_ms = SDL_GetTicks();
819+
deferred_radio_rx_start_deadline_ms_ = now_ms;
820+
deferred_radio_rx_start_timeout_ms_ = now_ms + 3000;
819821
deferred_radio_rx_start_attempts_ = 0;
820-
guiLog("Startup audio stage 1/2 complete: output ready, delaying RX capture by 250ms");
822+
guiLog("Startup audio stage 1/2 complete: output ready, starting RX capture ASAP (timeout=3000ms)");
821823
} else {
822824
guiLog("Startup audio stage: openOutput failed");
823825
}
@@ -1533,9 +1535,10 @@ void App::render() {
15331535
std::string output_dev = getOutputDeviceName();
15341536
if (audio_.openOutput(output_dev)) {
15351537
deferred_radio_rx_start_pending_ = true;
1536-
deferred_radio_rx_start_deadline_ms_ = now_ms + 250;
1538+
deferred_radio_rx_start_deadline_ms_ = now_ms;
1539+
deferred_radio_rx_start_timeout_ms_ = now_ms + 3000;
15371540
deferred_radio_rx_start_attempts_ = 0;
1538-
guiLog("Deferred audio stage 1/2 complete: output ready, waiting 250ms before capture");
1541+
guiLog("Deferred audio stage 1/2 complete: output ready, starting RX capture ASAP (timeout=3000ms)");
15391542
ultra::gui::startupTrace("App", "deferred-audio-open-output-exit");
15401543
deferred_audio_auto_init_pending_ = false;
15411544
} else {
@@ -1572,14 +1575,18 @@ void App::render() {
15721575
deferred_radio_rx_start_attempts_ = 0;
15731576
} else {
15741577
deferred_radio_rx_start_attempts_++;
1575-
if (deferred_radio_rx_start_attempts_ >= 5) {
1576-
guiLog("Deferred audio stage 2/2 failed after %d attempts; manual audio init required",
1577-
deferred_radio_rx_start_attempts_);
1578+
if (now_ms >= deferred_radio_rx_start_timeout_ms_) {
1579+
guiLog("Deferred audio stage 2/2 timeout after %d attempts (%ums); manual audio init required",
1580+
deferred_radio_rx_start_attempts_, 3000u);
15781581
deferred_radio_rx_start_pending_ = false;
15791582
} else {
1580-
deferred_radio_rx_start_deadline_ms_ = now_ms + 500;
1581-
guiLog("Deferred audio stage 2/2 retry %d/5 scheduled",
1582-
deferred_radio_rx_start_attempts_ + 1);
1583+
deferred_radio_rx_start_deadline_ms_ = now_ms + 100;
1584+
if (deferred_radio_rx_start_attempts_ == 1 ||
1585+
(deferred_radio_rx_start_attempts_ % 10) == 0) {
1586+
uint32_t remaining_ms = deferred_radio_rx_start_timeout_ms_ - now_ms;
1587+
guiLog("Deferred audio stage 2/2 waiting for RX readiness (attempt=%d, remaining=%ums)",
1588+
deferred_radio_rx_start_attempts_, remaining_ms);
1589+
}
15831590
}
15841591
}
15851592
}

src/gui/app.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class App {
7575
bool deferred_audio_wait_logged_ = false;
7676
bool deferred_radio_rx_start_pending_ = false;
7777
uint32_t deferred_radio_rx_start_deadline_ms_ = 0;
78+
uint32_t deferred_radio_rx_start_timeout_ms_ = 0;
7879
int deferred_radio_rx_start_attempts_ = 0;
7980
uint32_t render_frames_seen_ = 0;
8081
std::atomic<bool> tx_in_progress_{false}; // Thread-safe TX flag for waterfall control

0 commit comments

Comments
 (0)