[perf](trx-server): reduce headless scheduler audio cpu
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -575,6 +575,12 @@ fn spawn_rig_audio_stack(
|
|||||||
loop {
|
loop {
|
||||||
match sdr_rx.recv().await {
|
match sdr_rx.recv().await {
|
||||||
Ok(frame) => {
|
Ok(frame) => {
|
||||||
|
let has_audio_clients = rx_audio_tx_sdr.receiver_count() > 0;
|
||||||
|
if !has_audio_clients {
|
||||||
|
let _ = pcm_tx_clone.send(frame);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let pcm_frame = match sdr_channels {
|
let pcm_frame = match sdr_channels {
|
||||||
1 => frame,
|
1 => frame,
|
||||||
2 => {
|
2 => {
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ impl SdrPipeline {
|
|||||||
wfm_deemphasis_us,
|
wfm_deemphasis_us,
|
||||||
wfm_stereo,
|
wfm_stereo,
|
||||||
fir_taps,
|
fir_taps,
|
||||||
|
channel_idx == 0,
|
||||||
channel_squelch_cfg,
|
channel_squelch_cfg,
|
||||||
pcm_tx.clone(),
|
pcm_tx.clone(),
|
||||||
iq_tx.clone(),
|
iq_tx.clone(),
|
||||||
@@ -233,6 +234,7 @@ impl SdrPipeline {
|
|||||||
self.wfm_deemphasis_us,
|
self.wfm_deemphasis_us,
|
||||||
self.wfm_stereo,
|
self.wfm_stereo,
|
||||||
fir_taps.max(1),
|
fir_taps.max(1),
|
||||||
|
false,
|
||||||
VirtualSquelchConfig::default(),
|
VirtualSquelchConfig::default(),
|
||||||
pcm_tx.clone(),
|
pcm_tx.clone(),
|
||||||
iq_tx.clone(),
|
iq_tx.clone(),
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ pub struct ChannelDsp {
|
|||||||
audio_agc: SoftAgc,
|
audio_agc: SoftAgc,
|
||||||
audio_dc: Option<DcBlocker>,
|
audio_dc: Option<DcBlocker>,
|
||||||
processing_enabled: bool,
|
processing_enabled: bool,
|
||||||
|
force_mono_pcm: bool,
|
||||||
squelch: VirtualSquelch,
|
squelch: VirtualSquelch,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,6 +270,7 @@ impl ChannelDsp {
|
|||||||
wfm_deemphasis_us: u32,
|
wfm_deemphasis_us: u32,
|
||||||
wfm_stereo: bool,
|
wfm_stereo: bool,
|
||||||
fir_taps: usize,
|
fir_taps: usize,
|
||||||
|
force_mono_pcm: bool,
|
||||||
squelch_cfg: VirtualSquelchConfig,
|
squelch_cfg: VirtualSquelchConfig,
|
||||||
pcm_tx: broadcast::Sender<Vec<f32>>,
|
pcm_tx: broadcast::Sender<Vec<f32>>,
|
||||||
iq_tx: broadcast::Sender<Vec<Complex<f32>>>,
|
iq_tx: broadcast::Sender<Vec<Complex<f32>>>,
|
||||||
@@ -348,6 +350,7 @@ impl ChannelDsp {
|
|||||||
audio_agc: agc_for_mode(mode, audio_sample_rate),
|
audio_agc: agc_for_mode(mode, audio_sample_rate),
|
||||||
audio_dc: dc_for_mode(mode),
|
audio_dc: dc_for_mode(mode),
|
||||||
processing_enabled: true,
|
processing_enabled: true,
|
||||||
|
force_mono_pcm,
|
||||||
squelch: VirtualSquelch::new(squelch_cfg),
|
squelch: VirtualSquelch::new(squelch_cfg),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,6 +359,10 @@ impl ChannelDsp {
|
|||||||
self.processing_enabled = enabled;
|
self.processing_enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_force_mono_pcm(&mut self, enabled: bool) {
|
||||||
|
self.force_mono_pcm = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_squelch(&mut self, enabled: bool, threshold_db: f32) {
|
pub fn set_squelch(&mut self, enabled: bool, threshold_db: f32) {
|
||||||
self.squelch.set_enabled(enabled);
|
self.squelch.set_enabled(enabled);
|
||||||
self.squelch.set_threshold_db(threshold_db);
|
self.squelch.set_threshold_db(threshold_db);
|
||||||
@@ -548,7 +555,7 @@ impl ChannelDsp {
|
|||||||
}
|
}
|
||||||
*sample = self.audio_agc.process(*sample);
|
*sample = self.audio_agc.process(*sample);
|
||||||
}
|
}
|
||||||
if self.output_channels >= 2 {
|
if self.output_channels >= 2 && !self.force_mono_pcm {
|
||||||
let mut stereo = Vec::with_capacity(raw.len() * self.output_channels);
|
let mut stereo = Vec::with_capacity(raw.len() * self.output_channels);
|
||||||
for sample in raw {
|
for sample in raw {
|
||||||
stereo.push(sample);
|
stereo.push(sample);
|
||||||
|
|||||||
@@ -203,6 +203,13 @@ impl SdrVirtualChannelManager {
|
|||||||
hidden,
|
hidden,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if hidden {
|
||||||
|
let dsps = self.pipeline.channel_dsps.read().unwrap();
|
||||||
|
if let Some(dsp_arc) = dsps.get(pipeline_slot) {
|
||||||
|
dsp_arc.lock().unwrap().set_force_mono_pcm(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(pcm_rx)
|
Ok(pcm_rx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user