From dee56085f9eb96a374e609cd1dbb557ba8b4b82c Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Mon, 3 Jul 2017 21:43:40 +0200 Subject: Hid correlation chart by default --- src/gui.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui.rs b/src/gui.rs index 595872d..d42b4c3 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -114,6 +114,10 @@ fn create_window(microphones: Vec<(u32, String)>) -> RustyUi { window.show_all(); + // correlation chart is only really useful for debugging, so it + // makes sense to have it default to being hidden + correlation_chart.set_visible(false); + RustyUi { dropdown: dropdown, pitch_label: pitch_label, @@ -155,12 +159,10 @@ fn start_processing_audio(mic_receiver: Receiver>, cross_thread_state: thread::spawn(move || { loop { let mut samples = None; - loop { - let next = mic_receiver.try_recv().ok(); - if next.is_none() { - break; - } - samples = next; + + // ignore all pending samples until we get to the most recent one + while let Ok(next_samples) = mic_receiver.try_recv() { + samples = Some(next_samples); } let samples = match samples { Some(samples) => samples, @@ -181,9 +183,11 @@ fn start_processing_audio(mic_receiver: Receiver>, cross_thread_state: state.pitch = pitch; state.signal = signal; state.correlation = correlation; - state.error = error + state.error = error; }, - Err(_) => {} + Err(err) => { + println!("Error updating cross thread state: {}", err); + } }; } }); -- cgit v1.2.3