mod: ALUT removed, caused waaay to many headaches

This commit is contained in:
Brian Matzon 2002-12-18 16:54:50 +00:00
parent 91df757aba
commit 602a155986
9 changed files with 56 additions and 762 deletions

View file

@ -1,134 +0,0 @@
/*
* Copyright (c) 2002 Light Weight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.openal;
/**
* $Id$
*
* This is the utility class for OpenAL. This class implements functions
* in alut.h
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
*/
public class ALUT {
/** Has the ALUT object been created? */
protected static boolean created;
static {
initialize();
}
/** Creates a new instance of ALUT */
public ALUT() {
}
/**
* Override to provide any initialization code after creation.
*/
protected void init() {
}
/**
* Static initialization
*/
private static void initialize() {
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
}
/**
* Creates the ALUT instance
*
* @throws Exception if a failiure occured in the ALUT creation process
*/
public void create() throws Exception {
if (created) {
return;
}
if (!nCreate()) {
throw new Exception("ALUT instance could not be created.");
}
created = true;
init();
}
/**
* Native method to create ALUT instance
*
* @return true if the ALUT creation process succeeded
*/
protected native boolean nCreate();
/**
* Calls whatever destruction rutines that are needed
*/
public void destroy() {
if (!created) {
return;
}
created = false;
nDestroy();
}
/**
* Native method the destroy the ALUT
*/
protected native void nDestroy();
/**
* Loads a wave file into memory
*
* @param file name of file to load (in current working directory)
* @return ALUTLoadWAVData object containing information regarding wave data loaded
*/
public native ALUTLoadWAVData loadWAVFile(String file);
/**
* Loads a byte buffer into memory
*
* @param buffer buffer address containing file
* @return ALUTLoadWAVData object containing information regarding wave data loaded
*/
public native ALUTLoadWAVData loadWAVMemory(int buffer);
/**
* Unloads the specified file from memory
*
* @param format OpenAL format specifier
* @param data address of data (pointer)
* @param size size of the data in bytes
* @param freq frequency of the data
*/
public native void unloadWAV(int format, int data, int size, int freq);
}

View file

@ -1,78 +0,0 @@
/*
* Copyright (c) 2002 Light Weight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.openal;
/**
* $Id$
*
* This class is used by the alutLoadWAVFile method. Since we
* cannot modify values supplied to the method (since JNI is pass by value)
* we return this object, which encapsulates the file loaded. Use this class
* when unloading using 'alutUnloadWAV'.
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
*/
public class ALUTLoadWAVData {
/* format of file */
public final int format;
/* pointer to data allocated */
public final int data;
/* size of data allocated */
public final int size;
/* frequency of sound data */
public final int freq;
/* whether or not to loop */
public final boolean loop;
/**
* Creates an ALUTLoadWAVFile object with specified properties
*
* @param format OpenAL format specifier
* @param data address of data (pointer)
* @param size size of the data in bytes
* @param freq frequency of the data
* @param loop looping indicator for the WAV data
*/
public ALUTLoadWAVData(int format, int data, int size, int freq, boolean loop) {
this.format = format;
this.data = data;
this.size = size;
this.freq = freq;
this.loop = loop;
}
}

View file

@ -35,7 +35,6 @@ import org.lwjgl.openal.AL;
import org.lwjgl.openal.ALC;
import org.lwjgl.openal.ALCcontext;
import org.lwjgl.openal.ALCdevice;
import org.lwjgl.openal.ALUTLoadWAVData;
import org.lwjgl.openal.eax.EAX;
import org.lwjgl.openal.eax.EAXBufferProperties;
import org.lwjgl.openal.eax.EAXListenerProperties;
@ -340,16 +339,16 @@ public class ALTest extends BasicTest {
// Load in samples to be used by Test functions
// Load footsteps.wav
ALUTLoadWAVData data = alut.loadWAVFile("Footsteps.wav");
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutLoadWAVFile footsteps.wav : ", error);
WaveData wavefile = WaveData.create("Footsteps.wav");
if (wavefile == null) {
displayALError("LoadWAVFile footsteps.wav : ", error);
// Delete Buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
// Copy footsteps.wav data into AL Buffer 0
al.bufferData(buffers.get(0), data.format, data.data, data.size, data.freq);
al.bufferData(buffers.get(0), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alBufferData buffer 0 : ", error);
// Delete buffers
@ -358,25 +357,20 @@ public class ALTest extends BasicTest {
}
// Unload footsteps.wav
alut.unloadWAV(data.format, data.data, data.size, data.freq);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutUnloadWAV : ", error);
// Delete buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
wavefile.dispose();
wavefile = null;
// Load ding.wav
data = alut.loadWAVFile("ding.wav");
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutLoadWAVFile ding.wav : ", error);
wavefile = WaveData.create("ding.wav");
if (wavefile == null) {
displayALError("LoadWAVFile ding.wav : ", error);
// Delete Buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
// Copy ding.wav data into AL Buffer 1
al.bufferData(buffers.get(1), data.format, data.data, data.size, data.freq);
al.bufferData(buffers.get(1), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alBufferData buffer 1 : ", error);
// Delete buffers
@ -385,25 +379,20 @@ public class ALTest extends BasicTest {
}
// Unload footsteps.wav
alut.unloadWAV(data.format, data.data, data.size, data.freq);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutUnloadWAV : ", error);
// Delete buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
wavefile.dispose();
wavefile = null;
// Load wave1.wav
data = alut.loadWAVFile("Wave1.WAV");
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutLoadWAVFile wave1.wav : ", error);
wavefile = WaveData.create("Wave1.WAV");
if (wavefile == null) {
displayALError("LoadWAVFile wave1.wav : ", error);
// Delete Buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
// Copy wave1.wav data into AL Buffer 2
al.bufferData(buffers.get(2), data.format, data.data, data.size, data.freq);
al.bufferData(buffers.get(2), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alBufferData buffer 2 : ", error);
// Delete buffers
@ -412,25 +401,20 @@ public class ALTest extends BasicTest {
}
// Unload wave1.wav
alut.unloadWAV(data.format, data.data, data.size, data.freq);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutUnloadWAV : ", error);
// Delete buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
wavefile.dispose();
wavefile = null;
// Load Wave2.wav
data = alut.loadWAVFile("Wave2.WAV");
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutLoadWAVFile Wave2.wav : ", error);
wavefile = WaveData.create("Wave2.WAV");
if (wavefile == null) {
displayALError("LoadWAVFile Wave2.wav : ", error);
// Delete Buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
// Copy Wave2.wav data into AL Buffer 3
al.bufferData(buffers.get(3), data.format, data.data, data.size, data.freq);
al.bufferData(buffers.get(3), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alBufferData buffer 3 : ", error);
// Delete buffers
@ -439,25 +423,20 @@ public class ALTest extends BasicTest {
}
// Unload Wave2.wav
alut.unloadWAV(data.format, data.data, data.size, data.freq);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutUnloadWAV : ", error);
// Delete buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
wavefile.dispose();
wavefile = null;
// Load wave3.wav
data = alut.loadWAVFile("Wave3.WAV");
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutLoadWAVFile wave3.wav : ", error);
wavefile = WaveData.create("Wave3.WAV");
if (wavefile == null) {
displayALError("LoadWAVFile wave3.wav : ", error);
// Delete Buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
// Copy wave3.wav data into AL Buffer 4
al.bufferData(buffers.get(4), data.format, data.data, data.size, data.freq);
al.bufferData(buffers.get(4), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alBufferData buffer 4 : ", error);
// Delete buffers
@ -466,25 +445,20 @@ public class ALTest extends BasicTest {
}
// Unload wave3.wav
alut.unloadWAV(data.format, data.data, data.size, data.freq);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutUnloadWAV : ", error);
// Delete buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
wavefile.dispose();
wavefile = null;
// Load wave4.wav
data = alut.loadWAVFile("Wave4.WAV");
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutLoadWAVFile wave4.wav : ", error);
wavefile = WaveData.create("Wave4.WAV");
if (wavefile == null) {
displayALError("LoadWAVFile wave4.wav : ", error);
// Delete Buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
// Copy wave4.wav data into AL Buffer 5
al.bufferData(buffers.get(5), data.format, data.data, data.size, data.freq);
al.bufferData(buffers.get(5), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alBufferData buffer 5 : ", error);
// Delete buffers
@ -493,25 +467,20 @@ public class ALTest extends BasicTest {
}
// Unload wave4.wav
alut.unloadWAV(data.format, data.data, data.size, data.freq);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutUnloadWAV : ", error);
// Delete buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
wavefile.dispose();
wavefile = null;
// Load stereo.wav
data = alut.loadWAVFile("stereo.wav");
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutLoadWAVFile stereo.wav : ", error);
wavefile = WaveData.create("stereo.wav");
if (wavefile == null) {
displayALError("LoadWAVFile stereo.wav : ", error);
// Delete Buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
// Copy stereo.wav data into AL Buffer 6
al.bufferData(buffers.get(6), data.format, data.data, data.size, data.freq);
al.bufferData(buffers.get(6), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alBufferData buffer 6 : ", error);
// Delete buffers
@ -520,13 +489,8 @@ public class ALTest extends BasicTest {
}
// Unload stereo.wav
alut.unloadWAV(data.format, data.data, data.size, data.freq);
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alutUnloadWAV : ", error);
// Delete buffers
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
System.exit(-1);
}
wavefile.dispose();
wavefile = null;
//do EAX check (can only be performed after device / context creation
eaxAvailable = al.isExtensionPresent("EAX");

View file

@ -1,165 +0,0 @@
/*
* Copyright (c) 2002 Light Weight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.test.openal;
import org.lwjgl.Sys;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.ALUTLoadWAVData;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* $Id$
*
* This is a basic play test using ALUT
* Yes, over zealous use of getError ;)
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
*/
public class ALUTTest extends BasicTest {
/**
* Creates an instance of ALUTTest
*/
public ALUTTest() {
super();
}
/**
* Runs the actual test, using supplied arguments
*/
protected void execute(String[] args) {
if(args.length < 1) {
System.out.println("please specify filename to play");
return;
}
int lastError;
//initialize AL
alInitialize();
//create 1 buffer and 1 source
ByteBuffer buffers = ByteBuffer.allocateDirect(4);
buffers.order(ByteOrder.nativeOrder());
ByteBuffer sources = ByteBuffer.allocateDirect(4);
sources.order(ByteOrder.nativeOrder());
// al generate buffers and sources
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
al.genSources(1, Sys.getDirectBufferAddress(sources));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//load wave data
ALUTLoadWAVData file = alut.loadWAVFile(args[0]);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//copy to buffers
al.bufferData(buffers.getInt(0), file.format, file.data, file.size, file.freq);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//unload file again
alut.unloadWAV(file.format, file.data, file.size, file.freq);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//set up source input
al.sourcei(sources.getInt(0), AL.BUFFER, buffers.getInt(0));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//lets loop the sound
al.sourcei(sources.getInt(0), AL.LOOPING, AL.TRUE);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//play source 0
al.sourcePlay(sources.getInt(0));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//wait 5 secs
try {
System.out.println("Waiting 5 seconds for sound to complete");
Thread.sleep(5000);
} catch (InterruptedException inte) {
}
//stop source 0
al.sourceStop(sources.getInt(0));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//delete buffers and sources
al.deleteSources(1, Sys.getDirectBufferAddress(sources));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//shutdown
alExit();
}
/**
* main entry point
*
* @param args String array containing arguments
*/
public static void main(String[] args) {
ALUTTest alutTest = new ALUTTest();
alutTest.execute(args);
}
}

View file

@ -35,7 +35,6 @@ import org.lwjgl.openal.AL;
import org.lwjgl.openal.ALC;
import org.lwjgl.openal.ALCcontext;
import org.lwjgl.openal.ALCdevice;
import org.lwjgl.openal.ALUT;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -56,10 +55,7 @@ public abstract class BasicTest {
/** OpenAL Context instance */
protected ALC alc;
/** OpenAL Util library instance */
protected ALUT alut;
/** OpenAL context */
protected ALCcontext context;
@ -84,15 +80,7 @@ public abstract class BasicTest {
} catch (Exception e) {
e.printStackTrace();
return;
}
alut = new ALUT();
try {
alut.create();
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}
/**
@ -152,7 +140,7 @@ public abstract class BasicTest {
temp.order(ByteOrder.nativeOrder());
return temp.asIntBuffer();
}
}
/**
* Exits the test NOW, printing errorcode to stdout

View file

@ -33,7 +33,6 @@ package org.lwjgl.test.openal;
import org.lwjgl.Sys;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.ALUTLoadWAVData;
import java.nio.IntBuffer;
@ -85,23 +84,16 @@ public class PlayTest extends BasicTest {
}
//load wave data
ALUTLoadWAVData file = alut.loadWAVFile(args[0]);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
WaveData wavefile = WaveData.create(args[0]);
//copy to buffers
al.bufferData(buffers.get(0), file.format, file.data, file.size, file.freq);
al.bufferData(buffers.get(0), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//unload file again
alut.unloadWAV(file.format, file.data, file.size, file.freq);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
wavefile.dispose();
//set up source input
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));

View file

@ -33,7 +33,6 @@ package org.lwjgl.test.openal;
import org.lwjgl.Sys;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.ALUTLoadWAVData;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
@ -97,23 +96,18 @@ public class PlayTestMemory extends BasicTest {
System.exit(-1);
}
ALUTLoadWAVData file = alut.loadWAVMemory(Sys.getDirectBufferAddress(filebuffer));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//ALUTLoadWAVData file = alut.loadWAVMemory(Sys.getDirectBufferAddress(filebuffer));
WaveData wavefile = WaveData.create(filebuffer.array());
//copy to buffers
al.bufferData(buffers.get(0), file.format, file.data, file.size, file.freq);
al.bufferData(buffers.get(0), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
}
//unload file again
alut.unloadWAV(file.format, file.data, file.size, file.freq);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
wavefile.dispose();
//set up source input
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
@ -158,7 +152,6 @@ public class PlayTestMemory extends BasicTest {
}
//no errorchecking from now on, since our context is gone.
//shutdown
alExit();
}
@ -198,7 +191,7 @@ public class PlayTestMemory extends BasicTest {
//done reading, close
bis.close();
buffer = ByteBuffer.allocateDirect(baos.size());
buffer = ByteBuffer.allocate(baos.size());
buffer.order(ByteOrder.nativeOrder());
buffer.put(baos.toByteArray());
} catch (Exception ioe) {