mod: ALUT removed, caused waaay to many headaches
This commit is contained in:
parent
91df757aba
commit
602a155986
|
@ -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);
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,6 @@ import org.lwjgl.openal.AL;
|
||||||
import org.lwjgl.openal.ALC;
|
import org.lwjgl.openal.ALC;
|
||||||
import org.lwjgl.openal.ALCcontext;
|
import org.lwjgl.openal.ALCcontext;
|
||||||
import org.lwjgl.openal.ALCdevice;
|
import org.lwjgl.openal.ALCdevice;
|
||||||
import org.lwjgl.openal.ALUTLoadWAVData;
|
|
||||||
import org.lwjgl.openal.eax.EAX;
|
import org.lwjgl.openal.eax.EAX;
|
||||||
import org.lwjgl.openal.eax.EAXBufferProperties;
|
import org.lwjgl.openal.eax.EAXBufferProperties;
|
||||||
import org.lwjgl.openal.eax.EAXListenerProperties;
|
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 in samples to be used by Test functions
|
||||||
// Load footsteps.wav
|
// Load footsteps.wav
|
||||||
ALUTLoadWAVData data = alut.loadWAVFile("Footsteps.wav");
|
WaveData wavefile = WaveData.create("Footsteps.wav");
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
if (wavefile == null) {
|
||||||
displayALError("alutLoadWAVFile footsteps.wav : ", error);
|
displayALError("LoadWAVFile footsteps.wav : ", error);
|
||||||
// Delete Buffers
|
// Delete Buffers
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy footsteps.wav data into AL Buffer 0
|
// 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) {
|
if ((error = al.getError()) != AL.NO_ERROR) {
|
||||||
displayALError("alBufferData buffer 0 : ", error);
|
displayALError("alBufferData buffer 0 : ", error);
|
||||||
// Delete buffers
|
// Delete buffers
|
||||||
|
@ -358,25 +357,20 @@ public class ALTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload footsteps.wav
|
// Unload footsteps.wav
|
||||||
alut.unloadWAV(data.format, data.data, data.size, data.freq);
|
wavefile.dispose();
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
wavefile = null;
|
||||||
displayALError("alutUnloadWAV : ", error);
|
|
||||||
// Delete buffers
|
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load ding.wav
|
// Load ding.wav
|
||||||
data = alut.loadWAVFile("ding.wav");
|
wavefile = WaveData.create("ding.wav");
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
if (wavefile == null) {
|
||||||
displayALError("alutLoadWAVFile ding.wav : ", error);
|
displayALError("LoadWAVFile ding.wav : ", error);
|
||||||
// Delete Buffers
|
// Delete Buffers
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy ding.wav data into AL Buffer 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) {
|
if ((error = al.getError()) != AL.NO_ERROR) {
|
||||||
displayALError("alBufferData buffer 1 : ", error);
|
displayALError("alBufferData buffer 1 : ", error);
|
||||||
// Delete buffers
|
// Delete buffers
|
||||||
|
@ -385,25 +379,20 @@ public class ALTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload footsteps.wav
|
// Unload footsteps.wav
|
||||||
alut.unloadWAV(data.format, data.data, data.size, data.freq);
|
wavefile.dispose();
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
wavefile = null;
|
||||||
displayALError("alutUnloadWAV : ", error);
|
|
||||||
// Delete buffers
|
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load wave1.wav
|
// Load wave1.wav
|
||||||
data = alut.loadWAVFile("Wave1.WAV");
|
wavefile = WaveData.create("Wave1.WAV");
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
if (wavefile == null) {
|
||||||
displayALError("alutLoadWAVFile wave1.wav : ", error);
|
displayALError("LoadWAVFile wave1.wav : ", error);
|
||||||
// Delete Buffers
|
// Delete Buffers
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy wave1.wav data into AL Buffer 2
|
// 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) {
|
if ((error = al.getError()) != AL.NO_ERROR) {
|
||||||
displayALError("alBufferData buffer 2 : ", error);
|
displayALError("alBufferData buffer 2 : ", error);
|
||||||
// Delete buffers
|
// Delete buffers
|
||||||
|
@ -412,25 +401,20 @@ public class ALTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload wave1.wav
|
// Unload wave1.wav
|
||||||
alut.unloadWAV(data.format, data.data, data.size, data.freq);
|
wavefile.dispose();
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
wavefile = null;
|
||||||
displayALError("alutUnloadWAV : ", error);
|
|
||||||
// Delete buffers
|
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load Wave2.wav
|
// Load Wave2.wav
|
||||||
data = alut.loadWAVFile("Wave2.WAV");
|
wavefile = WaveData.create("Wave2.WAV");
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
if (wavefile == null) {
|
||||||
displayALError("alutLoadWAVFile Wave2.wav : ", error);
|
displayALError("LoadWAVFile Wave2.wav : ", error);
|
||||||
// Delete Buffers
|
// Delete Buffers
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy Wave2.wav data into AL Buffer 3
|
// 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) {
|
if ((error = al.getError()) != AL.NO_ERROR) {
|
||||||
displayALError("alBufferData buffer 3 : ", error);
|
displayALError("alBufferData buffer 3 : ", error);
|
||||||
// Delete buffers
|
// Delete buffers
|
||||||
|
@ -439,25 +423,20 @@ public class ALTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload Wave2.wav
|
// Unload Wave2.wav
|
||||||
alut.unloadWAV(data.format, data.data, data.size, data.freq);
|
wavefile.dispose();
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
wavefile = null;
|
||||||
displayALError("alutUnloadWAV : ", error);
|
|
||||||
// Delete buffers
|
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load wave3.wav
|
// Load wave3.wav
|
||||||
data = alut.loadWAVFile("Wave3.WAV");
|
wavefile = WaveData.create("Wave3.WAV");
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
if (wavefile == null) {
|
||||||
displayALError("alutLoadWAVFile wave3.wav : ", error);
|
displayALError("LoadWAVFile wave3.wav : ", error);
|
||||||
// Delete Buffers
|
// Delete Buffers
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy wave3.wav data into AL Buffer 4
|
// 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) {
|
if ((error = al.getError()) != AL.NO_ERROR) {
|
||||||
displayALError("alBufferData buffer 4 : ", error);
|
displayALError("alBufferData buffer 4 : ", error);
|
||||||
// Delete buffers
|
// Delete buffers
|
||||||
|
@ -466,25 +445,20 @@ public class ALTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload wave3.wav
|
// Unload wave3.wav
|
||||||
alut.unloadWAV(data.format, data.data, data.size, data.freq);
|
wavefile.dispose();
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
wavefile = null;
|
||||||
displayALError("alutUnloadWAV : ", error);
|
|
||||||
// Delete buffers
|
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load wave4.wav
|
// Load wave4.wav
|
||||||
data = alut.loadWAVFile("Wave4.WAV");
|
wavefile = WaveData.create("Wave4.WAV");
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
if (wavefile == null) {
|
||||||
displayALError("alutLoadWAVFile wave4.wav : ", error);
|
displayALError("LoadWAVFile wave4.wav : ", error);
|
||||||
// Delete Buffers
|
// Delete Buffers
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy wave4.wav data into AL Buffer 5
|
// 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) {
|
if ((error = al.getError()) != AL.NO_ERROR) {
|
||||||
displayALError("alBufferData buffer 5 : ", error);
|
displayALError("alBufferData buffer 5 : ", error);
|
||||||
// Delete buffers
|
// Delete buffers
|
||||||
|
@ -493,25 +467,20 @@ public class ALTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload wave4.wav
|
// Unload wave4.wav
|
||||||
alut.unloadWAV(data.format, data.data, data.size, data.freq);
|
wavefile.dispose();
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
wavefile = null;
|
||||||
displayALError("alutUnloadWAV : ", error);
|
|
||||||
// Delete buffers
|
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load stereo.wav
|
// Load stereo.wav
|
||||||
data = alut.loadWAVFile("stereo.wav");
|
wavefile = WaveData.create("stereo.wav");
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
if (wavefile == null) {
|
||||||
displayALError("alutLoadWAVFile stereo.wav : ", error);
|
displayALError("LoadWAVFile stereo.wav : ", error);
|
||||||
// Delete Buffers
|
// Delete Buffers
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy stereo.wav data into AL Buffer 6
|
// 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) {
|
if ((error = al.getError()) != AL.NO_ERROR) {
|
||||||
displayALError("alBufferData buffer 6 : ", error);
|
displayALError("alBufferData buffer 6 : ", error);
|
||||||
// Delete buffers
|
// Delete buffers
|
||||||
|
@ -520,13 +489,8 @@ public class ALTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload stereo.wav
|
// Unload stereo.wav
|
||||||
alut.unloadWAV(data.format, data.data, data.size, data.freq);
|
wavefile.dispose();
|
||||||
if ((error = al.getError()) != AL.NO_ERROR) {
|
wavefile = null;
|
||||||
displayALError("alutUnloadWAV : ", error);
|
|
||||||
// Delete buffers
|
|
||||||
al.deleteBuffers(NUM_BUFFERS, Sys.getDirectBufferAddress(buffers));
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//do EAX check (can only be performed after device / context creation
|
//do EAX check (can only be performed after device / context creation
|
||||||
eaxAvailable = al.isExtensionPresent("EAX");
|
eaxAvailable = al.isExtensionPresent("EAX");
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,6 @@ import org.lwjgl.openal.AL;
|
||||||
import org.lwjgl.openal.ALC;
|
import org.lwjgl.openal.ALC;
|
||||||
import org.lwjgl.openal.ALCcontext;
|
import org.lwjgl.openal.ALCcontext;
|
||||||
import org.lwjgl.openal.ALCdevice;
|
import org.lwjgl.openal.ALCdevice;
|
||||||
import org.lwjgl.openal.ALUT;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
@ -57,9 +56,6 @@ public abstract class BasicTest {
|
||||||
/** OpenAL Context instance */
|
/** OpenAL Context instance */
|
||||||
protected ALC alc;
|
protected ALC alc;
|
||||||
|
|
||||||
/** OpenAL Util library instance */
|
|
||||||
protected ALUT alut;
|
|
||||||
|
|
||||||
/** OpenAL context */
|
/** OpenAL context */
|
||||||
protected ALCcontext context;
|
protected ALCcontext context;
|
||||||
|
|
||||||
|
@ -85,14 +81,6 @@ public abstract class BasicTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
alut = new ALUT();
|
|
||||||
try {
|
|
||||||
alut.create();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,6 @@ package org.lwjgl.test.openal;
|
||||||
|
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.openal.AL;
|
import org.lwjgl.openal.AL;
|
||||||
import org.lwjgl.openal.ALUTLoadWAVData;
|
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
@ -85,23 +84,16 @@ public class PlayTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
//load wave data
|
//load wave data
|
||||||
ALUTLoadWAVData file = alut.loadWAVFile(args[0]);
|
WaveData wavefile = WaveData.create(args[0]);
|
||||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
|
||||||
exit(lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//copy to buffers
|
//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) {
|
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||||
exit(lastError);
|
exit(lastError);
|
||||||
}
|
}
|
||||||
|
|
||||||
//unload file again
|
//unload file again
|
||||||
alut.unloadWAV(file.format, file.data, file.size, file.freq);
|
wavefile.dispose();
|
||||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
|
||||||
exit(lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
//set up source input
|
//set up source input
|
||||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||||
|
|
|
@ -33,7 +33,6 @@ package org.lwjgl.test.openal;
|
||||||
|
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.openal.AL;
|
import org.lwjgl.openal.AL;
|
||||||
import org.lwjgl.openal.ALUTLoadWAVData;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -97,23 +96,18 @@ public class PlayTestMemory extends BasicTest {
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ALUTLoadWAVData file = alut.loadWAVMemory(Sys.getDirectBufferAddress(filebuffer));
|
//ALUTLoadWAVData file = alut.loadWAVMemory(Sys.getDirectBufferAddress(filebuffer));
|
||||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
WaveData wavefile = WaveData.create(filebuffer.array());
|
||||||
exit(lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//copy to buffers
|
//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) {
|
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||||
exit(lastError);
|
exit(lastError);
|
||||||
}
|
}
|
||||||
|
|
||||||
//unload file again
|
//unload file again
|
||||||
alut.unloadWAV(file.format, file.data, file.size, file.freq);
|
wavefile.dispose();
|
||||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
|
||||||
exit(lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
//set up source input
|
//set up source input
|
||||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
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.
|
//no errorchecking from now on, since our context is gone.
|
||||||
//shutdown
|
|
||||||
alExit();
|
alExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +191,7 @@ public class PlayTestMemory extends BasicTest {
|
||||||
//done reading, close
|
//done reading, close
|
||||||
bis.close();
|
bis.close();
|
||||||
|
|
||||||
buffer = ByteBuffer.allocateDirect(baos.size());
|
buffer = ByteBuffer.allocate(baos.size());
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
buffer.order(ByteOrder.nativeOrder());
|
||||||
buffer.put(baos.toByteArray());
|
buffer.put(baos.toByteArray());
|
||||||
} catch (Exception ioe) {
|
} catch (Exception ioe) {
|
||||||
|
|
|
@ -1,180 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* This is the actual JNI implementation of the OpenAL utility library.
|
|
||||||
* It handles whatever is needed for proper OpenAL support via using Java.
|
|
||||||
*
|
|
||||||
* @author Brian Matzon <brian@matzon.dk>
|
|
||||||
* @version $Revision$
|
|
||||||
*/
|
|
||||||
#include "org_lwjgl_openal_ALUT.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* OpenAL includes */
|
|
||||||
#include "checkALerror.h"
|
|
||||||
#include <AL/alut.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_openal_ALUT
|
|
||||||
* Method: nCreate
|
|
||||||
* Signature: ()Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALUT_nCreate (JNIEnv *env, jobject obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_openal_ALUT
|
|
||||||
* Method: nDestroy
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_nDestroy (JNIEnv *env, jobject obj) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This function loads a WAV file into memory from a file.
|
|
||||||
*
|
|
||||||
* C Specification:
|
|
||||||
* ALboolean alutLoadWAVFile(const char *fname, ALsizei *format, ALsizei *size, ALsizei *bits,
|
|
||||||
* ALsizei *freq, ALboolean *loop );
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVFile (JNIEnv *env, jobject obj, jstring file) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: Since Java doesn't support modification of supplied
|
|
||||||
* variables (pass by value). We will return a class that
|
|
||||||
* holds what is needed to unload the file again.
|
|
||||||
* The data field contains the offset at whcih the data
|
|
||||||
* segment begins (ie. a pointer). This will *not* work
|
|
||||||
* on 64 bit platforms, since we use an jint for this.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* actual file info object */
|
|
||||||
jobject alutLoadWAVFile_object = NULL;
|
|
||||||
|
|
||||||
/* class type to find */
|
|
||||||
jclass alutLoadWAVFile_class = NULL;
|
|
||||||
|
|
||||||
/* method id - will be set to constructor of alutLoadWAVData */
|
|
||||||
jmethodID methodID = NULL;
|
|
||||||
|
|
||||||
/* sound data vars */
|
|
||||||
jint format, size, freq;
|
|
||||||
jboolean loop;
|
|
||||||
void* data;
|
|
||||||
ALbyte* filename = (ALbyte*) (env->GetStringUTFChars(file, 0));
|
|
||||||
|
|
||||||
/* load wave file */
|
|
||||||
alutLoadWAVFile(filename, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop);
|
|
||||||
|
|
||||||
/* get class */
|
|
||||||
alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVData");
|
|
||||||
|
|
||||||
/* get constructor */
|
|
||||||
methodID = env->GetMethodID(alutLoadWAVFile_class, "<init>", "(IIIIZ)V");
|
|
||||||
|
|
||||||
/* create object */
|
|
||||||
alutLoadWAVFile_object = env->NewObject(alutLoadWAVFile_class, methodID, format, (int) data, size, freq, loop);
|
|
||||||
|
|
||||||
/* release chars */
|
|
||||||
env->ReleaseStringUTFChars((jstring)filename, 0);
|
|
||||||
|
|
||||||
CHECK_AL_ERROR
|
|
||||||
return alutLoadWAVFile_object;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function loads a WAV file into memory from another memory location.
|
|
||||||
*
|
|
||||||
* C Specification:
|
|
||||||
* ALvoid alutLoadWAVMemory(ALbyte *memory,ALenum *format,ALvoid **data,ALsizei
|
|
||||||
* *size,ALsizei *freq,ALboolean *loop)
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVMemory (JNIEnv *env, jobject obj, jint buffer) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: Since Java doesn't support modification of supplied
|
|
||||||
* variables (pass by value). We will return a class that
|
|
||||||
* holds what is needed to unload the file again.
|
|
||||||
* The data field contains the offset at whcih the data
|
|
||||||
* segment begins (ie. a pointer). This will *not* work
|
|
||||||
* on 64 bit platforms, since we use an jint for this.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* actual file info object */
|
|
||||||
jobject alutLoadWAVFile_object = NULL;
|
|
||||||
|
|
||||||
/* class type to find */
|
|
||||||
jclass alutLoadWAVFile_class = NULL;
|
|
||||||
|
|
||||||
/* method id - will be set to constructor of alutLoadWAVData */
|
|
||||||
jmethodID methodID = NULL;
|
|
||||||
|
|
||||||
/* sound data vars */
|
|
||||||
jint format, size, freq;
|
|
||||||
jboolean loop;
|
|
||||||
void* data;
|
|
||||||
|
|
||||||
/* load wave from mem */
|
|
||||||
alutLoadWAVMemory((ALbyte*) buffer, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop);
|
|
||||||
|
|
||||||
/* get class */
|
|
||||||
alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVData");
|
|
||||||
|
|
||||||
/* get constructor */
|
|
||||||
methodID = env->GetMethodID(alutLoadWAVFile_class, "<init>", "(IIIIZ)V");
|
|
||||||
|
|
||||||
/* create object */
|
|
||||||
alutLoadWAVFile_object = env->NewObject(alutLoadWAVFile_class, methodID, format, (int) data, size, freq, loop);
|
|
||||||
|
|
||||||
CHECK_AL_ERROR
|
|
||||||
return alutLoadWAVFile_object;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function unloads a WAV file from memory and is normally used after copying the data into a buffer
|
|
||||||
* after an alutLoad* function.
|
|
||||||
*
|
|
||||||
* C Specification:
|
|
||||||
* ALvoid alutUnloadWAV(ALenum format, ALvoid *data, ALsizei size, ALsizei freq)
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_unloadWAV (JNIEnv *env, jobject obj, jint format, jint data, jint size, jint freq) {
|
|
||||||
alutUnloadWAV(format, (void**) data, size, freq);
|
|
||||||
CHECK_AL_ERROR
|
|
||||||
}
|
|
|
@ -1,86 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
|
||||||
#include <jni.h>
|
|
||||||
/* Header for class org_lwjgl_openal_ALUT */
|
|
||||||
|
|
||||||
#ifndef _Included_org_lwjgl_openal_ALUT
|
|
||||||
#define _Included_org_lwjgl_openal_ALUT
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_openal_ALUT
|
|
||||||
* Method: nCreate
|
|
||||||
* Signature: ()Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALUT_nCreate
|
|
||||||
(JNIEnv *, jobject);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_openal_ALUT
|
|
||||||
* Method: nDestroy
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_nDestroy
|
|
||||||
(JNIEnv *, jobject);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_openal_ALUT
|
|
||||||
* Method: loadWAVFile
|
|
||||||
* Signature: (Ljava/lang/String;)Lorg/lwjgl/openal/ALUTLoadWAVData;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVFile
|
|
||||||
(JNIEnv *, jobject, jstring);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_openal_ALUT
|
|
||||||
* Method: loadWAVMemory
|
|
||||||
* Signature: (I)Lorg/lwjgl/openal/ALUTLoadWAVData;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVMemory
|
|
||||||
(JNIEnv *, jobject, jint);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_openal_ALUT
|
|
||||||
* Method: unloadWAV
|
|
||||||
* Signature: (IIII)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_unloadWAV
|
|
||||||
(JNIEnv *, jobject, jint, jint, jint, jint);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue