diff options
author | Xerxes Rånby <[email protected]> | 2013-07-16 13:26:48 +0200 |
---|---|---|
committer | Xerxes Rånby <[email protected]> | 2013-07-16 13:26:48 +0200 |
commit | 5c8699690ac907882615ba8f01eebb9e39699f50 (patch) | |
tree | 2c3dcb570973298bc9da7d3952b4b7f92def79ff /src/jogl/classes/jogamp/opengl/openal | |
parent | 32210a87c2d9b10e04a773fa1b86f8f543d83af0 (diff) |
ALAudioSink: Reduce exessive CPU usage caused by polling alGetSourcei.
Signed-off-by: Xerxes Rånby <[email protected]>
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/openal')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java | 8 |
1 files changed, 8 insertions, 0 deletions
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 |