Moved ALC error check to java. Fix linux type cast warnings
This commit is contained in:
parent
f5cf0ef2a4
commit
f3d3ce7ce5
|
@ -164,10 +164,11 @@ public final class ALC {
|
|||
* @return String property from device
|
||||
*/
|
||||
public static String alcGetString(int pname) {
|
||||
return nalcGetString(AL.device.device, pname);
|
||||
String result = nalcGetString(AL.device.device, pname);
|
||||
Util.checkALCError();
|
||||
return result;
|
||||
}
|
||||
|
||||
native static String nalcGetString(long device, int pname);
|
||||
private native static String nalcGetString(long device, int pname);
|
||||
|
||||
/**
|
||||
* The application can query ALC for information using an integer query function.
|
||||
|
@ -192,9 +193,9 @@ public final class ALC {
|
|||
public static void alcGetInteger(int pname, IntBuffer integerdata) {
|
||||
BufferChecks.checkDirect(integerdata);
|
||||
nalcGetIntegerv(AL.device.device, pname, integerdata.remaining(), integerdata, integerdata.position());
|
||||
Util.checkALCError();
|
||||
}
|
||||
|
||||
native static void nalcGetIntegerv(long device, int pname, int size, Buffer integerdata, int offset);
|
||||
private native static void nalcGetIntegerv(long device, int pname, int size, Buffer integerdata, int offset);
|
||||
|
||||
/**
|
||||
* The <code>alcOpenDevice</code> function allows the application (i.e. the client program) to
|
||||
|
@ -236,7 +237,12 @@ public final class ALC {
|
|||
* @param attrList Buffer to read attributes from
|
||||
* @return New context, or null if creation failed
|
||||
*/
|
||||
native static ALCcontext alcCreateContext(long device, IntBuffer attrList);
|
||||
static ALCcontext alcCreateContext(long device, IntBuffer attrList) {
|
||||
ALCcontext result = nalcCreateContext(device, attrList);
|
||||
Util.checkALCError();
|
||||
return result;
|
||||
}
|
||||
private native static ALCcontext nalcCreateContext(long device, IntBuffer attrList);
|
||||
|
||||
/**
|
||||
* To make a Context current with respect to AL Operation (state changes by issueing
|
||||
|
@ -268,8 +274,7 @@ public final class ALC {
|
|||
public static void alcProcessContext() {
|
||||
nalcProcessContext(AL.context.context);
|
||||
}
|
||||
|
||||
native static void nalcProcessContext(long context);
|
||||
private native static void nalcProcessContext(long context);
|
||||
|
||||
/**
|
||||
* The application can query for, and obtain an handle to, the current context for the
|
||||
|
@ -302,7 +307,7 @@ public final class ALC {
|
|||
public static void alcSuspendContext() {
|
||||
nalcSuspendContext(AL.context.context);
|
||||
}
|
||||
native static void nalcSuspendContext(long context);
|
||||
private native static void nalcSuspendContext(long context);
|
||||
|
||||
/**
|
||||
* The correct way to destroy a context is to first release it using <code>alcMakeCurrent</code> and
|
||||
|
@ -330,8 +335,7 @@ public final class ALC {
|
|||
public static int alcGetError() {
|
||||
return nalcGetError(AL.device.device);
|
||||
}
|
||||
|
||||
native static int nalcGetError(long device);
|
||||
private native static int nalcGetError(long device);
|
||||
|
||||
/**
|
||||
* Verify that a given extension is available for the current context and the device it
|
||||
|
@ -343,10 +347,11 @@ public final class ALC {
|
|||
* @return true if extension is available, false if not
|
||||
*/
|
||||
public static boolean alcIsExtensionPresent(String extName) {
|
||||
return nalcIsExtensionPresent(AL.device.device, extName);
|
||||
boolean result = nalcIsExtensionPresent(AL.device.device, extName);
|
||||
Util.checkALCError();
|
||||
return result;
|
||||
}
|
||||
|
||||
native static boolean nalcIsExtensionPresent(long device, String extName);
|
||||
private native static boolean nalcIsExtensionPresent(long device, String extName);
|
||||
|
||||
/**
|
||||
* Enumeration/token values are device independend, but tokens defined for
|
||||
|
@ -359,8 +364,9 @@ public final class ALC {
|
|||
* @return value of enumeration
|
||||
*/
|
||||
public static int alcGetEnumValue(String enumName) {
|
||||
return nalcGetEnumValue(AL.device.device, enumName);
|
||||
int result = nalcGetEnumValue(AL.device.device, enumName);
|
||||
Util.checkALCError();
|
||||
return result;
|
||||
}
|
||||
|
||||
native static int nalcGetEnumValue(long device, String enumName);
|
||||
private native static int nalcGetEnumValue(long device, String enumName);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,12 @@ public final class Util {
|
|||
private Util() {
|
||||
}
|
||||
|
||||
public static void checkALCError() {
|
||||
int err = ALC.alcGetError();
|
||||
if (err != ALC.ALC_NO_ERROR)
|
||||
throw new OpenALException(ALC.alcGetString(err));
|
||||
}
|
||||
|
||||
public static void checkALError() {
|
||||
int err = AL10.alGetError();
|
||||
if (err != AL10.AL_NO_ERROR)
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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.
|
||||
*/
|
||||
|
||||
#ifndef _CHECKALERROR_H_INCLUDED_
|
||||
#define _CHECKALERROR_H_INCLUDED_
|
||||
|
||||
#include <jni.h>
|
||||
#include "extal.h"
|
||||
#include "common_tools.h"
|
||||
|
||||
/* only available if deviceaddress is specified in method */
|
||||
#define CHECK_ALC_ERROR \
|
||||
{ \
|
||||
int err = alcGetError((ALCdevice*) deviceaddress); \
|
||||
if (err != AL_NO_ERROR) { \
|
||||
jclass cls = (*env)->FindClass(env, "org/lwjgl/openal/OpenALException"); \
|
||||
(*env)->ThrowNew(env, cls, (const char*) alcGetString((ALCdevice*) deviceaddress, err)); \
|
||||
(*env)->DeleteLocalRef(env, cls); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif /* _CHECKALERROR_H_INCLUDED_ */
|
|
@ -33,7 +33,6 @@
|
|||
#include "org_lwjgl_openal_AL.h"
|
||||
|
||||
/* OpenAL includes */
|
||||
#include "checkALerror.h"
|
||||
#include "extal.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreate (JNIEnv *env, jclass clazz, jobjectArray oalPaths) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* MACHINE GENERATED FILE, DO NOT EDIT */
|
||||
|
||||
#include <jni.h>
|
||||
#include "checkALerror.h"
|
||||
#include "extal.h"
|
||||
|
||||
typedef ALvoid (ALAPIENTRY *alDopplerVelocityPROC) (ALfloat value);
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
*/
|
||||
|
||||
/* OpenAL includes */
|
||||
#include "checkALerror.h"
|
||||
#include "extal.h"
|
||||
|
||||
//alc
|
||||
|
@ -82,7 +81,7 @@ static alcGetEnumValuePROC alcGetEnumValue;
|
|||
* ALubyte * alcGetString(ALCdevice *device, ALenum token);
|
||||
*/
|
||||
static jstring JNICALL Java_org_lwjgl_openal_ALC_nalcGetString (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token) {
|
||||
const char* alcString = (const char*) alcGetString((ALCdevice*) deviceaddress, (ALenum) token);
|
||||
const char* alcString = (const char*) alcGetString((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token);
|
||||
jstring string;
|
||||
|
||||
if(alcString == NULL) {
|
||||
|
@ -91,7 +90,6 @@ static jstring JNICALL Java_org_lwjgl_openal_ALC_nalcGetString (JNIEnv *env, jcl
|
|||
|
||||
string = NewStringNative(env, alcString);
|
||||
|
||||
CHECK_ALC_ERROR
|
||||
return string;
|
||||
}
|
||||
|
||||
|
@ -106,8 +104,7 @@ static void JNICALL Java_org_lwjgl_openal_ALC_nalcGetIntegerv (JNIEnv *env, jcla
|
|||
if (dest != NULL) {
|
||||
address = offset + (ALint*) (*env)->GetDirectBufferAddress(env, dest);
|
||||
}
|
||||
alcGetIntegerv((ALCdevice*) deviceaddress, (ALenum) token, (ALsizei) size, address);
|
||||
CHECK_ALC_ERROR
|
||||
alcGetIntegerv((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token, (ALsizei) size, address);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,7 +143,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcOpenDevice (JNIEnv *env, jcl
|
|||
alcDevice_method = (*env)->GetMethodID(env, alcDevice_class, "<init>", "(J)V");
|
||||
|
||||
/* create instance */
|
||||
alcDevice_object = (*env)->NewObject(env, alcDevice_class, alcDevice_method, (jlong) device);
|
||||
alcDevice_object = (*env)->NewObject(env, alcDevice_class, alcDevice_method, (jlong)((intptr_t)device));
|
||||
|
||||
/* clean up */
|
||||
if (tokenstring != NULL)
|
||||
|
@ -162,7 +159,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcOpenDevice (JNIEnv *env, jcl
|
|||
* void alcCloseDevice( ALCdevice *dev );
|
||||
*/
|
||||
static void JNICALL Java_org_lwjgl_openal_ALC_alcCloseDevice (JNIEnv *env, jclass clazz, jlong deviceaddress) {
|
||||
alcCloseDevice((ALCdevice*) deviceaddress);
|
||||
alcCloseDevice((ALCdevice*)((intptr_t)deviceaddress));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,7 +168,7 @@ static void JNICALL Java_org_lwjgl_openal_ALC_alcCloseDevice (JNIEnv *env, jclas
|
|||
* C Specification:
|
||||
* ALCcontext* alcCreateContext( ALCdevice *dev, ALint* attrlist );
|
||||
*/
|
||||
static jobject JNICALL Java_org_lwjgl_openal_ALC_alcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jobject attrlist) {
|
||||
static jobject JNICALL Java_org_lwjgl_openal_ALC_nalcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jobject attrlist) {
|
||||
ALint* address = NULL;
|
||||
ALCcontext* context;
|
||||
/* get ready to create ALCcontext instance */
|
||||
|
@ -182,7 +179,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcCreateContext (JNIEnv *env,
|
|||
if (attrlist != NULL) {
|
||||
address = (ALint*) (*env)->GetDirectBufferAddress(env, attrlist);
|
||||
}
|
||||
context = alcCreateContext((ALCdevice*) deviceaddress, address);
|
||||
context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), address);
|
||||
|
||||
/* if error - get out */
|
||||
if(context == NULL) {
|
||||
|
@ -194,9 +191,8 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcCreateContext (JNIEnv *env,
|
|||
alcContext_method = (*env)->GetMethodID(env, alcContext_class, "<init>", "(J)V");
|
||||
|
||||
/* create instance */
|
||||
alcContext_object = (*env)->NewObject(env, alcContext_class, alcContext_method, (jlong)context);
|
||||
alcContext_object = (*env)->NewObject(env, alcContext_class, alcContext_method, (jlong)((intptr_t)context));
|
||||
|
||||
CHECK_ALC_ERROR
|
||||
return alcContext_object;
|
||||
}
|
||||
|
||||
|
@ -207,7 +203,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcCreateContext (JNIEnv *env,
|
|||
* ALCboolean alcMakeContextCurrent(ALCcontext *context);
|
||||
*/
|
||||
static jint JNICALL Java_org_lwjgl_openal_ALC_alcMakeContextCurrent (JNIEnv *env, jclass clazz, jlong contextaddress) {
|
||||
ALCcontext* context = (ALCcontext*) contextaddress;
|
||||
ALCcontext* context = (ALCcontext*)((intptr_t)contextaddress);
|
||||
ALCenum result;
|
||||
if(context == NULL) {
|
||||
result = alcMakeContextCurrent(NULL);
|
||||
|
@ -224,7 +220,7 @@ static jint JNICALL Java_org_lwjgl_openal_ALC_alcMakeContextCurrent (JNIEnv *env
|
|||
* void alcProcessContext(ALCcontext *context);
|
||||
*/
|
||||
static void JNICALL Java_org_lwjgl_openal_ALC_nalcProcessContext (JNIEnv *env, jclass clazz, jlong contextaddress) {
|
||||
alcProcessContext((ALCcontext*) contextaddress);
|
||||
alcProcessContext((ALCcontext*)((intptr_t)contextaddress));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -249,7 +245,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcGetCurrentContext (JNIEnv *e
|
|||
alcContext_method = (*env)->GetMethodID(env, alcContext_class, "<init>", "(J)V");
|
||||
|
||||
/* create instance */
|
||||
alcContext_object = (*env)->NewObject(env, alcContext_class, alcContext_method, (jlong) context);
|
||||
alcContext_object = (*env)->NewObject(env, alcContext_class, alcContext_method, (jlong)((intptr_t)context));
|
||||
|
||||
return alcContext_object;
|
||||
}
|
||||
|
@ -261,8 +257,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcGetCurrentContext (JNIEnv *e
|
|||
* ALCdevice* alcGetContextsDevice(ALCcontext *context);
|
||||
*/
|
||||
static jobject JNICALL Java_org_lwjgl_openal_ALC_alcGetContextsDevice (JNIEnv *env, jclass clazz, jlong contextaddress) {
|
||||
|
||||
ALCdevice* device = alcGetContextsDevice((ALCcontext*) contextaddress);
|
||||
ALCdevice* device = alcGetContextsDevice((ALCcontext*)((intptr_t)contextaddress));
|
||||
/* get ready to create ALCdevice instance */
|
||||
jobject alcDevice_object = NULL;
|
||||
jclass alcDevice_class = NULL;
|
||||
|
@ -277,7 +272,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcGetContextsDevice (JNIEnv *e
|
|||
alcDevice_method = (*env)->GetMethodID(env, alcDevice_class, "<init>", "(J)V");
|
||||
|
||||
/* create instance */
|
||||
alcDevice_object = (*env)->NewObject(env, alcDevice_class, alcDevice_method, (jlong) device);
|
||||
alcDevice_object = (*env)->NewObject(env, alcDevice_class, alcDevice_method, (jlong)((intptr_t)device));
|
||||
|
||||
return alcDevice_object;
|
||||
}
|
||||
|
@ -289,7 +284,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcGetContextsDevice (JNIEnv *e
|
|||
* void alcSuspendContext(ALCcontext *context);
|
||||
*/
|
||||
static void JNICALL Java_org_lwjgl_openal_ALC_nalcSuspendContext (JNIEnv *env, jclass clazz, jlong contextaddress) {
|
||||
alcSuspendContext((ALCcontext*) contextaddress);
|
||||
alcSuspendContext((ALCcontext*)((intptr_t)contextaddress));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,7 +294,7 @@ static void JNICALL Java_org_lwjgl_openal_ALC_nalcSuspendContext (JNIEnv *env, j
|
|||
* void alcDestroyContext(ALCcontext *context);
|
||||
*/
|
||||
static void JNICALL Java_org_lwjgl_openal_ALC_alcDestroyContext (JNIEnv *env, jclass clazz, jlong contextaddress) {
|
||||
alcDestroyContext((ALCcontext*) contextaddress);
|
||||
alcDestroyContext((ALCcontext*)((intptr_t)contextaddress));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -309,8 +304,7 @@ static void JNICALL Java_org_lwjgl_openal_ALC_alcDestroyContext (JNIEnv *env, jc
|
|||
* ALCenum alcGetError(ALCdevice *device);
|
||||
*/
|
||||
static jint JNICALL Java_org_lwjgl_openal_ALC_nalcGetError (JNIEnv *env, jclass clazz, jlong deviceaddress) {
|
||||
jint result = alcGetError((ALCdevice*) deviceaddress);
|
||||
CHECK_ALC_ERROR
|
||||
jint result = alcGetError((ALCdevice*)((intptr_t)deviceaddress));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -324,11 +318,10 @@ static jboolean JNICALL Java_org_lwjgl_openal_ALC_nalcIsExtensionPresent (JNIEnv
|
|||
/* get extension */
|
||||
ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName);
|
||||
|
||||
jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*) deviceaddress, functionname);
|
||||
jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), functionname);
|
||||
|
||||
free(functionname);
|
||||
|
||||
CHECK_ALC_ERROR
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -342,11 +335,10 @@ static jint JNICALL Java_org_lwjgl_openal_ALC_nalcGetEnumValue (JNIEnv *env, jcl
|
|||
/* get extension */
|
||||
ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName);
|
||||
|
||||
jint result = (jint) alcGetEnumValue((ALCdevice*) deviceaddress, enumerationname);
|
||||
jint result = (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), enumerationname);
|
||||
|
||||
free(enumerationname);
|
||||
|
||||
CHECK_ALC_ERROR
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -364,7 +356,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_initNativeStubs(JNIEnv *env, jc
|
|||
{"nalcGetIntegerv", "(JIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_openal_ALC_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv},
|
||||
{"alcOpenDevice", "(Ljava/lang/String;)Lorg/lwjgl/openal/ALCdevice;", (void*)&Java_org_lwjgl_openal_ALC_alcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice},
|
||||
{"alcCloseDevice", "(J)V", (void*)&Java_org_lwjgl_openal_ALC_alcCloseDevice, "alcCloseDevice", (void*)&alcCloseDevice},
|
||||
{"alcCreateContext", "(JLjava/nio/IntBuffer;)Lorg/lwjgl/openal/ALCcontext;", (void*)&Java_org_lwjgl_openal_ALC_alcCreateContext, "alcCreateContext", (void*)&alcCreateContext},
|
||||
{"nalcCreateContext", "(JLjava/nio/IntBuffer;)Lorg/lwjgl/openal/ALCcontext;", (void*)&Java_org_lwjgl_openal_ALC_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext},
|
||||
{"alcMakeContextCurrent", "(J)I", (void*)&Java_org_lwjgl_openal_ALC_alcMakeContextCurrent, "alcMakeContextCurrent", (void*)&alcMakeContextCurrent},
|
||||
{"nalcProcessContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC_nalcProcessContext, "alcProcessContext", (void*)&alcProcessContext},
|
||||
{"alcGetCurrentContext", "()Lorg/lwjgl/openal/ALCcontext;", (void*)&Java_org_lwjgl_openal_ALC_alcGetCurrentContext, "alcGetCurrentContext", (void*)&alcGetCurrentContext},
|
||||
|
|
Loading…
Reference in New Issue