[feat](trx-server): handle virtual channel bandwidth updates
Handle AUDIO_MSG_VCHAN_BW in the audio server path and apply per-channel filter bandwidth through the SoapySDR virtual channel manager. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -27,7 +27,8 @@ use trx_core::audio::{
|
|||||||
AUDIO_MSG_AIS_DECODE, AUDIO_MSG_APRS_DECODE, AUDIO_MSG_CW_DECODE, AUDIO_MSG_FT8_DECODE,
|
AUDIO_MSG_AIS_DECODE, AUDIO_MSG_APRS_DECODE, AUDIO_MSG_CW_DECODE, AUDIO_MSG_FT8_DECODE,
|
||||||
AUDIO_MSG_HF_APRS_DECODE, AUDIO_MSG_HISTORY_COMPRESSED, AUDIO_MSG_RX_FRAME,
|
AUDIO_MSG_HF_APRS_DECODE, AUDIO_MSG_HISTORY_COMPRESSED, AUDIO_MSG_RX_FRAME,
|
||||||
AUDIO_MSG_STREAM_INFO, AUDIO_MSG_TX_FRAME, AUDIO_MSG_VCHAN_ALLOCATED,
|
AUDIO_MSG_STREAM_INFO, AUDIO_MSG_TX_FRAME, AUDIO_MSG_VCHAN_ALLOCATED,
|
||||||
AUDIO_MSG_VCHAN_DESTROYED, AUDIO_MSG_VCHAN_FREQ, AUDIO_MSG_VCHAN_MODE, AUDIO_MSG_VCHAN_REMOVE,
|
AUDIO_MSG_VCHAN_BW, AUDIO_MSG_VCHAN_DESTROYED, AUDIO_MSG_VCHAN_FREQ, AUDIO_MSG_VCHAN_MODE,
|
||||||
|
AUDIO_MSG_VCHAN_REMOVE,
|
||||||
AUDIO_MSG_VCHAN_SUB, AUDIO_MSG_VCHAN_UNSUB, AUDIO_MSG_VDES_DECODE, AUDIO_MSG_WSPR_DECODE,
|
AUDIO_MSG_VCHAN_SUB, AUDIO_MSG_VCHAN_UNSUB, AUDIO_MSG_VDES_DECODE, AUDIO_MSG_WSPR_DECODE,
|
||||||
};
|
};
|
||||||
use trx_core::vchan::SharedVChanManager;
|
use trx_core::vchan::SharedVChanManager;
|
||||||
@@ -2183,6 +2184,20 @@ async fn handle_audio_client(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok((AUDIO_MSG_VCHAN_BW, payload)) => {
|
||||||
|
if let Some(ref mgr) = vchan_manager {
|
||||||
|
if let Ok(v) = serde_json::from_slice::<serde_json::Value>(&payload) {
|
||||||
|
if let (Some(uuid), Some(bandwidth_hz)) = (
|
||||||
|
v["uuid"].as_str().and_then(|s| s.parse::<Uuid>().ok()),
|
||||||
|
v["bandwidth_hz"].as_u64().map(|b| b as u32),
|
||||||
|
) {
|
||||||
|
if let Err(e) = mgr.set_channel_bandwidth(uuid, bandwidth_hz) {
|
||||||
|
warn!("Audio vchan BW: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok((AUDIO_MSG_VCHAN_REMOVE, payload)) => {
|
Ok((AUDIO_MSG_VCHAN_REMOVE, payload)) => {
|
||||||
match parse_vchan_uuid_msg(&payload) {
|
match parse_vchan_uuid_msg(&payload) {
|
||||||
Ok(uuid) => {
|
Ok(uuid) => {
|
||||||
|
|||||||
@@ -295,6 +295,20 @@ impl VirtualChannelManager for SdrVirtualChannelManager {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_channel_bandwidth(&self, id: Uuid, bandwidth_hz: u32) -> Result<(), VChanError> {
|
||||||
|
let channels = self.channels.read().unwrap();
|
||||||
|
let ch = channels
|
||||||
|
.iter()
|
||||||
|
.find(|c| c.id == id)
|
||||||
|
.ok_or(VChanError::NotFound)?;
|
||||||
|
|
||||||
|
let dsps = self.pipeline.channel_dsps.read().unwrap();
|
||||||
|
if let Some(dsp_arc) = dsps.get(ch.pipeline_slot) {
|
||||||
|
dsp_arc.lock().unwrap().set_filter(bandwidth_hz, DEFAULT_FIR_TAPS);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn subscribe_pcm(&self, id: Uuid) -> Option<broadcast::Receiver<Vec<f32>>> {
|
fn subscribe_pcm(&self, id: Uuid) -> Option<broadcast::Receiver<Vec<f32>>> {
|
||||||
let channels = self.channels.read().unwrap();
|
let channels = self.channels.read().unwrap();
|
||||||
channels
|
channels
|
||||||
|
|||||||
Reference in New Issue
Block a user