summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2017-07-03 21:43:40 +0200
committerJustin Worthe <justin@worthe-it.co.za>2017-07-03 21:43:40 +0200
commitdee56085f9eb96a374e609cd1dbb557ba8b4b82c (patch)
treec074f11781f7f62101056a474fe666dbc9527028 /src
parent8100c984a9dd98332cd968b8828c247aaa85d04a (diff)
Hid correlation chart by default
Diffstat (limited to 'src')
-rw-r--r--src/gui.rs20
1 files changed, 12 insertions, 8 deletions
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<Vec<f64>>, 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<Vec<f64>>, 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);
+ }
};
}
});