summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-07-10 17:33:11 +0200
committerMichael Bien <[email protected]>2010-07-10 17:33:11 +0200
commitafa3632e8df813f54195c8a97833eff5c832d6ee (patch)
tree7ca4afd776f7c12919d598622b9498797273afd4
parent728c9b6e348520d778009f42633ea9f6e0e782a1 (diff)
fixed alcGetString functionpointer mapping (gluegen does not handle method renames correctly).
ALCImpl is now ALCAbstractImpl. "Custom code" is now in ALCImpl which extends ALCAbstractImpl.
-rwxr-xr-xmake/joal-alc-impl-CustomJavaCode.java52
-rwxr-xr-xmake/joal-alc.cfg4
-rw-r--r--src/java/com/jogamp/openal/impl/ALCImpl.java75
-rwxr-xr-xsrc/java/com/jogamp/openal/impl/ALProcAddressLookup.java33
-rw-r--r--test/src/com/jogamp/openal/OpenALTest.java12
5 files changed, 113 insertions, 63 deletions
diff --git a/make/joal-alc-impl-CustomJavaCode.java b/make/joal-alc-impl-CustomJavaCode.java
deleted file mode 100755
index c6f8e92..0000000
--- a/make/joal-alc-impl-CustomJavaCode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-public java.lang.String alcGetString(ALCdevice device, int param) {
- if (device == null && param == ALC_DEVICE_SPECIFIER) {
- throw new ALException("Call alcGetDeviceSpecifiers to fetch all available device names");
- }
-
- java.nio.ByteBuffer buf = alcGetStringImpl(device, param);
- if (buf == null) {
- return null;
- }
- byte[] res = new byte[buf.capacity()];
- buf.get(res);
- try {
- return new String(res, "US-ASCII");
- } catch (UnsupportedEncodingException e) {
- throw new ALException(e);
- }
-}
-
-/** Fetches the names of the available ALC device specifiers.
- Equivalent to the C call alcGetString(NULL, ALC_DEVICE_SPECIFIER). */
-public java.lang.String[] alcGetDeviceSpecifiers() {
- return getDoubleNullTerminatedString(ALC_DEVICE_SPECIFIER);
-}
-
-/** Fetches the names of the available ALC capture device specifiers.
- Equivalent to the C call alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER). */
-public java.lang.String[] alcGetCaptureDeviceSpecifiers() {
- return getDoubleNullTerminatedString(ALC_CAPTURE_DEVICE_SPECIFIER);
-}
-
-private java.lang.String[] getDoubleNullTerminatedString(int which) {
- java.nio.ByteBuffer buf = alcGetStringImpl(null, which);
- if (buf == null) {
- return null;
- }
- byte[] bytes = new byte[buf.capacity()];
- buf.get(bytes);
- try {
- ArrayList/*<String>*/ res = new ArrayList/*<String>*/();
- int i = 0;
- while (i < bytes.length) {
- int startIndex = i;
- while ((i < bytes.length) && (bytes[i] != 0))
- i++;
- res.add(new String(bytes, startIndex, i - startIndex, "US-ASCII"));
- i++;
- }
- return (String[]) res.toArray(new String[0]);
- } catch (UnsupportedEncodingException e) {
- throw new ALException(e);
- }
-}
diff --git a/make/joal-alc.cfg b/make/joal-alc.cfg
index 8626e43..3134a06 100755
--- a/make/joal-alc.cfg
+++ b/make/joal-alc.cfg
@@ -4,7 +4,8 @@ Include joal-common.cfg
Style InterfaceAndImpl
JavaClass ALC
ImplPackage com.jogamp.openal.impl
-ImplJavaClass ALCImpl
+ImplJavaClass ALCAbstractImpl
+AccessControl ALCAbstractImpl PUBLIC_ABSTRACT
Extends ALC ALCConstants
EmitProcAddressTable true
@@ -35,7 +36,6 @@ ReturnValueCapacity alcGetStringImpl strlen_alc(_device_ptr, {1}, _res)
# Note that we don't declare this as "ReturnsString" because we're
# going to wrap it in another method
IncludeAs CustomJavaCode ALC joal-alc-CustomJavaCode.java
-IncludeAs CustomJavaCode ALCImpl joal-alc-impl-CustomJavaCode.java
# These routines use strings
ArgumentIsString alcIsExtensionPresent 1
diff --git a/src/java/com/jogamp/openal/impl/ALCImpl.java b/src/java/com/jogamp/openal/impl/ALCImpl.java
new file mode 100644
index 0000000..208e64f
--- /dev/null
+++ b/src/java/com/jogamp/openal/impl/ALCImpl.java
@@ -0,0 +1,75 @@
+/*
+ * Created on Saturday, July 10 2010 17:08
+ */
+package com.jogamp.openal.impl;
+
+import com.jogamp.openal.ALException;
+import com.jogamp.openal.ALCdevice;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+
+/**
+ * ALC implementation.
+ * @author Michael Bien
+ */
+public class ALCImpl extends ALCAbstractImpl {
+
+ public String alcGetString(ALCdevice device, int param) {
+ if (device == null && param == ALC_DEVICE_SPECIFIER) {
+ throw new ALException("Call alcGetDeviceSpecifiers to fetch all available device names");
+ }
+
+ ByteBuffer buf = alcGetStringImpl(device, param);
+ if (buf == null) {
+ return null;
+ }
+ byte[] res = new byte[buf.capacity()];
+ buf.get(res);
+ try {
+ return new String(res, "US-ASCII");
+ } catch (UnsupportedEncodingException e) {
+ throw new ALException(e);
+ }
+ }
+
+ /**
+ * Fetches the names of the available ALC device specifiers.
+ * Equivalent to the C call alcGetString(NULL, ALC_DEVICE_SPECIFIER).
+ */
+ public String[] alcGetDeviceSpecifiers() {
+ return getDoubleNullTerminatedString(ALC_DEVICE_SPECIFIER);
+ }
+
+ /**
+ * Fetches the names of the available ALC capture device specifiers.
+ * Equivalent to the C call alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER).
+ */
+ public String[] alcGetCaptureDeviceSpecifiers() {
+ return getDoubleNullTerminatedString(ALC_CAPTURE_DEVICE_SPECIFIER);
+ }
+
+ private String[] getDoubleNullTerminatedString(int which) {
+ ByteBuffer buf = alcGetStringImpl(null, which);
+ if (buf == null) {
+ return null;
+ }
+ byte[] bytes = new byte[buf.capacity()];
+ buf.get(bytes);
+ try {
+ ArrayList/*<String>*/ res = new ArrayList/*<String>*/();
+ int i = 0;
+ while (i < bytes.length) {
+ int startIndex = i;
+ while ((i < bytes.length) && (bytes[i] != 0)) {
+ i++;
+ }
+ res.add(new String(bytes, startIndex, i - startIndex, "US-ASCII"));
+ i++;
+ }
+ return (String[]) res.toArray(new String[res.size()]);
+ } catch (UnsupportedEncodingException e) {
+ throw new ALException(e);
+ }
+ }
+}
diff --git a/src/java/com/jogamp/openal/impl/ALProcAddressLookup.java b/src/java/com/jogamp/openal/impl/ALProcAddressLookup.java
index 7f16628..45718dd 100755
--- a/src/java/com/jogamp/openal/impl/ALProcAddressLookup.java
+++ b/src/java/com/jogamp/openal/impl/ALProcAddressLookup.java
@@ -39,19 +39,34 @@ import java.lang.reflect.Field;
import com.jogamp.openal.*;
import com.jogamp.gluegen.runtime.*;
-import com.jogamp.openal.impl.ALCProcAddressTable;
-import com.jogamp.openal.impl.ALImpl;
-import com.jogamp.openal.impl.ALProcAddressTable;
/** Helper class for managing OpenAL-related proc address tables. */
public class ALProcAddressLookup {
- private static final ALProcAddressTable alTable = new ALProcAddressTable();
- 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;
+
+ private static final ALProcAddressTable alTable;
+ private static final ALCProcAddressTable alcTable;
+
+ private static volatile boolean alTableInitialized = false;
+ private static volatile boolean alcTableInitialized = false;
+
+ private static final DynamicLookup lookup;
+ private static volatile NativeLibrary openAL;
+
+ static {
+ //workaround: map renamed fooImpl back to the real function name
+ FunctionAddressResolver resolver = new FunctionAddressResolver() {
+ public long resolve(String string, DynamicLookupHelper dlh) {
+ if (string.endsWith("Impl")) {
+ string = string.substring(0, string.length() - 4);
+ }
+ return dlh.dynamicLookupFunction(string);
+ }
+ };
+ alcTable = new ALCProcAddressTable(resolver);
+ alTable = new ALProcAddressTable();
+ lookup = new DynamicLookup();
+ }
static class DynamicLookup implements DynamicLookupHelper {
public long dynamicLookupFunction(String functionName) {
diff --git a/test/src/com/jogamp/openal/OpenALTest.java b/test/src/com/jogamp/openal/OpenALTest.java
index ec8d50f..69ee204 100644
--- a/test/src/com/jogamp/openal/OpenALTest.java
+++ b/test/src/com/jogamp/openal/OpenALTest.java
@@ -52,6 +52,18 @@ public class OpenALTest {
ALCcontext context = alc.alcCreateContext(device, null);
alc.alcMakeContextCurrent(context);
AL al = ALFactory.getAL();
+
+ System.out.println("devices:");
+ String[] devices = alc.alcGetDeviceSpecifiers();
+ for (String name : devices) {
+ System.out.println(" "+name);
+ }
+ System.out.println("capture devices:");
+ devices = alc.alcGetCaptureDeviceSpecifiers();
+ for (String name : devices) {
+ System.out.println(" "+name);
+ }
+
boolean eaxPresent = al.alIsExtensionPresent("EAX2.0");
System.out.println("EAX present:" + eaxPresent);