From 5c8699690ac907882615ba8f01eebb9e39699f50 Mon Sep 17 00:00:00 2001 From: Xerxes Rånby Date: Tue, 16 Jul 2013 13:26:48 +0200 Subject: ALAudioSink: Reduce exessive CPU usage caused by polling alGetSourcei. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes Rånby --- src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java index c8004d6b3..690948c5a 100644 --- a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java @@ -3,6 +3,8 @@ package jogamp.opengl.openal.av; import java.nio.Buffer; import java.nio.ByteBuffer; +import java.lang.InterruptedException; + import jogamp.opengl.util.av.AudioSink; import com.jogamp.common.nio.Buffers; @@ -135,6 +137,12 @@ public class ALAudioSink implements AudioSink { int[] val=new int[1]; do { al.alGetSourcei(source[0], AL.AL_BUFFERS_PROCESSED, val, 0); + if(val[0] <= 0){ + try { + Thread.sleep(1); + } catch (InterruptedException e){ + } + } } while (val[0] <= 0); // fill and requeue the empty buffer -- cgit v1.2.3