From 8042624c39865f2cff02a506ef199685097c5c40 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Tue, 3 Mar 2026 19:41:17 +0100 Subject: [PATCH] [style](trx-server): format audio and startup code Co-authored-by: OpenAI Codex Signed-off-by: Stan Grams --- src/trx-server/src/audio.rs | 16 +++++++++++----- src/trx-server/src/main.rs | 21 +++++++++------------ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/trx-server/src/audio.rs b/src/trx-server/src/audio.rs index 2d6e8dd..c6c8685 100644 --- a/src/trx-server/src/audio.rs +++ b/src/trx-server/src/audio.rs @@ -19,9 +19,9 @@ use tracing::{error, info, warn}; use trx_ais::AisDecoder; use trx_aprs::AprsDecoder; use trx_core::audio::{ - read_audio_msg, write_audio_msg, AudioStreamInfo, AUDIO_MSG_AIS_DECODE, - AUDIO_MSG_APRS_DECODE, AUDIO_MSG_CW_DECODE, AUDIO_MSG_FT8_DECODE, AUDIO_MSG_RX_FRAME, - AUDIO_MSG_STREAM_INFO, AUDIO_MSG_TX_FRAME, AUDIO_MSG_VDES_DECODE, AUDIO_MSG_WSPR_DECODE, + read_audio_msg, write_audio_msg, AudioStreamInfo, AUDIO_MSG_AIS_DECODE, AUDIO_MSG_APRS_DECODE, + AUDIO_MSG_CW_DECODE, AUDIO_MSG_FT8_DECODE, AUDIO_MSG_RX_FRAME, AUDIO_MSG_STREAM_INFO, + AUDIO_MSG_TX_FRAME, AUDIO_MSG_VDES_DECODE, AUDIO_MSG_WSPR_DECODE, }; use trx_core::decode::{ AisMessage, AprsPacket, DecodedMessage, Ft8Message, VdesMessage, WsprMessage, @@ -905,7 +905,10 @@ pub async fn run_ais_decoder( let mut decoder_a = AisDecoder::new(sample_rate); let mut decoder_b = AisDecoder::new(sample_rate); let mut was_active = false; - let mut active = matches!(state_rx.borrow().status.mode, RigMode::AIS | RigMode::MARINE); + let mut active = matches!( + state_rx.borrow().status.mode, + RigMode::AIS | RigMode::MARINE + ); loop { if !active { @@ -987,7 +990,10 @@ pub async fn run_vdes_decoder( info!("VDES decoder started ({}Hz complex baseband)", sample_rate); let mut decoder = VdesDecoder::new(sample_rate); let mut was_active = false; - let mut active = matches!(state_rx.borrow().status.mode, RigMode::VDES | RigMode::MARINE); + let mut active = matches!( + state_rx.borrow().status.mode, + RigMode::VDES | RigMode::MARINE + ); loop { if !active { diff --git a/src/trx-server/src/main.rs b/src/trx-server/src/main.rs index 94b8d2e..331f63e 100644 --- a/src/trx-server/src/main.rs +++ b/src/trx-server/src/main.rs @@ -288,10 +288,7 @@ type SdrRigBuildResult = DynResult<( type OptionalSdrRig = Option>; type OptionalSdrPcmRx = Option>>; -type OptionalSdrAisPcmRx = Option<( - broadcast::Receiver>, - broadcast::Receiver>, -)>; +type OptionalSdrAisPcmRx = Option<(broadcast::Receiver>, broadcast::Receiver>)>; type OptionalSdrVdesIqRx = Option>>>; /// Build a `SoapySdrRig` with full channel config from a `RigInstanceConfig`. @@ -641,7 +638,8 @@ fn spawn_rig_audio_stack( let vdes_decode_tx = decode_tx.clone(); let vdes_shutdown_rx = shutdown_rx.clone(); let vdes_histories = histories.clone(); - let vdes_sr = (rig_cfg.sdr.sample_rate / (rig_cfg.sdr.sample_rate / 96_000).max(1)).max(1); + let vdes_sr = + (rig_cfg.sdr.sample_rate / (rig_cfg.sdr.sample_rate / 96_000).max(1)).max(1); handles.push(tokio::spawn(async move { tokio::select! { _ = audio::run_vdes_decoder(vdes_sr, vdes_iq_rx, vdes_state_rx, vdes_decode_tx, vdes_histories) => {} @@ -881,13 +879,12 @@ async fn main() -> DynResult<()> { OptionalSdrPcmRx, OptionalSdrAisPcmRx, OptionalSdrVdesIqRx, - ) = - if rig_cfg.rig.access.access_type.as_deref() == Some("sdr") { - let (rig, pcm_rx, ais_pcm_rx, vdes_iq_rx) = build_sdr_rig_from_instance(rig_cfg)?; - (Some(rig), Some(pcm_rx), Some(ais_pcm_rx), Some(vdes_iq_rx)) - } else { - (None, None, None, None) - }; + ) = if rig_cfg.rig.access.access_type.as_deref() == Some("sdr") { + let (rig, pcm_rx, ais_pcm_rx, vdes_iq_rx) = build_sdr_rig_from_instance(rig_cfg)?; + (Some(rig), Some(pcm_rx), Some(ais_pcm_rx), Some(vdes_iq_rx)) + } else { + (None, None, None, None) + }; #[cfg(not(feature = "soapysdr"))] let (sdr_prebuilt_rig, sdr_pcm_rx, sdr_ais_pcm_rx, sdr_vdes_iq_rx): (