Wip: refacto
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -116,7 +116,7 @@ fn main() -> io::Result<()> {
|
||||
max_voices: app.audio.config.max_voices,
|
||||
};
|
||||
|
||||
let mut _stream = match build_stream(
|
||||
let (mut _stream, mut _analysis_handle) = match build_stream(
|
||||
&stream_config,
|
||||
sequencer.audio_rx.clone(),
|
||||
Arc::clone(&scope_buffer),
|
||||
@@ -124,14 +124,14 @@ fn main() -> io::Result<()> {
|
||||
Arc::clone(&metrics),
|
||||
initial_samples,
|
||||
) {
|
||||
Ok((s, sample_rate)) => {
|
||||
Ok((s, sample_rate, analysis)) => {
|
||||
app.audio.config.sample_rate = sample_rate;
|
||||
Some(s)
|
||||
(Some(s), Some(analysis))
|
||||
}
|
||||
Err(e) => {
|
||||
app.ui.set_status(format!("Audio failed: {e}"));
|
||||
app.audio.error = Some(e);
|
||||
None
|
||||
(None, None)
|
||||
}
|
||||
};
|
||||
app.mark_all_patterns_dirty();
|
||||
@@ -147,6 +147,7 @@ fn main() -> io::Result<()> {
|
||||
if app.audio.restart_pending {
|
||||
app.audio.restart_pending = false;
|
||||
_stream = None;
|
||||
_analysis_handle = None;
|
||||
|
||||
let new_config = AudioStreamConfig {
|
||||
output_device: app.audio.config.output_device.clone(),
|
||||
@@ -170,8 +171,9 @@ fn main() -> io::Result<()> {
|
||||
Arc::clone(&metrics),
|
||||
restart_samples,
|
||||
) {
|
||||
Ok((new_stream, sr)) => {
|
||||
Ok((new_stream, sr, new_analysis)) => {
|
||||
_stream = Some(new_stream);
|
||||
_analysis_handle = Some(new_analysis);
|
||||
app.audio.config.sample_rate = sr;
|
||||
app.audio.error = None;
|
||||
app.ui.set_status("Audio restarted".to_string());
|
||||
@@ -197,6 +199,7 @@ fn main() -> io::Result<()> {
|
||||
|
||||
let seq_snapshot = sequencer.snapshot();
|
||||
app.metrics.event_count = seq_snapshot.event_count;
|
||||
app.metrics.dropped_events = seq_snapshot.dropped_events;
|
||||
|
||||
app.flush_queued_changes(&sequencer.cmd_tx);
|
||||
app.flush_dirty_patterns(&sequencer.cmd_tx);
|
||||
|
||||
Reference in New Issue
Block a user