From 8982276a9059b8e2f38034ecf526085f83b1d920 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Thu, 30 Nov 2023 09:41:12 -0700 Subject: [PATCH] not infinite buffer --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3929704..6392fd3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -121,7 +121,7 @@ fn new_listener() -> Listener { impl Listener { fn listen(self, mut cb: impl FnMut(Vec)) { - let (send, recv) = std::sync::mpsc::channel(); + let (send, recv) = std::sync::mpsc::sync_channel(5_000_000); thread::spawn(move || { self._listen(send); }); loop { match recv.recv() { @@ -131,7 +131,7 @@ impl Listener { } } - fn _listen(self, ch: std::sync::mpsc::Sender>) { + fn _listen(self, ch: std::sync::mpsc::SyncSender>) { let host = cpal::default_host(); let device = host.default_input_device().unwrap(); let cfg = device.supported_input_configs()