Add per-channel RDS overlays for WFM vchans

This commit is contained in:
2026-03-11 22:39:02 +01:00
parent 21972c27d2
commit 93ff35a824
14 changed files with 313 additions and 100 deletions
+2
View File
@@ -544,8 +544,10 @@ async fn process_command(
RigCommand::GetSpectrum => {
// Fetch current spectrum and embed it in a one-shot snapshot.
ctx.state.spectrum = ctx.rig.get_spectrum();
ctx.state.vchan_rds = ctx.rig.get_vchan_rds();
let result = snapshot_from(ctx.state);
ctx.state.spectrum = None; // don't persist in ongoing state
ctx.state.vchan_rds = None; // don't persist in ongoing state
return result;
}
_ => {} // fall through to normal rig handler
@@ -13,7 +13,7 @@ use std::sync::{Arc, Mutex};
use trx_core::radio::freq::{Band, Freq};
use trx_core::rig::response::RigError;
use trx_core::rig::state::{RigFilterState, SpectrumData, WfmDenoiseLevel};
use trx_core::rig::state::{RigFilterState, SpectrumData, VchanRdsEntry, WfmDenoiseLevel};
use trx_core::rig::{
AudioSource, Rig, RigAccessMethod, RigCapabilities, RigCat, RigInfo, RigStatusFuture,
};
@@ -820,6 +820,10 @@ impl RigCat for SoapySdrRig {
})
}
fn get_vchan_rds(&self) -> Option<Vec<VchanRdsEntry>> {
Some(self.channel_manager.rds_snapshots())
}
/// Override: this backend provides demodulated PCM audio.
fn as_audio_source(&self) -> Option<&dyn AudioSource> {
Some(self)
@@ -26,7 +26,7 @@ use std::sync::{Arc, RwLock};
use num_complex::Complex;
use tokio::sync::broadcast;
use trx_core::rig::state::RigMode;
use trx_core::rig::state::{RigMode, VchanRdsEntry};
use uuid::Uuid;
use crate::dsp::SdrPipeline;
@@ -184,6 +184,22 @@ impl SdrVirtualChannelManager {
ch.mode = mode.clone();
}
}
/// Snapshot RDS data for each WFM virtual channel (including primary).
pub fn rds_snapshots(&self) -> Vec<VchanRdsEntry> {
let channels = self.channels.read().unwrap();
let dsps = self.pipeline.channel_dsps.read().unwrap();
channels
.iter()
.filter(|ch| matches!(ch.mode, RigMode::WFM))
.map(|ch| {
let rds = dsps
.get(ch.pipeline_slot)
.and_then(|dsp| dsp.lock().ok().and_then(|d| d.rds_data()));
VchanRdsEntry { id: ch.id, rds }
})
.collect()
}
}
impl VirtualChannelManager for SdrVirtualChannelManager {