diff options
author | Carsten Weisse <[email protected]> | 2005-04-26 22:39:34 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2005-04-26 22:39:34 +0000 |
commit | 696d1c5a364a00be29952e8b75086baadccbfccf (patch) | |
tree | 1d269247acc9b48b06b537e9ccf4039c4035bae2 /src/jake2/sound/joal | |
parent | c93689282fdf3c46f5b8a81eacba4a87567f8ecc (diff) |
code cleanup
Diffstat (limited to 'src/jake2/sound/joal')
-rw-r--r-- | src/jake2/sound/joal/JOALSoundImpl.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/jake2/sound/joal/JOALSoundImpl.java b/src/jake2/sound/joal/JOALSoundImpl.java index 348bf11..69e8683 100644 --- a/src/jake2/sound/joal/JOALSoundImpl.java +++ b/src/jake2/sound/joal/JOALSoundImpl.java @@ -2,7 +2,7 @@ * JOALSoundImpl.java * Copyright (C) 2004 * - * $Id: JOALSoundImpl.java,v 1.11 2005-04-26 20:17:54 cawe Exp $ + * $Id: JOALSoundImpl.java,v 1.12 2005-04-26 22:39:34 cawe Exp $ */ package jake2.sound.joal; @@ -14,6 +14,7 @@ import jake2.sound.*; import jake2.util.Lib; import jake2.util.Vargs; +import java.awt.image.SampleModel; import java.io.*; import java.nio.IntBuffer; @@ -176,18 +177,9 @@ public final class JOALSoundImpl implements Sound { /* (non-Javadoc) * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t) */ - private void initBuffer(sfx_t sfx) { - if (sfx.cache == null ) { - //System.out.println(sfx.name + " " + sfx.cache.length+ " " + sfx.cache.loopstart + " " + sfx.cache.speed + " " + sfx.cache.stereo + " " + sfx.cache.width); - return; - } - - int format = AL.AL_FORMAT_MONO16; - byte[] data = sfx.cache.data; - int freq = sfx.cache.speed; - int size = data.length; - - al.alBufferData( buffers[sfx.bufferId], format, data, size, freq); + private void initBuffer(byte[] samples, int bufferId, int freq) { + al.alBufferData(buffers[bufferId], AL.AL_FORMAT_MONO16, samples, + samples.length, freq); } private void checkError() { @@ -512,8 +504,10 @@ public final class JOALSoundImpl implements Sound { if (s.isCached) return s.cache; sfxcache_t sc = WaveLoader.LoadSound(s); if (sc != null) { - initBuffer(s); + initBuffer(sc.data, s.bufferId, sc.speed); s.isCached = true; + // free samples for GC + s.cache.data = null; } return sc; } |