fix: now using ByteBuffer all the way

This commit is contained in:
Brian Matzon 2002-08-29 01:11:46 +00:00
parent dac8f79273
commit f85aaf6b01
7 changed files with 605 additions and 275 deletions

View File

@ -73,10 +73,10 @@ public class ALUT {
/**
* Loads a byte buffer into memory
*
* @param buffer byte buffer containing file
* @param buffer buffer address containing file
* @return ALUTLoadWAVData object containing information regarding wave data loaded
*/
public native ALUTLoadWAVData loadWAVMemory(byte[] buffer);
public native ALUTLoadWAVData loadWAVMemory(int buffer);
/**
* Unloads the specified file from memory

View File

@ -255,7 +255,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of sources to generate
* @param sources array holding sources
*/
public native void genSources(int n, int[] sources);
public native void genSources(int n, int sources);
/**
* Delete one or more sources.
@ -263,7 +263,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n Number of sources to delete
* @param source Source array to delete from
*/
public native void deleteSources(int n, int[] source);
public native void deleteSources(int n, int source);
/**
* Tests if a source is valid.
@ -355,7 +355,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of sources to play
* @param source array of sources to play
*/
public native void sourcePlayv(int n, int[] sources);
public native void sourcePlayv(int n, int sources);
/**
* Pauses a set of sources.
@ -363,7 +363,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of sources to pause
* @param source array of sources to pause
*/
public native void sourcePausev(int n, int[] sources);
public native void sourcePausev(int n, int sources);
/**
* Stops a set of sources.
@ -371,7 +371,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of sources to stop
* @param source array of sources to stop
*/
public native void sourceStopv(int n, int[] sources);
public native void sourceStopv(int n, int sources);
/**
* Rewinds a set of sources.
@ -379,7 +379,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of sources to rewind
* @param source array of sources to rewind
*/
public native void sourceRewindv(int n, int[] sources);
public native void sourceRewindv(int n, int sources);
/**
* Play a source.
@ -415,7 +415,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of buffers to generate
* @param buffers array holding buffers
*/
public native void genBuffers(int n, int[] buffers);
public native void genBuffers(int n, int buffers);
/**
* Delete one or more buffers.
@ -423,7 +423,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n Number of buffers to delete
* @param buffers Buffer array to delete from
*/
public native void deleteBuffers(int n, int[] buffers);
public native void deleteBuffers(int n, int buffers);
/**
* Tests if buffer is valid.
@ -469,7 +469,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of buffers to be queued
* @param buffers buffers to be queued
*/
public native void sourceQueueBuffers(int source, int n, int[] buffers);
public native void sourceQueueBuffers(int source, int n, int buffers);
/**
* Unqueues a set of buffers attached to a source.
@ -478,7 +478,7 @@ public class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of buffers to be unqueued
* @param buffers buffers to be unqueued
*/
public native void sourceUnqueueBuffers(int source, int n, int[] buffers);
public native void sourceUnqueueBuffers(int source, int n, int buffers);
/**
* Selects the OpenAL distance model.

File diff suppressed because it is too large Load Diff

View File

@ -31,15 +31,13 @@
*/
package org.lwjgl.openal.test;
import org.lwjgl.Sys;
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 org.lwjgl.openal.ALUTLoadWAVData;
import java.io.*;
import java.net.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* $Id$
*
@ -73,16 +71,19 @@ public class ALUTTest extends BasicTest {
alut.init(args);
//create 1 buffer and 1 source
int[] buffers = new int[1];
int[] sources = new int[1];
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, buffers);
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
al.genSources(1, sources);
al.genSources(1, Sys.getDirectBufferAddress(sources));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
@ -95,7 +96,7 @@ public class ALUTTest extends BasicTest {
//copy to buffers
al.bufferData(buffers[0], file.format, file.data, file.size, file.freq);
al.bufferData(buffers.getInt(0), file.format, file.data, file.size, file.freq);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
@ -107,19 +108,19 @@ public class ALUTTest extends BasicTest {
}
//set up source input
al.sourcei(sources[0], AL.BUFFER, buffers[0]);
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[0], AL.LOOPING, AL.TRUE);
al.sourcei(sources.getInt(0), AL.LOOPING, AL.TRUE);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//play source 0
al.sourcePlay(sources[0]);
al.sourcePlay(sources.getInt(0));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
@ -132,18 +133,18 @@ public class ALUTTest extends BasicTest {
}
//stop source 0
al.sourceStop(sources[0]);
al.sourceStop(sources.getInt(0));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//delete buffers and sources
al.deleteSources(1, sources);
al.deleteSources(1, Sys.getDirectBufferAddress(sources));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
al.deleteBuffers(1, buffers);
al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}

View File

@ -31,13 +31,13 @@
*/
package org.lwjgl.openal.test;
import org.lwjgl.Sys;
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 org.lwjgl.openal.ALUTLoadWAVData;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* $Id$
*
@ -71,16 +71,19 @@ public class PlayTest extends BasicTest {
alInitialize();
//create 1 buffer and 1 source
int[] buffers = new int[1];
int[] sources = new int[1];
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, buffers);
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
al.genSources(1, sources);
al.genSources(1, Sys.getDirectBufferAddress(sources));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
@ -93,7 +96,7 @@ public class PlayTest extends BasicTest {
//copy to buffers
al.bufferData(buffers[0], file.format, file.data, file.size, file.freq);
al.bufferData(buffers.getInt(0), file.format, file.data, file.size, file.freq);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
@ -105,19 +108,19 @@ public class PlayTest extends BasicTest {
}
//set up source input
al.sourcei(sources[0], AL.BUFFER, buffers[0]);
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[0], AL.LOOPING, AL.TRUE);
al.sourcei(sources.getInt(0), AL.LOOPING, AL.TRUE);
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//play source 0
al.sourcePlay(sources[0]);
al.sourcePlay(sources.getInt(0));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
@ -130,18 +133,18 @@ public class PlayTest extends BasicTest {
}
//stop source 0
al.sourceStop(sources[0]);
al.sourceStop(sources.getInt(0));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
//delete buffers and sources
al.deleteSources(1, sources);
al.deleteSources(1, Sys.getDirectBufferAddress(sources));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
al.deleteBuffers(1, buffers);
al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers));
if((lastError = al.getError()) != AL.NO_ERROR) {
exit(lastError);
}
@ -155,7 +158,7 @@ public class PlayTest extends BasicTest {
/**
* main entry point
*
*+
* @param args String array containing arguments
*/
public static void main(String[] args) {

View File

@ -242,18 +242,18 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListenerfv
/*
* Class: org_lwjgl_openal_CoreAL
* Method: genSources
* Signature: (I[I)V
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genSources
(JNIEnv *, jobject, jint, jintArray);
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
* Method: deleteSources
* Signature: (I[I)V
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteSources
(JNIEnv *, jobject, jint, jintArray);
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
@ -330,34 +330,34 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSourcefv
/*
* Class: org_lwjgl_openal_CoreAL
* Method: sourcePlayv
* Signature: (I[I)V
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePlayv
(JNIEnv *, jobject, jint, jintArray);
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
* Method: sourcePausev
* Signature: (I[I)V
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePausev
(JNIEnv *, jobject, jint, jintArray);
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
* Method: sourceStopv
* Signature: (I[I)V
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStopv
(JNIEnv *, jobject, jint, jintArray);
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
* Method: sourceRewindv
* Signature: (I[I)V
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewindv
(JNIEnv *, jobject, jint, jintArray);
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
@ -394,18 +394,18 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewind
/*
* Class: org_lwjgl_openal_CoreAL
* Method: genBuffers
* Signature: (I[I)V
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genBuffers
(JNIEnv *, jobject, jint, jintArray);
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
* Method: deleteBuffers
* Signature: (I[I)V
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteBuffers
(JNIEnv *, jobject, jint, jintArray);
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
@ -442,18 +442,18 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getBufferf
/*
* Class: org_lwjgl_openal_CoreAL
* Method: sourceQueueBuffers
* Signature: (II[I)V
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceQueueBuffers
(JNIEnv *, jobject, jint, jint, jintArray);
(JNIEnv *, jobject, jint, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL
* Method: sourceUnqueueBuffers
* Signature: (II[I)V
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceUnqueueBuffers
(JNIEnv *, jobject, jint, jint, jintArray);
(JNIEnv *, jobject, jint, jint, jint);
/*
* Class: org_lwjgl_openal_CoreAL

View File

@ -354,10 +354,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListenerfv (JNIEnv *env,
* C Specification:
* ALvoid alGenSources(ALsizei n,ALuint *sources);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genSources (JNIEnv *env, jobject obj, jint n, jintArray sources) {
int* array = (int*) env->GetIntArrayElements(sources, 0);
alGenSources(n, (ALuint*) array);
env->ReleaseIntArrayElements(sources, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genSources (JNIEnv *env, jobject obj, jint n, jint sources) {
alGenSources(n, (ALuint*) sources);
CHECK_AL_ERROR
}
@ -367,10 +365,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genSources (JNIEnv *env, job
* C Specification:
* ALvoid alDeleteSources(ALsizei n,ALuint *sources);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteSources (JNIEnv *env, jobject obj, jint n, jintArray source) {
int* array = (int*) env->GetIntArrayElements(source, 0);
alDeleteSources(n, (ALuint*) array);
env->ReleaseIntArrayElements(source, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteSources (JNIEnv *env, jobject obj, jint n, jint sources) {
alDeleteSources(n, (ALuint*) sources);
CHECK_AL_ERROR
}
@ -479,10 +475,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSourcefv (JNIEnv *env, jo
* C Specification:
* ALvoid alSourcePlayv(ALsizei n,ALuint *sources);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePlayv (JNIEnv *env, jobject obj, jint n, jintArray sources) {
int* array = (int*) env->GetIntArrayElements(sources, 0);
alSourcePlayv(n, (ALuint*) array);
env->ReleaseIntArrayElements(sources, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePlayv (JNIEnv *env, jobject obj, jint n, jint sources) {
alSourcePlayv(n, (ALuint*) sources);
CHECK_AL_ERROR
}
@ -492,10 +486,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePlayv (JNIEnv *env, jo
* C Specification:
* ALvoid alSourcePausev(ALsizei n,ALuint *sources);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePausev (JNIEnv *env, jobject obj, jint n, jintArray sources) {
int* array = (int*) env->GetIntArrayElements(sources, 0);
alSourcePausev(n, (ALuint*) array);
env->ReleaseIntArrayElements(sources, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePausev (JNIEnv *env, jobject obj, jint n, jint sources) {
alSourcePausev(n, (ALuint*) sources);
CHECK_AL_ERROR
}
@ -505,10 +497,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePausev (JNIEnv *env, j
* C Specification:
* ALvoid alSourceStopv(ALsizei n,ALuint *sources);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStopv (JNIEnv *env, jobject obj, jint n, jintArray sources) {
int* array = (int*) env->GetIntArrayElements(sources, 0);
alSourceStopv(n, (ALuint*) array);
env->ReleaseIntArrayElements(sources, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStopv (JNIEnv *env, jobject obj, jint n, jint sources) {
alSourceStopv(n, (ALuint*) sources);
CHECK_AL_ERROR
}
@ -518,10 +508,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStopv (JNIEnv *env, jo
* C Specification:
* ALvoid alSourceRewindv(ALsizei n,ALuint *sources);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewindv (JNIEnv *env, jobject obj, jint n, jintArray sources) {
int* array = (int*) env->GetIntArrayElements(sources, 0);
alSourceRewindv(n, (ALuint*) array);
env->ReleaseIntArrayElements(sources, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewindv (JNIEnv *env, jobject obj, jint n, jint sources) {
alSourceRewindv(n, (ALuint*) sources);
CHECK_AL_ERROR
}
@ -575,10 +563,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewind (JNIEnv *env, j
* C Specification:
* ALvoid alGenBuffers(ALsizei n,ALuint *buffers);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genBuffers (JNIEnv *env, jobject obj, jint n, jintArray buffers) {
int* array = (int*) env->GetIntArrayElements(buffers, 0);
alGenBuffers(n, (ALuint*) array);
env->ReleaseIntArrayElements(buffers, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genBuffers (JNIEnv *env, jobject obj, jint n, jint buffers) {
alGenBuffers(n, (ALuint*) buffers);
CHECK_AL_ERROR
}
@ -588,10 +574,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genBuffers (JNIEnv *env, job
* C Specification:
* ALvoid alDeleteBuffers(ALsizei n,ALuint *buffers);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteBuffers (JNIEnv *env, jobject obj, jint n, jintArray buffer) {
int* array = (int*) env->GetIntArrayElements(buffer, 0);
alDeleteBuffers(n, (ALuint*) array);
env->ReleaseIntArrayElements(buffer, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteBuffers (JNIEnv *env, jobject obj, jint n, jint buffers) {
alDeleteBuffers(n, (ALuint*) buffers);
CHECK_AL_ERROR
}
@ -647,10 +631,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getBufferf (JNIEnv *env, job
* C Specification:
* ALvoid alSourceQueueBuffers( ALuint source, ALsizei n, ALuint* buffers );
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceQueueBuffers (JNIEnv *env, jobject obj, jint source, jint n, jintArray buffers) {
int* array = (int*) env->GetIntArrayElements(buffers, 0);
alSourceQueueBuffers((ALuint) source, (ALsizei) n, (ALuint*) array);
env->ReleaseIntArrayElements(buffers, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceQueueBuffers (JNIEnv *env, jobject obj, jint source, jint n, jint buffers) {
alSourceQueueBuffers((ALuint) source, (ALsizei) n, (ALuint*) buffers);
CHECK_AL_ERROR
}
@ -660,10 +642,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceQueueBuffers (JNIEnv *
* C Specification:
* ALvoid alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint* buffers );
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceUnqueueBuffers (JNIEnv *env, jobject obj, jint source, jint n, jintArray buffers) {
int* array = (int*) env->GetIntArrayElements(buffers, 0);
alSourceUnqueueBuffers((ALuint) source, (ALsizei) n, (ALuint*) array);
env->ReleaseIntArrayElements(buffers, (jint*) array, 0);
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceUnqueueBuffers (JNIEnv *env, jobject obj, jint source, jint n, jint buffers) {
alSourceUnqueueBuffers((ALuint) source, (ALsizei) n, (ALuint*) buffers);
CHECK_AL_ERROR
}