From d8d9fc0651d3d7538356d7a2a999522b38317810 Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Sun, 19 Apr 2020 22:24:23 +0300 Subject: [PATCH] Fix crash with JNI bindings during audio buffer overrun Former-commit-id: 0bb39e057c5aa81c5f491314125a8853b1f65ab0 --- bindings/rustboyadvance-jni/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bindings/rustboyadvance-jni/src/lib.rs b/bindings/rustboyadvance-jni/src/lib.rs index aaeb5ec..a8efb56 100644 --- a/bindings/rustboyadvance-jni/src/lib.rs +++ b/bindings/rustboyadvance-jni/src/lib.rs @@ -46,8 +46,12 @@ impl VideoInterface for Hardware { } impl AudioInterface for Hardware { fn push_sample(&mut self, sample: StereoSample) { - self.audio_buffer.prod.push(sample.0).unwrap(); - self.audio_buffer.prod.push(sample.1).unwrap(); + if self.audio_buffer.prod.push(sample.0).is_err() { + warn!("failed to push audio sample"); + } + if self.audio_buffer.prod.push(sample.1).is_err() { + warn!("failed to push audio sample"); + } } } impl InputInterface for Hardware {