try_recv to remove unwrap

This commit is contained in:
Gwilym Inzani 2024-07-10 09:52:07 +01:00
parent afddd77ce8
commit 45f8a52eb5

View file

@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn Error>> {
&config.into(),
move |data: &mut [f32], _| {
for val in data.iter_mut() {
*val = rx.recv().unwrap();
*val = rx.try_recv().unwrap_or(0.0);
}
},
|err| eprintln!("Error on audio stream {err}"),