From 89df7909d3d178e018941c556f3e470dfe6edae6 Mon Sep 17 00:00:00 2001 From: matthias plasser Date: Wed, 15 Apr 2020 21:33:39 +0200 Subject: [PATCH] Fixes #1341: AudioBuffer.updateData only allows direct buffers (#1342) * only allowing direct buffers now, see: https://hub.jmonkeyengine.org/t/solved-playing-audio-from-audiobuffer-in-audionode-causes-jre-to-die/43091/12 * style correction Co-authored-by: Stephen Gold --- jme3-core/src/main/java/com/jme3/audio/AudioBuffer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/audio/AudioBuffer.java b/jme3-core/src/main/java/com/jme3/audio/AudioBuffer.java index 8350d995b..ec992a3cf 100644 --- a/jme3-core/src/main/java/com/jme3/audio/AudioBuffer.java +++ b/jme3-core/src/main/java/com/jme3/audio/AudioBuffer.java @@ -31,9 +31,9 @@ */ package com.jme3.audio; -import com.jme3.audio.AudioData.DataType; import com.jme3.util.BufferUtils; import com.jme3.util.NativeObject; + import java.nio.ByteBuffer; /** @@ -87,8 +87,14 @@ public class AudioBuffer extends AudioData { /** * Update the data in the buffer with new data. * @param data + * @throws IllegalArgumentException if the provided buffer is not a direct buffer */ public void updateData(ByteBuffer data){ + if (!data.isDirect()) { + throw new IllegalArgumentException( + "Currently only direct buffers are allowed"); + } + this.audioData = data; updateNeeded = true; }