Feat: fixing stderr catching and scope not drawing completely
This commit is contained in:
@@ -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}"))?;
|
||||
|
||||
Reference in New Issue
Block a user