Feat: fixing stderr catching and scope not drawing completely

This commit is contained in:
2026-02-23 21:53:53 +01:00
parent e7137cc7ed
commit 502f7afe8f
4 changed files with 31 additions and 4 deletions

View File

@@ -251,7 +251,7 @@ use cpal::traits::{DeviceTrait, StreamTrait};
#[cfg(feature = "cli")]
use cpal::Stream;
#[cfg(feature = "cli")]
use crossbeam_channel::Receiver;
use crossbeam_channel::{Receiver, Sender};
#[cfg(feature = "cli")]
use doux::{Engine, EngineMetrics};
@@ -274,6 +274,7 @@ pub struct AudioStreamInfo {
}
#[cfg(feature = "cli")]
#[allow(clippy::too_many_arguments)]
pub fn build_stream(
config: &AudioStreamConfig,
audio_rx: Receiver<AudioCommand>,
@@ -282,6 +283,7 @@ pub fn build_stream(
metrics: Arc<EngineMetrics>,
initial_samples: Vec<doux::sampling::SampleEntry>,
audio_sample_pos: Arc<AtomicU64>,
error_tx: Sender<String>,
) -> Result<
(
Stream,
@@ -375,15 +377,15 @@ pub fn build_stream(
engine.metrics.load.set_buffer_time(buffer_time_ns);
engine.process_block(data, &[], &[]);
scope_buffer.write(&engine.output);
scope_buffer.write(data);
// Feed mono mix to analysis thread via ring buffer (non-blocking)
for chunk in engine.output.chunks(channels) {
for chunk in data.chunks(channels) {
let mono = chunk.iter().sum::<f32>() / channels as f32;
let _ = fft_producer.try_push(mono);
}
},
|err| eprintln!("stream error: {err}"),
move |err| { let _ = error_tx.try_send(format!("stream error: {err}")); },
None,
)
.map_err(|e| format!("Failed to build stream: {e}"))?;