summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/java/net/java/games/joal/NativeLibLoader.java14
-rwxr-xr-xsrc/java/net/java/games/joal/impl/ALProcAddressLookup.java30
-rw-r--r--src/native/eaxfactory.c27
3 files changed, 47 insertions, 24 deletions
diff --git a/src/java/net/java/games/joal/NativeLibLoader.java b/src/java/net/java/games/joal/NativeLibLoader.java
index 011b1dd..5aace19 100755
--- a/src/java/net/java/games/joal/NativeLibLoader.java
+++ b/src/java/net/java/games/joal/NativeLibLoader.java
@@ -44,20 +44,6 @@ class NativeLibLoader {
static {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
-
- boolean useGlueGen =
- (System.getProperty("joal.use.gluegen") != null);
-
- if (useGlueGen) {
- // Workaround for problems when OpenAL is not installed;
- // want to be able to download the OpenAL shared library
- // over e.g. Java Web Start and still link against it, so we
- // have to use an alternate loading mechanism to work around
- // the JDK's usage of RTLD_LOCAL on Unix platforms
- NativeLibrary lib = NativeLibrary.open("OpenAL32", "openal", "openal",
- NativeLibLoader.class.getClassLoader());
- }
-
// Workaround for problem in OpenAL32.dll, which is actually
// the "wrapper" DLL which looks for real OpenAL
// implementations like nvopenal.dll and "*oal.dll".
diff --git a/src/java/net/java/games/joal/impl/ALProcAddressLookup.java b/src/java/net/java/games/joal/impl/ALProcAddressLookup.java
index 5291587..687e03b 100755
--- a/src/java/net/java/games/joal/impl/ALProcAddressLookup.java
+++ b/src/java/net/java/games/joal/impl/ALProcAddressLookup.java
@@ -43,6 +43,30 @@ public class ALProcAddressLookup {
private static volatile boolean alTableInitialized = false;
private static final ALCProcAddressTable alcTable = new ALCProcAddressTable();
private static volatile boolean alcTableInitialized = false;
+ private static final DynamicLookup lookup = new DynamicLookup();
+ private static volatile NativeLibrary openAL = null;
+
+ static class DynamicLookup implements DynamicLookupHelper {
+ public long dynamicLookupFunction(String functionName) {
+ // At some point this may require an OpenAL context to be
+ // current as we will actually use alGetProcAddress. Since
+ // this routine is currently broken and there are no
+ // per-context function pointers anyway we could actually do
+ // this work anywhere.
+ if (openAL == null) {
+ // We choose not to search the system path first because we
+ // bundle a very recent version of OpenAL which we would like
+ // to override existing installations
+ openAL = NativeLibrary.open("OpenAL32", "openal", "openal",
+ false,
+ ALProcAddressLookup.class.getClassLoader());
+ if (openAL == null) {
+ throw new RuntimeException("Unable to find and load OpenAL library");
+ }
+ }
+ return openAL.lookupFunction(functionName);
+ }
+ }
public static void resetALProcAddressTable() {
if (!alTableInitialized) {
@@ -55,8 +79,7 @@ public class ALProcAddressLookup {
// this work anywhere. We should also in theory have
// per-ALcontext ALProcAddressTables and per-ALCdevice
// ALCProcAddressTables.
- ALImpl impl = (ALImpl) ALFactory.getAL();
- ProcAddressHelper.resetProcAddressTable(alTable, impl);
+ ProcAddressHelper.resetProcAddressTable(alTable, lookup);
alTableInitialized = true;
}
}
@@ -74,8 +97,7 @@ public class ALProcAddressLookup {
// this work anywhere. We should also in theory have
// per-ALcontext ALProcAddressTables and per-ALCdevice
// ALCProcAddressTables.
- ALImpl impl = (ALImpl) ALFactory.getAL();
- ProcAddressHelper.resetProcAddressTable(alcTable, impl);
+ ProcAddressHelper.resetProcAddressTable(alcTable, lookup);
alcTableInitialized = true;
}
}
diff --git a/src/native/eaxfactory.c b/src/native/eaxfactory.c
index d0e3e9d..6ad89ce 100644
--- a/src/native/eaxfactory.c
+++ b/src/native/eaxfactory.c
@@ -37,8 +37,12 @@
#include "eax.h"
#ifdef _WIN32
-EAXSet eaxSet; // EAXSet function, ret$
-EAXGet eaxGet; // EAXGet function, ret$
+#include <windows.h>
+static HMODULE oalModule = NULL;
+static LPALISEXTENSIONPRESENT _ptr_alIsExtensionPresent = NULL;
+static LPALGETPROCADDRESS _ptr_alGetProcAddress = NULL;
+EAXSet eaxSet; // EAXSet function
+EAXGet eaxGet; // EAXGet function
#endif
/*
@@ -48,9 +52,20 @@ EAXGet eaxGet; // EAXGet function, ret$
JNIEXPORT void JNICALL Java_net_java_games_joal_eax_EAXFactory_init
(JNIEnv *env, jclass clazz) {
#ifdef _WIN32
- if(alIsExtensionPresent("EAX2.0")) {
- eaxSet = alGetProcAddress((ALubyte*)"EAXSet");
- eaxGet = alGetProcAddress((ALubyte*)"EAXGet");
- }
+ if (_ptr_alIsExtensionPresent == NULL) {
+ if (oalModule == NULL) {
+ oalModule = GetModuleHandle("OpenAL32");
+ }
+ _ptr_alIsExtensionPresent = (LPALISEXTENSIONPRESENT) GetProcAddress(oalModule, "alIsExtensionPresent");
+ _ptr_alGetProcAddress = (LPALGETPROCADDRESS) GetProcAddress(oalModule, "alGetProcAddress");
+ }
+
+ if (_ptr_alIsExtensionPresent != NULL &&
+ _ptr_alGetProcAddress != NULL) {
+ if ((*_ptr_alIsExtensionPresent)("EAX2.0")) {
+ eaxSet = (*_ptr_alGetProcAddress)((ALubyte*)"EAXSet");
+ eaxGet = (*_ptr_alGetProcAddress)((ALubyte*)"EAXGet");
+ }
+ }
#endif
}