fix: now using Int- & Float- Buffers
fix: to small iteration when unqueing buffers fix: nulling of buffer
This commit is contained in:
parent
7bd04b6719
commit
c18e8bd28a
|
@ -37,8 +37,8 @@ import org.lwjgl.openal.ALCcontext;
|
|||
import org.lwjgl.openal.ALCdevice;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
|
@ -71,15 +71,14 @@ public class ALCTest extends BasicTest {
|
|||
}
|
||||
|
||||
//create attribute list for context creation
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(28);
|
||||
buffer.order(ByteOrder.nativeOrder());
|
||||
buffer.putInt(ALC.FREQUENCY);
|
||||
buffer.putInt(44100);
|
||||
buffer.putInt(ALC.REFRESH);
|
||||
buffer.putInt(15);
|
||||
buffer.putInt(ALC.SYNC);
|
||||
buffer.putInt(ALC.FALSE);
|
||||
buffer.putInt(0); //terminating int
|
||||
IntBuffer buffer = createIntBuffer(7);
|
||||
buffer.put(ALC.FREQUENCY);
|
||||
buffer.put(44100);
|
||||
buffer.put(ALC.REFRESH);
|
||||
buffer.put(15);
|
||||
buffer.put(ALC.SYNC);
|
||||
buffer.put(ALC.FALSE);
|
||||
buffer.put(0); //terminating int
|
||||
|
||||
//create a context, using above attributes
|
||||
context = alc.createContext(device, Sys.getDirectBufferAddress(buffer));
|
||||
|
@ -112,8 +111,8 @@ public class ALCTest extends BasicTest {
|
|||
alc.getIntegerv(device, ALC.MAJOR_VERSION, 4, Sys.getDirectBufferAddress(buffer));
|
||||
alc.getIntegerv(device, ALC.MINOR_VERSION, 4, Sys.getDirectBufferAddress(buffer)+4);
|
||||
|
||||
System.out.println("ALC_MAJOR_VERSION: " + buffer.getInt());
|
||||
System.out.println("ALC_MINOR_VERSION: " + buffer.getInt());
|
||||
System.out.println("ALC_MAJOR_VERSION: " + buffer.get(0));
|
||||
System.out.println("ALC_MINOR_VERSION: " + buffer.get(1));
|
||||
|
||||
//no check for ALC_ALL_ATTRIBUTES / ALC_ATTRIBUTES_SIZE since it
|
||||
//is buggy on win32 - my dev platform
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,6 +37,10 @@ import org.lwjgl.openal.ALCcontext;
|
|||
import org.lwjgl.openal.ALCdevice;
|
||||
import org.lwjgl.openal.ALUT;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
|
@ -95,6 +99,20 @@ public abstract class BasicTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an integer buffer to hold specified ints
|
||||
* - strictly a utility method
|
||||
*
|
||||
* @param size how many int to contain
|
||||
* @return created IntBuffer
|
||||
*/
|
||||
protected IntBuffer createIntBuffer(int size) {
|
||||
ByteBuffer temp = ByteBuffer.allocateDirect(4*size);
|
||||
temp.order(ByteOrder.nativeOrder());
|
||||
|
||||
return temp.asIntBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits the test NOW, printing errorcode to stdout
|
||||
*
|
||||
|
|
|
@ -35,8 +35,7 @@ import org.lwjgl.Sys;
|
|||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.ALUTLoadWAVData;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
@ -71,11 +70,8 @@ public class PlayTest extends BasicTest {
|
|||
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());
|
||||
IntBuffer buffers = createIntBuffer(1);
|
||||
IntBuffer sources = createIntBuffer(1);
|
||||
|
||||
// al generate buffers and sources
|
||||
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
|
@ -96,7 +92,7 @@ public class PlayTest extends BasicTest {
|
|||
|
||||
|
||||
//copy to buffers
|
||||
al.bufferData(buffers.getInt(0), file.format, file.data, file.size, file.freq);
|
||||
al.bufferData(buffers.get(0), file.format, file.data, file.size, file.freq);
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
@ -108,19 +104,19 @@ public class PlayTest extends BasicTest {
|
|||
}
|
||||
|
||||
//set up source input
|
||||
al.sourcei(sources.getInt(0), AL.BUFFER, buffers.getInt(0));
|
||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
al.sourcei(sources.getInt(0), AL.LOOPING, AL.TRUE);
|
||||
al.sourcei(sources.get(0), AL.LOOPING, AL.TRUE);
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
al.sourcePlay(sources.getInt(0));
|
||||
al.sourcePlay(sources.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
@ -133,7 +129,7 @@ public class PlayTest extends BasicTest {
|
|||
}
|
||||
|
||||
//stop source 0
|
||||
al.sourceStop(sources.getInt(0));
|
||||
al.sourceStop(sources.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
@ -158,7 +154,7 @@ public class PlayTest extends BasicTest {
|
|||
|
||||
/**
|
||||
* main entry point
|
||||
*+
|
||||
*
|
||||
* @param args String array containing arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
@ -75,11 +76,8 @@ public class PlayTestMemory extends BasicTest {
|
|||
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());
|
||||
IntBuffer buffers = createIntBuffer(1);
|
||||
IntBuffer sources = createIntBuffer(1);
|
||||
|
||||
// al generate buffers and sources
|
||||
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
|
@ -106,7 +104,7 @@ public class PlayTestMemory extends BasicTest {
|
|||
|
||||
|
||||
//copy to buffers
|
||||
al.bufferData(buffers.getInt(0), file.format, file.data, file.size, file.freq);
|
||||
al.bufferData(buffers.get(0), file.format, file.data, file.size, file.freq);
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
@ -118,19 +116,19 @@ public class PlayTestMemory extends BasicTest {
|
|||
}
|
||||
|
||||
//set up source input
|
||||
al.sourcei(sources.getInt(0), AL.BUFFER, buffers.getInt(0));
|
||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
al.sourcei(sources.getInt(0), AL.LOOPING, AL.TRUE);
|
||||
al.sourcei(sources.get(0), AL.LOOPING, AL.TRUE);
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
al.sourcePlay(sources.getInt(0));
|
||||
al.sourcePlay(sources.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
@ -143,7 +141,7 @@ public class PlayTestMemory extends BasicTest {
|
|||
}
|
||||
|
||||
//stop source 0
|
||||
al.sourceStop(sources.getInt(0));
|
||||
al.sourceStop(sources.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue