From 3ac8312a931dc1957414962e7f20b06d1642e7d0 Mon Sep 17 00:00:00 2001 From: tomara_x <86204514+tomara-x@users.noreply.github.com> Date: Tue, 13 Aug 2024 18:49:57 +0300 Subject: [PATCH] avoid swap arity panic --- src/nodes.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/nodes.rs b/src/nodes.rs index 55cef10..d5d80da 100644 --- a/src/nodes.rs +++ b/src/nodes.rs @@ -547,14 +547,18 @@ impl AudioUnit for SwapUnit { fn tick(&mut self, input: &[f32], output: &mut [f32]) { if let Ok(net) = self.receiver.try_recv() { - self.x = net; + if self.x.inputs() == net.inputs() && self.x.outputs() == net.outputs() { + self.x = net; + } } self.x.tick(input, output); } fn process(&mut self, size: usize, input: &BufferRef, output: &mut BufferMut) { if let Ok(net) = self.receiver.try_recv() { - self.x = net; + if self.x.inputs() == net.inputs() && self.x.outputs() == net.outputs() { + self.x = net; + } } self.x.process(size, input, output); }