|
From: <eli...@us...> - 2007-11-14 10:45:16
|
Revision: 2920
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2920&view=rev
Author: elias_naur
Date: 2007-11-14 02:45:07 -0800 (Wed, 14 Nov 2007)
Log Message:
-----------
openal: Improved error reporting from native library load
Modified Paths:
--------------
trunk/LWJGL/src/native/common/extal.h
trunk/LWJGL/src/native/common/org_lwjgl_openal_AL.c
trunk/LWJGL/src/native/linux/linux_al.c
trunk/LWJGL/src/native/macosx/macosx_al.c
trunk/LWJGL/src/native/windows/windows_al.c
Modified: trunk/LWJGL/src/native/common/extal.h
===================================================================
--- trunk/LWJGL/src/native/common/extal.h 2007-11-12 16:02:57 UTC (rev 2919)
+++ trunk/LWJGL/src/native/common/extal.h 2007-11-14 10:45:07 UTC (rev 2920)
@@ -162,7 +162,7 @@
/* Platform dependent functions */
void *NativeGetFunctionPointer(const char *function);
-bool tryLoadLibrary(JNIEnv *env, jstring path);
+void tryLoadLibrary(JNIEnv *env, jstring path);
void UnLoadOpenAL();
#ifdef __cplusplus
Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_AL.c
===================================================================
--- trunk/LWJGL/src/native/common/org_lwjgl_openal_AL.c 2007-11-12 16:02:57 UTC (rev 2919)
+++ trunk/LWJGL/src/native/common/org_lwjgl_openal_AL.c 2007-11-14 10:45:07 UTC (rev 2920)
@@ -35,9 +35,7 @@
#include "extal.h"
JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreate(JNIEnv *env, jclass clazz, jstring oalPath) {
- if (!tryLoadLibrary(env, oalPath)) {
- throwException(env, "Could not load OpenAL library");
- }
+ tryLoadLibrary(env, oalPath);
}
JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nDestroy(JNIEnv *env, jclass clazz) {
Modified: trunk/LWJGL/src/native/linux/linux_al.c
===================================================================
--- trunk/LWJGL/src/native/linux/linux_al.c 2007-11-12 16:02:57 UTC (rev 2919)
+++ trunk/LWJGL/src/native/linux/linux_al.c 2007-11-14 10:45:07 UTC (rev 2920)
@@ -45,15 +45,16 @@
return dlsym(handleOAL, function);
}
-bool tryLoadLibrary(JNIEnv *env, jstring path) {
+void tryLoadLibrary(JNIEnv *env, jstring path) {
char *path_str = GetStringNativeChars(env, path);
printfDebugJava(env, "Testing '%s'", path_str);
+ free(path_str);
handleOAL = dlopen(path_str, RTLD_LAZY);
if (handleOAL != NULL) {
printfDebugJava(env, "Found OpenAL at '%s'", path_str);
+ } else {
+ throwException(env, "Could not load OpenAL library");
}
- free(path_str);
- return handleOAL != NULL;
}
void UnLoadOpenAL() {
Modified: trunk/LWJGL/src/native/macosx/macosx_al.c
===================================================================
--- trunk/LWJGL/src/native/macosx/macosx_al.c 2007-11-12 16:02:57 UTC (rev 2919)
+++ trunk/LWJGL/src/native/macosx/macosx_al.c 2007-11-14 10:45:07 UTC (rev 2920)
@@ -89,15 +89,16 @@
return openal_bundle;
}
-bool tryLoadLibrary(JNIEnv *env, jstring path) {
+void tryLoadLibrary(JNIEnv *env, jstring path) {
const char *path_str = (*env)->GetStringUTFChars(env, path, NULL);
printfDebugJava(env, "Testing '%s'", path_str);
handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
+ (*env)->ReleaseStringUTFChars(env, path, path_str);
if (handleOAL != NULL) {
printfDebugJava(env, "Found OpenAL at '%s'", path_str);
+ } else {
+ throwException(env, "Could not load OpenAL library");
}
- (*env)->ReleaseStringUTFChars(env, path, path_str);
- return handleOAL != NULL;
}
/**
Modified: trunk/LWJGL/src/native/windows/windows_al.c
===================================================================
--- trunk/LWJGL/src/native/windows/windows_al.c 2007-11-12 16:02:57 UTC (rev 2919)
+++ trunk/LWJGL/src/native/windows/windows_al.c 2007-11-14 10:45:07 UTC (rev 2920)
@@ -51,15 +51,16 @@
return GetProcAddress(handleOAL, function);
}
-bool tryLoadLibrary(JNIEnv *env, jstring path) {
+void tryLoadLibrary(JNIEnv *env, jstring path) {
char *path_str = GetStringNativeChars(env, path);
printfDebugJava(env, "Testing '%s'", path_str);
handleOAL = LoadLibrary(path_str);
+ free(path_str);
if (handleOAL != NULL) {
printfDebugJava(env, "Found OpenAL at '%s'", path_str);
+ } else {
+ throwException(env, "Could not load OpenAL library (%d)", GetLastError());
}
- free(path_str);
- return handleOAL != NULL;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|