[style](trx-server): format audio and startup code
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -288,10 +288,7 @@ type SdrRigBuildResult = DynResult<(
|
||||
|
||||
type OptionalSdrRig = Option<Box<dyn trx_core::rig::RigCat>>;
|
||||
type OptionalSdrPcmRx = Option<broadcast::Receiver<Vec<f32>>>;
|
||||
type OptionalSdrAisPcmRx = Option<(
|
||||
broadcast::Receiver<Vec<f32>>,
|
||||
broadcast::Receiver<Vec<f32>>,
|
||||
)>;
|
||||
type OptionalSdrAisPcmRx = Option<(broadcast::Receiver<Vec<f32>>, broadcast::Receiver<Vec<f32>>)>;
|
||||
type OptionalSdrVdesIqRx = Option<broadcast::Receiver<Vec<num_complex::Complex<f32>>>>;
|
||||
|
||||
/// 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): (
|
||||
|
||||
Reference in New Issue
Block a user