diff --git a/gb-vst/src/ui.rs b/gb-vst/src/ui.rs index 750b45d..f00f6b7 100644 --- a/gb-vst/src/ui.rs +++ b/gb-vst/src/ui.rs @@ -114,21 +114,17 @@ fn init_pixbuf(info: WindowInfo, window: &mut Window) -> (Pixels, usize) { impl WindowHandler for EmulatorWindow { fn on_frame(&mut self, _window: &mut Window) { if let Some(ref mut receiver) = *self.frame_receiver.lock().expect("failed to lock mutex") { - match receiver.recv() { - Ok(buf) => { - let scaled_buf = if self.scale != 1 { - scale_buffer(&buf, WIDTH, HEIGHT, self.scale) - } else { - buf - }; - for (pixel, source) in - self.pix.get_frame_mut().chunks_exact_mut(4).zip(scaled_buf) - { - pixel.copy_from_slice(&source); - } - self.pix.render().unwrap(); + if let Some(buf) = receiver.try_iter().last() { + let scaled_buf = if self.scale != 1 { + scale_buffer(&buf, WIDTH, HEIGHT, self.scale) + } else { + buf + }; + for (pixel, source) in self.pix.get_frame_mut().chunks_exact_mut(4).zip(scaled_buf) + { + pixel.copy_from_slice(&source); } - Err(e) => nih_log!("recv error: {e}"), + self.pix.render().unwrap(); } } }