From ce668ad98b873e5a2fd95c70e0a6431df0af038f Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 19 Nov 2002 14:08:21 +0000 Subject: [PATCH] Initial OpenAL linux support --- src/native/linux/Makefile | 2 +- src/native/linux/org_lwjgl_openal_ALC.cpp | 381 ++++++++++ src/native/linux/org_lwjgl_openal_ALUT.cpp | 222 ++++++ src/native/linux/org_lwjgl_openal_BaseAL.cpp | 50 ++ src/native/linux/org_lwjgl_openal_CoreAL.cpp | 668 ++++++++++++++++++ ...g_lwjgl_openal_eax_EAXBufferProperties.cpp | 109 +++ ...lwjgl_openal_eax_EAXListenerProperties.cpp | 113 +++ 7 files changed, 1544 insertions(+), 1 deletion(-) create mode 100644 src/native/linux/org_lwjgl_openal_ALC.cpp create mode 100644 src/native/linux/org_lwjgl_openal_ALUT.cpp create mode 100644 src/native/linux/org_lwjgl_openal_BaseAL.cpp create mode 100644 src/native/linux/org_lwjgl_openal_CoreAL.cpp create mode 100644 src/native/linux/org_lwjgl_openal_eax_EAXBufferProperties.cpp create mode 100644 src/native/linux/org_lwjgl_openal_eax_EAXListenerProperties.cpp diff --git a/src/native/linux/Makefile b/src/native/linux/Makefile index 51fec0b6..38f0db1a 100644 --- a/src/native/linux/Makefile +++ b/src/native/linux/Makefile @@ -48,7 +48,7 @@ LIBCPPOBJS=$(LIBCPPSRC:.cpp=.o) LIBCOBJS=$(LIBCSRC:.c=.o) LIBOBJS=$(LIBCOBJS) $(LIBCPPOBJS) #DEBUG_FLAGS=-D_DEBUG -LINKOPTS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU +LINKOPTS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU -lopenal all: liblwjgl.so diff --git a/src/native/linux/org_lwjgl_openal_ALC.cpp b/src/native/linux/org_lwjgl_openal_ALC.cpp new file mode 100644 index 00000000..278df6bf --- /dev/null +++ b/src/native/linux/org_lwjgl_openal_ALC.cpp @@ -0,0 +1,381 @@ +/* + * 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 context/device library. + * + * @author Brian Matzon + * @version $Revision$ + */ +#include "org_lwjgl_openal_ALC.h" +#include "checkALerror.h" + +/* OpenAL includes */ +#include + +/* + * Class: org_lwjgl_openal_ALC + * Method: nCreate + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALC_nCreate (JNIEnv *env, jobject obj) { + return true; +} + +/* + * Class: org_lwjgl_openal_ALC + * Method: nDestroy + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_nDestroy (JNIEnv *env, jobject obj) { +} + +/** + * This function returns strings related to the context. + * + * C Specification: + * ALubyte * alcGetString(ALCdevice *device, ALenum token); + */ +JNIEXPORT jstring JNICALL Java_org_lwjgl_openal_ALC_getString (JNIEnv *env, jobject obj, jobject device, jint token) { + jclass class_device = env->GetObjectClass(device); + jfieldID field_device = env->GetFieldID(class_device, "device", "I"); + jint deviceaddress = env->GetIntField(device, field_device); + + const char* alcString = (const char*) alcGetString((ALCdevice*) deviceaddress, (ALenum) token); + if(alcString == NULL) { + return NULL; + } + + jstring string = env->NewStringUTF(alcString); + + CHECK_ALC_ERROR + return string; +} + +/** + * This function returns integers related to the context. + * + * C Specification: + * ALvoid alcGetIntegerv(ALCdevice *device, ALenum token, ALsizei size, ALint *dest); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_getIntegerv (JNIEnv *env, jobject obj, jobject device, jint token, jint size, jint dest) { + jclass device_class = env->GetObjectClass(device); + jfieldID device_field = env->GetFieldID(device_class, "device", "I"); + jint deviceaddress = env->GetIntField(device, device_field); + + alcGetIntegerv((ALCdevice*) deviceaddress, (ALenum) token, (ALsizei) size, (ALint*) dest); + CHECK_ALC_ERROR +} + +/** + * This function opens a device by name. + * + * C Specification: + * ALCdevice *alcOpenDevice( const ALubyte *tokstr ); + */ +JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALC_openDevice (JNIEnv *env, jobject obj, jstring tokstr) { + ALubyte* tokenstring; + + if(tokstr != NULL) { + tokenstring = (ALubyte*) (env->GetStringUTFChars(tokstr, 0)); + } else { + tokenstring = NULL; + } + + /* get device */ + ALCdevice* device = alcOpenDevice(tokenstring); + + /* if error - cleanup and get out */ + if(device == NULL) { + if(tokenstring != NULL) { + env->ReleaseStringUTFChars((jstring)tokenstring, 0); + } + return NULL; + } + + /* get ready to create ALCdevice instance */ + jobject alcDevice_object = NULL; + jclass alcDevice_class = NULL; + jmethodID alcDevice_method = NULL; + + /* find class and constructor */ + alcDevice_class = env->FindClass("org/lwjgl/openal/ALCdevice"); + alcDevice_method = env->GetMethodID(alcDevice_class, "", "(I)V"); + + /* create instance */ + alcDevice_object = env->NewObject(alcDevice_class, alcDevice_method, (int) device); + + /* clean up */ + env->ReleaseStringUTFChars((jstring)tokenstring, 0); + + return alcDevice_object; +} + +/** + * This function closes a device by name. + * + * C Specification: + * void alcCloseDevice( ALCdevice *dev ); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_closeDevice (JNIEnv *env, jobject obj, jobject device) { + jclass device_class = env->GetObjectClass(device); + jfieldID device_field = env->GetFieldID(device_class, "device", "I"); + jint deviceaddress = env->GetIntField(device, device_field); + + alcCloseDevice((ALCdevice*) deviceaddress); + CHECK_ALC_ERROR +} + +/** + * This function creates a context using a specified device. + * + * C Specification: + * ALCcontext* alcCreateContext( ALCdevice *dev, ALint* attrlist ); + */ +JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALC_createContext (JNIEnv *env, jobject obj, jobject device, jint attrlist) { + /* get device address */ + jclass device_class = env->GetObjectClass(device); + jfieldID device_field = env->GetFieldID(device_class, "device", "I"); + jint deviceaddress = env->GetIntField(device, device_field); + + ALCcontext* context = alcCreateContext((ALCdevice*) deviceaddress, (ALint*) attrlist); + + /* if error - get out */ + if(context == NULL) { + return NULL; + } + + /* get ready to create ALCcontext instance */ + jobject alcContext_object = NULL; + jclass alcContext_class = NULL; + jmethodID alcContext_method = NULL; + + /* find class and constructor */ + alcContext_class = env->FindClass("org/lwjgl/openal/ALCcontext"); + alcContext_method = env->GetMethodID(alcContext_class, "", "(I)V"); + + /* create instance */ + alcContext_object = env->NewObject(alcContext_class, alcContext_method, (int) context); + + CHECK_ALC_ERROR + return alcContext_object; +} + +/** + * This function makes a specified context the current context. + * + * C Specification: + * ALCboolean alcMakeContextCurrent(ALCcontext *context); + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALC_makeContextCurrent (JNIEnv *env, jobject obj, jobject context) { + if(context == NULL) { + return alcMakeContextCurrent(NULL); + } + + /* get context address */ + jclass context_class = env->GetObjectClass(context); + jfieldID context_field = env->GetFieldID(context_class, "context", "I"); + jint contextaddress = env->GetIntField(context, context_field); + + return alcMakeContextCurrent((ALCcontext*) contextaddress); +} + +/** + * This function tells a context to begin processing. + * + * C Specification: + * void alcProcessContext(ALCcontext *context); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_processContext (JNIEnv *env, jobject obj, jobject context) { + /* get context address */ + jclass context_class = env->GetObjectClass(context); + jfieldID context_field = env->GetFieldID(context_class, "context", "I"); + jint contextaddress = env->GetIntField(context, context_field); + + alcProcessContext((ALCcontext*) contextaddress); +} + +/** + * This function retrieves the current context. + * + * C Specification: + * ALCcontext* alcGetCurrentContext( ALvoid ); + */ +JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALC_getCurrentContext (JNIEnv *env, jobject obj) { + + ALCcontext* context = alcGetCurrentContext(); + if(context == NULL) { + return NULL; + } + + /* get ready to create ALCcontext instance */ + jobject alcContext_object = NULL; + jclass alcContext_class = NULL; + jmethodID alcContext_method = NULL; + + /* find class and constructor */ + alcContext_class = env->FindClass("org/lwjgl/openal/ALCcontext"); + alcContext_method = env->GetMethodID(alcContext_class, "", "(I)V"); + + /* create instance */ + alcContext_object = env->NewObject(alcContext_class, alcContext_method, (int) context); + + return alcContext_object; +} + +/** + * This function retrieves the specified contexts device + * + * C Specification: + * ALCdevice* alcGetContextsDevice(ALCcontext *context); + */ +JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALC_getContextsDevice (JNIEnv *env, jobject obj, jobject context) { + + /* get context address */ + jclass context_class = env->GetObjectClass(context); + jfieldID context_field = env->GetFieldID(context_class, "context", "I"); + jint contextaddress = env->GetIntField(context, context_field); + + ALCdevice* device = alcGetContextsDevice((ALCcontext*) contextaddress); + if(device == NULL) { + return NULL; + } + + /* get ready to create ALCdevice instance */ + jobject alcDevice_object = NULL; + jclass alcDevice_class = NULL; + jmethodID alcDevice_method = NULL; + + /* find class and constructor */ + alcDevice_class = env->FindClass("org/lwjgl/openal/ALCdevice"); + alcDevice_method = env->GetMethodID(alcDevice_class, "", "(I)V"); + + /* create instance */ + alcDevice_object = env->NewObject(alcDevice_class, alcDevice_method, (int) device); + + return alcDevice_object; +} + +/** + * This function suspends processing on a specified context. + * + * C Specification: + * void alcSuspendContext(ALCcontext *context); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_suspendContext (JNIEnv *env, jobject obj, jobject context) { + /* get context address */ + jclass context_class = env->GetObjectClass(context); + jfieldID context_field = env->GetFieldID(context_class, "context", "I"); + jint contextaddress = env->GetIntField(context, context_field); + + alcSuspendContext((ALCcontext*) contextaddress); +} + +/** + * This function destroys a context. + * + * C Specification: + * void alcDestroyContext(ALCcontext *context); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_destroyContext (JNIEnv *env, jobject obj, jobject context) { + /* get context address */ + jclass context_class = env->GetObjectClass(context); + jfieldID context_field = env->GetFieldID(context_class, "context", "I"); + jint contextaddress = env->GetIntField(context, context_field); + + alcDestroyContext((ALCcontext*) contextaddress); +} + +/** + * This function retrieves the specified devices context error state. + * + * C Specification: + * ALCenum alcGetError(ALCdevice *device); + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_openal_ALC_getError (JNIEnv *env, jobject obj, jobject device) { + /* get device address */ + jclass device_class = env->GetObjectClass(device); + jfieldID device_field = env->GetFieldID(device_class, "device", "I"); + jint deviceaddress = env->GetIntField(device, device_field); + + jint result = alcGetError((ALCdevice*) deviceaddress); + CHECK_ALC_ERROR + return result; +} + +/** + * This function queries if a specified context extension is available. + * + * C Specification: + * ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName); + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALC_isExtensionPresent (JNIEnv *env, jobject obj, jobject device, jstring extName) { + /* get device address */ + jclass device_class = env->GetObjectClass(device); + jfieldID device_field = env->GetFieldID(device_class, "device", "I"); + jint deviceaddress = env->GetIntField(device, device_field); + + /* get extension */ + ALubyte* functionname = (ALubyte*) (env->GetStringUTFChars(extName, 0)); + + jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*) deviceaddress, functionname); + + env->ReleaseStringUTFChars((jstring)functionname, 0); + + CHECK_ALC_ERROR + return result; +} + +/** + * This function retrieves the enum value for a specified enumeration name. + * + * C Specification: + * ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName); + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_openal_ALC_getEnumValue (JNIEnv *env, jobject obj, jobject device, jstring enumName) { + /* get device address */ + jclass device_class = env->GetObjectClass(device); + jfieldID device_field = env->GetFieldID(device_class, "device", "I"); + jint deviceaddress = env->GetIntField(device, device_field); + + /* get extension */ + ALubyte* enumerationname = (ALubyte*) (env->GetStringUTFChars(enumName, 0)); + + jint result = (jint) alcGetEnumValue((ALCdevice*) deviceaddress, enumerationname); + + env->ReleaseStringUTFChars((jstring)enumerationname, 0); + + CHECK_ALC_ERROR + return result; +} diff --git a/src/native/linux/org_lwjgl_openal_ALUT.cpp b/src/native/linux/org_lwjgl_openal_ALUT.cpp new file mode 100644 index 00000000..809a2fd6 --- /dev/null +++ b/src/native/linux/org_lwjgl_openal_ALUT.cpp @@ -0,0 +1,222 @@ +/* + * 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 + * @version $Revision$ + */ +#include "org_lwjgl_openal_ALUT.h" +#include "checkALerror.h" + +/* OpenAL includes */ +#include + +#include + +/* + * 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 initializes OpenAL. + * + * C Specification: + * void alutInit(int *argc, char *argv[]); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_init (JNIEnv *env, jobject obj, jobjectArray jargv) { + /* obtain the size the array */ + jsize argc = env->GetArrayLength(jargv); + + /* Declare a char array for argv */ + const char* argv[128]; + int i; + + for (i=0;iGetObjectArrayElement(jargv, i); + + /* Convert the object just obtained into a String */ + const char *str = env->GetStringUTFChars(string, 0); + + /* Build the argv array */ + argv[i] = str; + + /* Free up memory to prevent memory leaks */ + env->ReleaseStringUTFChars(string, str); + } + + /* Increment argc to adjust the difference between Java and C arguments */ + argc++; + + /* call the actual implementation */ + alutInit((ALint*) &argc,(char**) argv); + CHECK_AL_ERROR +} +/* + * 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, "", "(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, "", "(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 +} + +/** + * This function exits OpenAL. + * + * C Specification: + * void alutExit(ALvoid); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_exit (JNIEnv *env, jobject obj) { + alutExit(); +} diff --git a/src/native/linux/org_lwjgl_openal_BaseAL.cpp b/src/native/linux/org_lwjgl_openal_BaseAL.cpp new file mode 100644 index 00000000..b397ccfb --- /dev/null +++ b/src/native/linux/org_lwjgl_openal_BaseAL.cpp @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#include "org_lwjgl_openal_BaseAL.h" + +/* + * Class: org_lwjgl_openal_BaseAL + * Method: nCreate + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_BaseAL_nCreate (JNIEnv *env, jobject obj) { + return true; +} + +/* + * Class: org_lwjgl_openal_BaseAL + * Method: nDestroy + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_BaseAL_nDestroy(JNIEnv *env, jobject obj) { +} \ No newline at end of file diff --git a/src/native/linux/org_lwjgl_openal_CoreAL.cpp b/src/native/linux/org_lwjgl_openal_CoreAL.cpp new file mode 100644 index 00000000..032beac3 --- /dev/null +++ b/src/native/linux/org_lwjgl_openal_CoreAL.cpp @@ -0,0 +1,668 @@ +/* + * 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 core. It handles + * whatever is needed for proper OpenAL support via using Java. + * + * @author Brian Matzon + * @version $Revision$ + */ +#include "org_lwjgl_openal_CoreAL.h" +#include "checkALerror.h" + +/* OpenAL includes */ +#include + +/** + * This function enables a feature of the OpenAL driver. + * + * C Specification: + * ALvoid alEnable(ALenum capability); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_enable (JNIEnv *env, jobject obj, jint capability) { + alEnable((ALenum) capability); + CHECK_AL_ERROR +} + +/** + * This function disables a feature of the OpenAL driver. + * + * C Specification: + * ALvoid alDisable(ALenum capability); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_disable (JNIEnv *env, jobject obj, jint capability) { + alDisable((ALenum) capability); + CHECK_AL_ERROR +} + +/** + * This function returns a boolean indicating if a specific feature is enabled in the OpenAL driver. + * + * C Specification: + * Alboolean alIsEnabled(ALenum capability); + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_isEnabled (JNIEnv *env, jobject obj, jint capability) { + jboolean result = (jboolean) alIsEnabled((ALenum) capability); + + CHECK_AL_ERROR + return result; +} + +/** + * This function Enables a feature of the OpenAL driver. + * + * C Specification + * ALvoid alHint(ALenum target, ALenum mode); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_hint (JNIEnv *env, jobject obj, jint target, jint mode) { + //alHint((ALint)target, (ALint)mode); + //cannot link with above statement + return; +} + + +/** + * This function returns a boolean OpenAL state. + * + * C Specification: + * Alboolean alGetBoolean(ALenum pname); + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_getBoolean (JNIEnv *env, jobject obj, jint pname) { + jboolean result = (jboolean) alGetBoolean((ALenum) pname); + + CHECK_AL_ERROR + return result; +} + +/** + * This function returns an integer OpenAL state. + * + * C Specification: + * Alint alGetInteger(ALenum pname); + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_openal_CoreAL_getInteger (JNIEnv *env, jobject obj, jint pname) { + jint result = (jint) alGetInteger((ALenum) pname); + + CHECK_AL_ERROR + return result; +} + +/** + * This function returns a floating point OpenAL state. + * + * C Specification: + * ALfloat alGetFloat(ALenum pname); + */ +JNIEXPORT jfloat JNICALL Java_org_lwjgl_openal_CoreAL_getFloat (JNIEnv *env, jobject obj, jint pname) { + jfloat result = (jfloat) alGetFloat((ALenum) pname); + + CHECK_AL_ERROR + return result; +} + +/** + * This function returns a double precision floating point OpenAL state. + * + * C Specification: + * Aldouble alGetDouble(ALenum pname); + */ +JNIEXPORT jdouble JNICALL Java_org_lwjgl_openal_CoreAL_getDouble (JNIEnv *env, jobject obj, jint pname) { + jdouble result = (jdouble) alGetDouble((ALenum) pname); + + CHECK_AL_ERROR + return result; +} + +/** + * This function retrieves a boolean OpenAL state. + * + * C Specification: + * ALvoid alGetBooleanv(ALenum pname,ALboolean *data); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getBooleanv (JNIEnv *env, jobject obj, jint pname, jint data) { + alGetBooleanv((ALenum) pname, (ALboolean*) data); + CHECK_AL_ERROR +} + +/** + * This function retrieves an integer OpenAL state. + * + * C Specification: + * ALvoid alGetIntegerv(ALenum pname,ALint *data); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getIntegerv (JNIEnv *env, jobject obj, jint pname, jint data) { + alGetIntegerv((ALenum) pname, (ALint*) data); + CHECK_AL_ERROR +} + +/** + * This function retrieves a floating point OpenAL state. + * + * C Specification: + * ALvoid alGetFloatv(ALenum pname,ALfloat *data); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getFloatv (JNIEnv *env, jobject obj, jint pname, jint data) { + alGetFloatv((ALenum) pname, (ALfloat*) data); + CHECK_AL_ERROR +} + +/** + * This function retrieves a double precision floating point OpenAL state. + * + * C Specification: + * ALvoid alGetDoublev(ALenum pname,ALdouble *data); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getDoublev (JNIEnv *env, jobject obj, jint pname, jint data) { + alGetDoublev((ALenum) pname, (ALdouble*) data); + CHECK_AL_ERROR +} + +/** + * This function retrieves an OpenAL string property. + * + * C Specification: + * ALubyte * alGetString(ALenum pname); + */ +JNIEXPORT jstring JNICALL Java_org_lwjgl_openal_CoreAL_getString (JNIEnv *env, jobject obj, jint param) { + jstring string = (jstring) env->NewStringUTF((const char*) alGetString((ALenum)param)); + + CHECK_AL_ERROR + return string; +} + +/** + * This function returns the current error state and then clears the error state. + * + * C Specification: + * ALenum alGetError(ALvoid); + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_openal_CoreAL_getError (JNIEnv *env, jobject obj) { + jint result = (jint) alGetError(); + + CHECK_AL_ERROR + return result; +} + +/** + * This function tests if a specific extension is available for the OpenAL driver. + * + * C Specification: + * ALboolean alIsExtensionPresent(ALubyte *extName); + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_isExtensionPresent (JNIEnv *env, jobject obj, jstring fname) { + ALubyte* functionname = (ALubyte*) (env->GetStringUTFChars(fname, 0)); + jboolean result = (jboolean) alIsExtensionPresent(functionname); + env->ReleaseStringUTFChars((jstring)functionname, 0); + + CHECK_AL_ERROR + return result; +} + +/** + * This function returns the enumeration value of an OpenAL enum described by a string. + * + * C Specification: + * ALenum alGetEnumValue(ALubyte *enumName); + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_openal_CoreAL_getEnumValue (JNIEnv *env, jobject obj, jstring ename) { + ALubyte* functionname = (ALubyte*) (env->GetStringUTFChars(ename, 0)); + jint result = (jint) alGetEnumValue(functionname); + env->ReleaseStringUTFChars((jstring)functionname, 0); + + CHECK_AL_ERROR + return result; +} + +/** + * This function sets an integer property of the listener. + * + * C Specification: + * ALvoid alListeneri(ALenum pname,ALint value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_listeneri (JNIEnv *env, jobject obj, jint pname, jint value) { + alListeneri((ALenum) pname, (ALint) value); + CHECK_AL_ERROR +} + +/** + * This function sets a floating point property for the listener. + * + * C Specification: + * ALvoid alListenerf(ALenum pname,ALfloat value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_listenerf (JNIEnv *env, jobject obj, jint pname, jfloat value) { + alListenerf((ALenum) pname, (ALfloat) value); + CHECK_AL_ERROR +} + +/** + * This function sets a floating point property for the listener. + * + * C Specification: + * ALvoid alListener3f(ALenum pname,ALfloat v1,ALfloat v2,ALfloat v3); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_listener3f (JNIEnv *env, jobject obj, jint pname, jfloat v1, jfloat v2, jfloat v3) { + alListener3f((ALenum) pname, (ALfloat) v1, (ALfloat) v2, (ALfloat) v3); + CHECK_AL_ERROR +} + +/** + * This function sets a floating point-vector property of the listener. + * + * C Specification: + * ALvoid alListenerfv(ALenum pname,ALfloat *values); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_listenerfv (JNIEnv *env, jobject obj, jint pname, jint values) { + alListenerfv((ALenum) pname, (ALfloat*) values); + CHECK_AL_ERROR +} + +/** + * This function retrieves an integer property of the listener. + * + * C Specification: + * ALvoid alGetListeneri(ALenum pname,ALint *value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListeneri (JNIEnv *env, jobject obj, jint pname, jint value) { + alGetListeneri((ALenum) pname, (ALint*) value); + CHECK_AL_ERROR +} + +/** + * This function retrieves a floating point property of the listener. + * + * C Specification: + * ALvoid alGetListenerf(ALenum pname,ALfloat *value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListenerf (JNIEnv *env, jobject obj, jint pname, jint value) { + alGetListenerf((ALenum) pname, (ALfloat*) value); + CHECK_AL_ERROR +} + +/** + * This function retrieves a set of three floating point values from a property of the listener. + * + * C Specification: + * ALvoid alGetListener3f(ALenum pname,ALfloat *v1,ALfloat *v2,ALfloat *v3); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListener3f (JNIEnv *env, jobject obj, jint pname, jint v1, jint v2, jint v3) { + alGetListener3f((ALenum) pname, (ALfloat*) v1, (ALfloat*) v2, (ALfloat*) v3); + CHECK_AL_ERROR +} + +/** + * This function retrieves a floating point-vector property of the listener. + * + * C Specification: + * ALvoid alGetListenerfv(ALenum pname,ALfloat *values); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListenerfv (JNIEnv *env, jobject obj, jint pname, jint values) { + alGetListenerfv((ALenum) pname, (ALfloat*) values); + CHECK_AL_ERROR +} + +/** + * This function generates one or more sources. + * + * C Specification: + * ALvoid alGenSources(ALsizei n,ALuint *sources); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genSources (JNIEnv *env, jobject obj, jint n, jint sources) { + alGenSources(n, (ALuint*) sources); + CHECK_AL_ERROR +} + +/** + * This function deletes one or more sources. + * + * C Specification: + * ALvoid alDeleteSources(ALsizei n,ALuint *sources); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteSources (JNIEnv *env, jobject obj, jint n, jint sources) { + alDeleteSources(n, (ALuint*) sources); + CHECK_AL_ERROR +} + +/** + * This function tests if a source name is valid. + * + * C Specification: + * Alboolean alIsSource(ALuint source); + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_isSource (JNIEnv *env, jobject obj, jint source) { + jboolean result = (jboolean) alIsSource((ALuint) source); + + CHECK_AL_ERROR + return result; +} + +/** + * This function sets an integer property of a source. + * + * C Specification: + * ALvoid alSourcei(ALuint source,ALenum pname,ALint value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcei (JNIEnv *env, jobject obj, jint source, jint pname, jint value) { + alSourcei((ALuint) source, (ALenum) pname, (ALint) value); + CHECK_AL_ERROR +} + +/** + * This function sets a floating point property of a source. + * + * C Specification: + * ALvoid alSourcef(ALuint source,ALenum pname,ALfloat value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcef (JNIEnv *env, jobject obj, jint source, jint pname, jfloat value) { + alSourcef((ALuint) source, (ALenum) pname, (ALfloat) value); + CHECK_AL_ERROR +} + +/** + * This function sets a source property requiring three floating point values. + * C Specification: + * ALvoid alSource3f(ALuint source,ALenum pname,ALfloat v1,ALfloat v2,ALfloat v3); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_source3f (JNIEnv *env, jobject obj, jint source, jint pname, jfloat v1, jfloat v2, jfloat v3) { + alSource3f((ALuint) source, (ALenum) pname, (ALfloat) v1, (ALfloat) v2, (ALfloat) v3); + CHECK_AL_ERROR +} + +/** + * This function sets a floating point-vector property of a source. + * + * C Specification: + * ALvoid alSourcefv(ALuint source,ALenum pname,ALfloat *values); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcefv (JNIEnv *env, jobject obj, jint source, jint pname, jint values) { + alSourcefv((ALuint) source, (ALenum) pname, (ALfloat*) values); + CHECK_AL_ERROR +} + +/** + * This function retrieves an integer property of a source. + * C Specification: + * ALvoid alGetSourcei(ALuint source,ALenum pname,ALint *value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSourcei (JNIEnv *env, jobject obj, jint source, jint pname, jint value) { + alGetSourcei((ALuint) source, (ALenum) pname, (ALint*) value); + CHECK_AL_ERROR +} + +/** + * This function retrieves a floating point property of a source. + * + * C Specification: + * ALvoid alGetSourcef(ALuint source,ALenum pname,ALfloat *value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSourcef (JNIEnv *env, jobject obj, jint source, jint pname, jint value) { + alGetSourcef((ALuint) source, (ALenum) pname, (ALfloat*) value); + CHECK_AL_ERROR +} + +/* + * This function retrieves a set of three floating point values from a property of a source. + * + * C Specification: + * ALvoid alGetSource3f(ALuint source, ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSource3f (JNIEnv *env, jobject obj, jint source, jint pname, jint v1, jint v2, jint v3) { +#warning FIXME: alGetSource3f +/* alGetSource3f((ALuint) source, (ALenum) pname, (ALfloat*) v1, (ALfloat*) v2, (ALfloat*) v3);*/ + CHECK_AL_ERROR +} + +/** + * This function retrieves a floating point-vector property of a source. + * + * C Specification: + * ALvoid alGetSourcefv(ALuint source,ALenum pname,ALfloat *values); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSourcefv (JNIEnv *env, jobject obj, jint source, jint pname, jint values) { + alGetSourcefv((ALuint) source, (ALenum) pname, (ALfloat*) values); + CHECK_AL_ERROR +} + +/** + * This function plays a set of sources. + * + * C Specification: + * ALvoid alSourcePlayv(ALsizei n,ALuint *sources); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePlayv (JNIEnv *env, jobject obj, jint n, jint sources) { + alSourcePlayv(n, (ALuint*) sources); + CHECK_AL_ERROR +} + +/** + * This function pauses a set of sources. + * + * C Specification: + * ALvoid alSourcePausev(ALsizei n,ALuint *sources); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePausev (JNIEnv *env, jobject obj, jint n, jint sources) { + alSourcePausev(n, (ALuint*) sources); + CHECK_AL_ERROR +} + +/** + * This function stops a set of sources. + * + * C Specification: + * ALvoid alSourceStopv(ALsizei n,ALuint *sources); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStopv (JNIEnv *env, jobject obj, jint n, jint sources) { + alSourceStopv(n, (ALuint*) sources); + CHECK_AL_ERROR +} + +/** + * This function stops a set of sources and sets all their states to AL_INITIAL. + * + * C Specification: + * ALvoid alSourceRewindv(ALsizei n,ALuint *sources); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewindv (JNIEnv *env, jobject obj, jint n, jint sources) { + alSourceRewindv(n, (ALuint*) sources); + CHECK_AL_ERROR +} + +/** + * This function plays a source. + * + * C Specification: + * ALvoid alSourcePlay(ALuint source); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePlay (JNIEnv *env, jobject obj, jint source) { + alSourcePlay((ALuint) source); + CHECK_AL_ERROR +} + +/* + * This function pauses a source. + * + * C Specification: + * ALvoid alSourcePause(ALuint source); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePause (JNIEnv *env, jobject obj, jint source) { + alSourcePause((ALuint) source); + CHECK_AL_ERROR +} + +/** + * This function stops a source. + * + * C Specification: + * ALvoid alSourceStop(ALuint source); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStop (JNIEnv *env, jobject obj, jint source) { + alSourceStop((ALuint) source); + CHECK_AL_ERROR +} + +/** + * This function stops the source and sets its state to AL_INITIAL. + * + * C Specification: + * ALvoid alSourceRewind(ALuint source); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewind (JNIEnv *env, jobject obj, jint source) { + alSourceRewind((ALuint) source); + CHECK_AL_ERROR +} + +/** + * This function generates one or more buffers. + * + * C Specification: + * ALvoid alGenBuffers(ALsizei n,ALuint *buffers); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genBuffers (JNIEnv *env, jobject obj, jint n, jint buffers) { + alGenBuffers(n, (ALuint*) buffers); + CHECK_AL_ERROR +} + +/** + * This function deletes one or more buffers. + * + * C Specification: + * ALvoid alDeleteBuffers(ALsizei n,ALuint *buffers); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteBuffers (JNIEnv *env, jobject obj, jint n, jint buffers) { + alDeleteBuffers(n, (ALuint*) buffers); + CHECK_AL_ERROR +} + +/** + * This function tests if a buffer name is valid. + * + * C Specification: + * Alboolean alIsBuffer(ALuint buffer); + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_isBuffer (JNIEnv *env, jobject obj, jint buffer) { + jboolean result = (jboolean) alIsBuffer((ALuint) buffer); + + CHECK_AL_ERROR + return result; +} + +/** + * This function fills a buffer with audio data. + * + * C Specification: + * ALvoid alBufferData(ALuint buffer,ALenum format,ALvoid *data,ALsizei size,ALsizei freq); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_bufferData (JNIEnv *env, jobject obj, jint buffer, jint format, jint data, jint size, jint freq) { + alBufferData(buffer, format, (void**) data, size, freq); + CHECK_AL_ERROR +} + +/** + * This function retrieves an integer property of a buffer. + * + * C Specification: + * ALvoid alGetBufferi(ALuint buffer,ALenum pname,ALint *value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getBufferi (JNIEnv *env, jobject obj, jint buffer, jint pname, jint value) { + alGetBufferi((ALuint) buffer, (ALenum) pname, (ALint*) value); + CHECK_AL_ERROR +} + +/** + * This function retrieves a floating point property of a buffer. + * + * C Specification: + * ALvoid alGetBufferf(ALuint buffer,ALenum pname,ALfloat *value); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getBufferf (JNIEnv *env, jobject obj, jint buffer, jint pname, jint value) { + alGetBufferf((ALuint) buffer, (ALenum) pname, (ALfloat*) value); + CHECK_AL_ERROR +} + +/** + * This function queues a set of buffers on a source. + * + * 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, jint buffers) { + alSourceQueueBuffers((ALuint) source, (ALsizei) n, (ALuint*) buffers); + CHECK_AL_ERROR +} + +/** + * This function unqueues a set of buffers attached to a source. + * + * 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, jint buffers) { + alSourceUnqueueBuffers((ALuint) source, (ALsizei) n, (ALuint*) buffers); + CHECK_AL_ERROR +} + +/** + * This function selects the OpenAL distance model. + * + * C Specification: + * ALvoid alDistanceModel( ALenum value ); + */ + +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_distanceModel (JNIEnv *env, jobject obj, jint value) { + alDistanceModel((ALenum) value); + CHECK_AL_ERROR +} + +/** + * This function selects the OpenAL Doppler factor value. + * + * C Specification: + * ALvoid alDopplerFactor( ALfloat value ); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_dopplerFactor (JNIEnv *env, jobject obj, jfloat value) { + alDopplerFactor((ALfloat) value); + CHECK_AL_ERROR +} + +/** + * This function selects the OpenAL Doppler velocity value. + * + * C Specification: + * ALvoid alDopplerVelocity( ALfloat value ); + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_dopplerVelocity (JNIEnv *env, jobject obj, jfloat value) { + alDopplerVelocity((ALfloat) value); + CHECK_AL_ERROR +} diff --git a/src/native/linux/org_lwjgl_openal_eax_EAXBufferProperties.cpp b/src/native/linux/org_lwjgl_openal_eax_EAXBufferProperties.cpp new file mode 100644 index 00000000..c639ea30 --- /dev/null +++ b/src/native/linux/org_lwjgl_openal_eax_EAXBufferProperties.cpp @@ -0,0 +1,109 @@ +/* + * 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. + */ + +#include "org_lwjgl_openal_eax_EAXBufferProperties.h" +//#include +#include + +/* + * Class: org_lwjgl_openal_eax_EAXBufferProperties + * Method: sizeOfEaxBufferProperties + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_openal_eax_EAXBufferProperties_sizeOfEaxBufferProperties(JNIEnv *env, jobject obj) { +// return sizeof(EAXBUFFERPROPERTIES); +} + +/* + * Class: org_lwjgl_openal_eax_EAXBufferProperties + * Method: assignOffsets + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_eax_EAXBufferProperties_assignOffsets(JNIEnv *env, jobject obj) { +/* jclass listener_class; + jfieldID field; + + //get class/fields + listener_class = env->FindClass("org/lwjgl/openal/eax/EAXBufferProperties"); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "direct_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lDirect)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "directHF_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lDirectHF)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "room_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lRoom)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "roomHF_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lRoomHF)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "roomRolloffFactor_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flRoomRolloffFactor)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "obstruction_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lObstruction)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "obstructionLFRatio_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flObstructionLFRatio)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "occlusion_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lOcclusion)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "occlusionLFRatio_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flOcclusionLFRatio)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "occlusionRoomRatio_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flOcclusionRoomRatio)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "outsideVolumeHF_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lOutsideVolumeHF)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "airAbsorptionFactor_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flAirAbsorptionFactor)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "flags_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, dwFlags));*/ +} diff --git a/src/native/linux/org_lwjgl_openal_eax_EAXListenerProperties.cpp b/src/native/linux/org_lwjgl_openal_eax_EAXListenerProperties.cpp new file mode 100644 index 00000000..fab3c9f5 --- /dev/null +++ b/src/native/linux/org_lwjgl_openal_eax_EAXListenerProperties.cpp @@ -0,0 +1,113 @@ +/* + * 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. + */ + +#include "org_lwjgl_openal_eax_EAXListenerProperties.h" +//#include +#include + +/* + * Class: org_lwjgl_openal_eax_EAXListenerProperties + * Method: sizeOfEaxListenerProperties + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_openal_eax_EAXListenerProperties_sizeOfEaxListenerProperties(JNIEnv *env, jobject obj) { +// return sizeof(EAXLISTENERPROPERTIES); +} + +/* + * Class: org_lwjgl_openal_eax_EAXListenerProperties + * Method: assignOffsets + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_openal_eax_EAXListenerProperties_assignOffsets (JNIEnv *env, jobject obj) { +/* jclass listener_class; + jfieldID field; + + //get class/fields + listener_class = env->FindClass("org/lwjgl/openal/eax/EAXListenerProperties"); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "room_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lRoom)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "roomHF_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lRoomHF)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "roomRolloffFactor_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flRoomRolloffFactor)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "decayTime_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flDecayTime)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "decayHFRatio_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flDecayHFRatio)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "reflections_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lReflections)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "reflectionsDelay_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flReflectionsDelay)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "reverb_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lReverb)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "reverbDelay_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flReverbDelay)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "environment_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, dwEnvironment)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "environmentSize_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flEnvironmentSize)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "environmentDiffusion_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flEnvironmentDiffusion)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "airAbsorptionHF_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flAirAbsorptionHF)); + + //set environmentDiffusion_offset + field = env->GetStaticFieldID(listener_class, "flags_offset", "I"); + env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, dwFlags));*/ +}