From bf09df70444f38424a84fc382498b57498bb5601 Mon Sep 17 00:00:00 2001 From: Mathieu Féry Date: Fri, 10 Nov 2023 15:50:24 +0100 Subject: feat(devices): Allow to retrieve devices specifiers with ALC_ENUMERATE_ALL_EXT --- make/config/joal-alc-CustomJavaCode.java | 19 +++++ make/config/joal-alc-constants-CustomJavaCode.java | 3 + make/config/joal-alc-constants.cfg | 2 + make/config/joal-alc-impl-CustomCCode.c | 12 +++- src/java/com/jogamp/openal/JoalVersion.java | 84 ++++++++++++++++------ src/java/jogamp/openal/ALCImpl.java | 42 +++++++---- src/native/almisc.c | 25 +++++-- .../com/jogamp/openal/test/manual/Synth01AL.java | 9 +++ 8 files changed, 154 insertions(+), 42 deletions(-) create mode 100644 make/config/joal-alc-constants-CustomJavaCode.java diff --git a/make/config/joal-alc-CustomJavaCode.java b/make/config/joal-alc-CustomJavaCode.java index be28d8c..6615c01 100644 --- a/make/config/joal-alc-CustomJavaCode.java +++ b/make/config/joal-alc-CustomJavaCode.java @@ -1,3 +1,18 @@ +/** Specify if ALC_ENUMERATION_EXT is present */ +public boolean aclEnumerationExtIsPresent(); + +/** Specify if ALC_ENUMERATE_ALL_EXT is present */ +public boolean aclEnumerateAllExtIsPresent(); + +/** Specify if call of alGetString(device, param) must + must retrun a double null terminted string */ +public boolean alcIsDoubleNullTerminatedString(final com.jogamp.openal.ALCdevice device, final int param); + +/** Fetches all values of device and param supplied from result of call to alcGetString + Each value is extracted from string because is a string double null terminated + Equivalent to the C call alcGetString(device, param). */ +public java.lang.String[] alcGetStringAsDoubleNullTerminatedString(final com.jogamp.openal.ALCdevice device, final int param); + /** Fetches the names of the available ALC device specifiers. Equivalent to the C call alcGetString(NULL, ALC_DEVICE_SPECIFIER). */ public java.lang.String[] alcGetDeviceSpecifiers(); @@ -5,3 +20,7 @@ public java.lang.String[] alcGetDeviceSpecifiers(); /** 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(); + +/** Fetches the names of the available ALC all capture device specifiers. + Equivalent to the C call alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER). */ +public java.lang.String[] alcGetAllDeviceSpecifiers(); diff --git a/make/config/joal-alc-constants-CustomJavaCode.java b/make/config/joal-alc-constants-CustomJavaCode.java new file mode 100644 index 0000000..fe97124 --- /dev/null +++ b/make/config/joal-alc-constants-CustomJavaCode.java @@ -0,0 +1,3 @@ +public final java.lang.String ALC_ENUMERATION_EXT_NAME = "ALC_ENUMERATION_EXT"; + +public final java.lang.String ALC_ENUMERATE_ALL_EXT_NAME = "ALC_ENUMERATE_ALL_EXT"; \ No newline at end of file diff --git a/make/config/joal-alc-constants.cfg b/make/config/joal-alc-constants.cfg index 83ea061..b58f700 100644 --- a/make/config/joal-alc-constants.cfg +++ b/make/config/joal-alc-constants.cfg @@ -6,3 +6,5 @@ JavaClass ALCConstants # Factor out the OpenAL constants into their own interface IgnoreNot ^ALC_.+ + +IncludeAs CustomJavaCode ALCConstants joal-alc-constants-CustomJavaCode.java diff --git a/make/config/joal-alc-impl-CustomCCode.c b/make/config/joal-alc-impl-CustomCCode.c index 9207210..bd4a57a 100644 --- a/make/config/joal-alc-impl-CustomCCode.c +++ b/make/config/joal-alc-impl-CustomCCode.c @@ -1,6 +1,16 @@ +#include + +bool alc_is_double_null_terminated_string(ALCdevice *device, int param) { + return device == NULL && ( + param == ALC_DEVICE_SPECIFIER || + param == ALC_CAPTURE_DEVICE_SPECIFIER || + param == ALC_ALL_DEVICES_SPECIFIER + ); +} + int strlen_alc(ALCdevice *device, int param, const char* str) { int len = 0; - if ((device == NULL) && (param == ALC_DEVICE_SPECIFIER)) { + if (alc_is_double_null_terminated_string(device, param)) { while (*str != 0) { while (*str != 0) { ++str; diff --git a/src/java/com/jogamp/openal/JoalVersion.java b/src/java/com/jogamp/openal/JoalVersion.java index f2ffc48..bca175e 100644 --- a/src/java/com/jogamp/openal/JoalVersion.java +++ b/src/java/com/jogamp/openal/JoalVersion.java @@ -119,21 +119,42 @@ public class JoalVersion extends JogampVersion { alv.toString(true, sb); sb.append("AL_EXTENSIONS ").append(al.alGetString(ALConstants.AL_EXTENSIONS)); sb.append(Platform.getNewline()); + final boolean enumerationExtIsPresent = alc.aclEnumerationExtIsPresent(); + final boolean enumerateAllExtIsPresent = alc.aclEnumerateAllExtIsPresent(); { final int[] iversion = { 0, 0 }; alc.alcGetIntegerv(device, ALCConstants.ALC_MAJOR_VERSION, 1, iversion, 0); alc.alcGetIntegerv(device, ALCConstants.ALC_MINOR_VERSION, 1, iversion, 1); sb.append("ALC_VERSION ").append(iversion[0]).append(".").append(iversion[1]); sb.append(Platform.getNewline()); - sb.append("ALC_DEF_OUTPUT ").append(alc.alcGetString(device, ALCConstants.ALC_DEFAULT_DEVICE_SPECIFIER)); - sb.append(Platform.getNewline()); - sb.append("ALC_DEF_CAPTURE ").append(alc.alcGetString(device, ALCConstants.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); - sb.append(Platform.getNewline()); + if (!enumerationExtIsPresent && !enumerateAllExtIsPresent) { + sb.append("ALC_DEF_OUTPUT Unknown (Missing "+ + ALCConstants.ALC_ENUMERATION_EXT_NAME+" and "+ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME+")"); + sb.append(Platform.getNewline()); + } else { + if (enumerationExtIsPresent) { + sb.append("ALC_DEF_OUTPUT (With " + ALCConstants.ALC_ENUMERATION_EXT_NAME + ") ") + .append(alc.alcGetString(device, ALCConstants.ALC_DEFAULT_DEVICE_SPECIFIER)); + sb.append(Platform.getNewline()); + } + if (enumerateAllExtIsPresent) { + sb.append("ALC_DEF_OUTPUT (With " + ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME + ") ") + .append(alc.alcGetString(device, ALCConstants.ALC_DEFAULT_ALL_DEVICES_SPECIFIER)); + sb.append(Platform.getNewline()); + } + } + if (enumerationExtIsPresent) { + sb.append("ALC_DEF_CAPTURE ").append(alc.alcGetString(device, ALCConstants.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); + sb.append(Platform.getNewline()); + } else { + sb.append("ALC_DEF_CAPTURE Unknown (Missing "+ALCConstants.ALC_ENUMERATION_EXT_NAME+")"); + sb.append(Platform.getNewline()); + } } alc.alcMakeContextCurrent(null); alc.alcDestroyContext(context); alc.alcCloseDevice(device); - devicesToString(sb, alc); + devicesToString(sb, alc, enumerationExtIsPresent, enumerateAllExtIsPresent); return sb; } @@ -222,24 +243,47 @@ public class JoalVersion extends JogampVersion { } } - public static void devicesToString(final StringBuilder sb, final ALC alc) { - final String defOutDeviceName = alc.alcGetString(null, ALCConstants.ALC_DEFAULT_DEVICE_SPECIFIER); - final String defInDeviceName = alc.alcGetString(null, ALCConstants.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); - sb.append("Output devices:"+System.lineSeparator()); - { - final String[] outDevices = alc.alcGetDeviceSpecifiers(); - if( null != outDevices ) { - for (final String devName : outDevices) { - deviceToString(sb, alc, devName, false, defOutDeviceName, defInDeviceName); + public static void devicesToString(final StringBuilder sb, final ALC alc, final boolean enumerationExtIsPresent, final boolean enumerateAllExtIsPresent) { + if (!enumerationExtIsPresent && !enumerateAllExtIsPresent) { + sb.append("No output devices infos available (Missing "+ + ALCConstants.ALC_ENUMERATION_EXT_NAME+" and "+ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME+")"); + } else { + if (enumerateAllExtIsPresent) { + final String defOutAllDeviceName = alc.alcGetString(null, ALCConstants.ALC_DEFAULT_ALL_DEVICES_SPECIFIER); + sb.append("Output devices (With " + ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME + "):" + System.lineSeparator()); + { + final String[] outDevices = alc.alcGetAllDeviceSpecifiers(); + if (null != outDevices) { + for (final String devName : outDevices) { + deviceToString(sb, alc, devName, false, defOutAllDeviceName, null); + } + } + } + } + if (enumerationExtIsPresent) { + final String defOutDeviceName = alc.alcGetString(null, ALCConstants.ALC_DEFAULT_DEVICE_SPECIFIER); + sb.append("Output devices (With " + ALCConstants.ALC_ENUMERATION_EXT_NAME + "):" + System.lineSeparator()); + { + final String[] outDevices = alc.alcGetDeviceSpecifiers(); + if (null != outDevices) { + for (final String devName : outDevices) { + deviceToString(sb, alc, devName, false, defOutDeviceName, null); + } + } } } } - sb.append("Capture devices:"+System.lineSeparator()); - { - final String[] inDevices = alc.alcGetCaptureDeviceSpecifiers(); - if( null != inDevices ) { - for (final String devName : inDevices) { - deviceToString(sb, alc, devName, true, defOutDeviceName, defInDeviceName); + if (!enumerationExtIsPresent) { + sb.append("No capture devices infos available (Missing " + ALCConstants.ALC_ENUMERATION_EXT_NAME + ")"); + } else { + final String defInDeviceName = alc.alcGetString(null, ALCConstants.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); + sb.append("Capture devices:" + System.lineSeparator()); + { + final String[] inDevices = alc.alcGetCaptureDeviceSpecifiers(); + if (null != inDevices) { + for (final String devName : inDevices) { + deviceToString(sb, alc, devName, true, null, defInDeviceName); + } } } } diff --git a/src/java/jogamp/openal/ALCImpl.java b/src/java/jogamp/openal/ALCImpl.java index 99494ca..bdd0a8a 100644 --- a/src/java/jogamp/openal/ALCImpl.java +++ b/src/java/jogamp/openal/ALCImpl.java @@ -4,6 +4,7 @@ package jogamp.openal; import com.jogamp.common.nio.Buffers; +import com.jogamp.openal.ALCConstants; import com.jogamp.openal.ALException; import com.jogamp.openal.ALCdevice; import java.io.UnsupportedEncodingException; @@ -15,10 +16,23 @@ import java.util.ArrayList; * @author Michael Bien */ public class ALCImpl extends ALCAbstractImpl { + public boolean aclEnumerationExtIsPresent() { + return alcIsExtensionPresent(null, ALCConstants.ALC_ENUMERATION_EXT_NAME); + } + + public boolean aclEnumerateAllExtIsPresent() { + return alcIsExtensionPresent(null, ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME); + } + + public boolean alcIsDoubleNullTerminatedString(final ALCdevice device, final int param) { + return dispatch_alcIsDoubleNullTerminatedString(((device == null) ? null : device.getBuffer()), param); + } + + public native boolean dispatch_alcIsDoubleNullTerminatedString(ByteBuffer deviceBuffer, int param); public String alcGetString(final ALCdevice device, final int param) { - if (device == null && param == ALC_DEVICE_SPECIFIER) { - throw new ALException("Call alcGetDeviceSpecifiers to fetch all available device names"); + if (alcIsDoubleNullTerminatedString(device, param)) { + throw new ALException("Call alcGetString to get double null terminated string"); } final ByteBuffer buf = alcGetStringImpl(device, param); @@ -51,24 +65,24 @@ public class ALCImpl extends ALCAbstractImpl { } private native java.nio.ByteBuffer dispatch_alcGetStringImpl1(ByteBuffer deviceBuffer, int param, long addr); - /** - * 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); + return alcGetStringAsDoubleNullTerminatedString(null, 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); + return alcGetStringAsDoubleNullTerminatedString(null, ALC_CAPTURE_DEVICE_SPECIFIER); } - private String[] getDoubleNullTerminatedString(final int which) { - final ByteBuffer buf = alcGetStringImpl(null, which); + public String[] alcGetAllDeviceSpecifiers() { + return alcGetStringAsDoubleNullTerminatedString(null, ALC_ALL_DEVICES_SPECIFIER); + } + + public String[] alcGetStringAsDoubleNullTerminatedString(final ALCdevice device, final int param) { + if (!alcIsDoubleNullTerminatedString(device, param)) { + throw new ALException("Call alcGetString to get string"); + } + + final ByteBuffer buf = alcGetStringImpl(device, param); if (buf == null) { return null; } diff --git a/src/native/almisc.c b/src/native/almisc.c index ca638d9..06fa794 100644 --- a/src/native/almisc.c +++ b/src/native/almisc.c @@ -1,19 +1,21 @@ - #include #include #include - #include "al.h" - #include "alc.h" - #ifndef _MSC_VER /* Non-Windows platforms */ +#include "al.h" +#include "alc.h" +#ifndef _MSC_VER /* Non-Windows platforms */ #define __cdecl /* Trim non-standard keyword */ - #endif - #include "efx.h" - #include +#endif +#include "efx.h" +#include +#include extern int strlen_alc(ALCdevice *device, int param, const char* str); +extern bool alc_is_double_null_terminated_string(ALCdevice *device, int param); + /* Java->C glue code: * Java package: jogamp.openal.ALImpl * Java method: long dispatch_alGetProcAddressStatic(java.lang.String fname) @@ -61,3 +63,12 @@ Java_jogamp_openal_ALCImpl_dispatch_1alcGetStringImpl1(JNIEnv *env, jobject _unu return (*env)->NewDirectByteBuffer(env, _res, strlen_alc(_device_ptr, param, _res)); } +JNIEXPORT jboolean JNICALL +Java_jogamp_openal_ALCImpl_dispatch_1alcIsDoubleNullTerminatedString(JNIEnv *env, jobject _unused, jobject device, jint param) { + ALCdevice * _device_ptr = NULL; + const ALCchar * _res; + if ( NULL != device ) { + _device_ptr = (ALCdevice *) (((char*) (*env)->GetDirectBufferAddress(env, device)) + 0); + } + return (jboolean) alc_is_double_null_terminated_string((ALCdevice *) _device_ptr, (ALCenum) param); +} diff --git a/src/test/com/jogamp/openal/test/manual/Synth01AL.java b/src/test/com/jogamp/openal/test/manual/Synth01AL.java index 64da9fa..7bd60c8 100644 --- a/src/test/com/jogamp/openal/test/manual/Synth01AL.java +++ b/src/test/com/jogamp/openal/test/manual/Synth01AL.java @@ -101,6 +101,15 @@ public class Synth01AL { } } } + System.out.println("Output all devices:"); + { + final String[] outDevices = alc.alcGetAllDeviceSpecifiers(); + if( null != outDevices ) { + for (final String name : outDevices) { + System.out.println(" "+name); + } + } + } alCheckError("setup", true); al.alGenBuffers(1, buffers, 0); -- cgit v1.2.3 From 9ac10deb2fa4e965222fb0dcd8d3e1dd136e5944 Mon Sep 17 00:00:00 2001 From: Mathieu Féry Date: Mon, 13 Nov 2023 10:54:47 +0100 Subject: feat(version): Invoking JoalVersion no longer destroys the current context --- src/java/com/jogamp/openal/JoalVersion.java | 42 ++++++++++++++++----- .../jogamp/openal/test/junit/ALVersionTest.java | 44 ++++++++++++++++++++++ 2 files changed, 77 insertions(+), 9 deletions(-) diff --git a/src/java/com/jogamp/openal/JoalVersion.java b/src/java/com/jogamp/openal/JoalVersion.java index bca175e..4ae784b 100644 --- a/src/java/com/jogamp/openal/JoalVersion.java +++ b/src/java/com/jogamp/openal/JoalVersion.java @@ -110,9 +110,18 @@ public class JoalVersion extends JogampVersion { sb.append("ALC null"); return sb; } - final ALCdevice device = alc.alcOpenDevice(null); - final ALCcontext context = alc.alcCreateContext(device, null); - alc.alcMakeContextCurrent(context); + final ALCcontext initialContext = alc.alcGetCurrentContext(); + + final ALCcontext context; + final ALCdevice device; + if( null == initialContext) { + device = alc.alcOpenDevice(null); + context = alc.alcCreateContext(device, null); + alc.alcMakeContextCurrent(context); + } else { + context = initialContext; + device = alc.alcGetContextsDevice(initialContext); + } final AL al = ALFactory.getAL(); // valid after makeContextCurrent(..) final ALVersion alv = new ALVersion(al); @@ -151,9 +160,13 @@ public class JoalVersion extends JogampVersion { sb.append(Platform.getNewline()); } } - alc.alcMakeContextCurrent(null); - alc.alcDestroyContext(context); - alc.alcCloseDevice(device); + + if( null == initialContext ) { + alc.alcMakeContextCurrent(null); + alc.alcDestroyContext(context); + alc.alcCloseDevice(device); + } + devicesToString(sb, alc, enumerationExtIsPresent, enumerateAllExtIsPresent); return sb; } @@ -178,6 +191,8 @@ public class JoalVersion extends JogampVersion { final String inOutStr = "output"; final int mixerFrequency, mixerRefresh, monoSourceCount, stereoSourceCount; final int[] val = { 0 }; + final ALCcontext initialContext = alc.alcGetCurrentContext(); + final ALCdevice initialDevice = initialContext != null ? alc.alcGetContextsDevice(initialContext) : null; final ALCdevice d = alc.alcOpenDevice(devName); if( null == d ) { System.err.println("Error: Failed to open "+defStr+inOutStr+" device "+devName); @@ -237,9 +252,18 @@ public class JoalVersion extends JogampVersion { " (min latency "+(1000f/mixerRefresh)+" ms)], sources[mono "+monoSourceCount+", stereo "+stereoSourceCount+"]"+ System.lineSeparator()); - alc.alcMakeContextCurrent(null); - alc.alcDestroyContext(c); - alc.alcCloseDevice(d); + if( null != initialContext ) { + alc.alcMakeContextCurrent(initialContext); + if( initialContext.getDirectBufferAddress() != c.getDirectBufferAddress() ) { + alc.alcDestroyContext(c); + } + } else { + alc.alcMakeContextCurrent(null); + alc.alcDestroyContext(c); + } + if( initialDevice == null || initialDevice.getDirectBufferAddress() != d.getDirectBufferAddress() ) { + alc.alcCloseDevice(d); + } } } diff --git a/src/test/com/jogamp/openal/test/junit/ALVersionTest.java b/src/test/com/jogamp/openal/test/junit/ALVersionTest.java index cb24e95..55535ed 100644 --- a/src/test/com/jogamp/openal/test/junit/ALVersionTest.java +++ b/src/test/com/jogamp/openal/test/junit/ALVersionTest.java @@ -31,10 +31,14 @@ import java.io.IOException; import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.After; import org.junit.Assert; import org.junit.runners.MethodSorters; import com.jogamp.common.util.VersionNumber; +import com.jogamp.openal.ALC; +import com.jogamp.openal.ALCcontext; +import com.jogamp.openal.ALCdevice; import com.jogamp.openal.ALFactory; import com.jogamp.openal.ALVersion; import com.jogamp.openal.JoalVersion; @@ -70,6 +74,46 @@ public class ALVersionTest extends UITestCase { System.err.println(jv.toString(ALFactory.getALC())); } + @Test + public void test03JoalVersionMustNoChangeContextAndDeviceUsed() { + final ALC alc = ALFactory.getALC(); + final ALCdevice intialDevice = alc.alcOpenDevice(null); + final ALCcontext initialContext = alc.alcCreateContext(intialDevice, null); + alc.alcMakeContextCurrent(initialContext); + final JoalVersion jv = JoalVersion.getInstance(); + System.err.println(jv.toString(alc)); + final ALCcontext currentContext = alc.alcGetCurrentContext(); + Assert.assertNotNull(currentContext); + Assert.assertEquals(initialContext.getDirectBufferAddress(), currentContext.getDirectBufferAddress()); + final ALCdevice currentDevice = alc.alcGetContextsDevice(currentContext); + Assert.assertNotNull(currentDevice); + Assert.assertEquals(intialDevice.getDirectBufferAddress(), currentDevice.getDirectBufferAddress()); + } + + @Test + public void test04JoalVersionMustNotSetAdditionalContext() { + final ALC alc = ALFactory.getALC(); + final JoalVersion jv = JoalVersion.getInstance(); + System.err.println(jv.toString(alc)); + final ALCcontext currentContext = alc.alcGetCurrentContext(); + Assert.assertNull(currentContext); + } + + @After + @Override + public void tearDown() { + super.tearDown(); + final ALC alc = ALFactory.getALC(); + final ALCcontext context = alc.alcGetCurrentContext(); + if(null != context) { + alc.alcDestroyContext(context); + final ALCdevice device = alc.alcGetContextsDevice(context); + if(null != device) { + alc.alcCloseDevice(device); + } + } + } + public static void main(final String args[]) throws IOException { org.junit.runner.JUnitCore.main(ALVersionTest.class.getName()); } -- cgit v1.2.3 From 0fde337685aa1feda82cc29ea852518135cb9eff Mon Sep 17 00:00:00 2001 From: Mathieu Féry Date: Tue, 14 Nov 2023 09:37:58 +0100 Subject: feat(devices): Move ALC_EXT constant from ALCconstants into ALHelpers with other ALC_EXT names --- make/config/joal-alc-constants-CustomJavaCode.java | 3 --- make/config/joal-alc-constants.cfg | 2 -- src/java/com/jogamp/openal/JoalVersion.java | 17 +++++++++-------- src/java/com/jogamp/openal/util/ALHelpers.java | 3 +++ src/java/jogamp/openal/ALCImpl.java | 6 ++++-- 5 files changed, 16 insertions(+), 15 deletions(-) delete mode 100644 make/config/joal-alc-constants-CustomJavaCode.java diff --git a/make/config/joal-alc-constants-CustomJavaCode.java b/make/config/joal-alc-constants-CustomJavaCode.java deleted file mode 100644 index fe97124..0000000 --- a/make/config/joal-alc-constants-CustomJavaCode.java +++ /dev/null @@ -1,3 +0,0 @@ -public final java.lang.String ALC_ENUMERATION_EXT_NAME = "ALC_ENUMERATION_EXT"; - -public final java.lang.String ALC_ENUMERATE_ALL_EXT_NAME = "ALC_ENUMERATE_ALL_EXT"; \ No newline at end of file diff --git a/make/config/joal-alc-constants.cfg b/make/config/joal-alc-constants.cfg index b58f700..83ea061 100644 --- a/make/config/joal-alc-constants.cfg +++ b/make/config/joal-alc-constants.cfg @@ -6,5 +6,3 @@ JavaClass ALCConstants # Factor out the OpenAL constants into their own interface IgnoreNot ^ALC_.+ - -IncludeAs CustomJavaCode ALCConstants joal-alc-constants-CustomJavaCode.java diff --git a/src/java/com/jogamp/openal/JoalVersion.java b/src/java/com/jogamp/openal/JoalVersion.java index 4ae784b..6469189 100644 --- a/src/java/com/jogamp/openal/JoalVersion.java +++ b/src/java/com/jogamp/openal/JoalVersion.java @@ -33,6 +33,7 @@ import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.JogampVersion; +import com.jogamp.openal.util.ALHelpers; import java.util.jar.Manifest; @@ -138,16 +139,16 @@ public class JoalVersion extends JogampVersion { sb.append(Platform.getNewline()); if (!enumerationExtIsPresent && !enumerateAllExtIsPresent) { sb.append("ALC_DEF_OUTPUT Unknown (Missing "+ - ALCConstants.ALC_ENUMERATION_EXT_NAME+" and "+ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME+")"); + ALHelpers.ALC_ENUMERATION_EXT+" and "+ALHelpers.ALC_ENUMERATE_ALL_EXT+")"); sb.append(Platform.getNewline()); } else { if (enumerationExtIsPresent) { - sb.append("ALC_DEF_OUTPUT (With " + ALCConstants.ALC_ENUMERATION_EXT_NAME + ") ") + sb.append("ALC_DEF_OUTPUT (With " + ALHelpers.ALC_ENUMERATION_EXT + ") ") .append(alc.alcGetString(device, ALCConstants.ALC_DEFAULT_DEVICE_SPECIFIER)); sb.append(Platform.getNewline()); } if (enumerateAllExtIsPresent) { - sb.append("ALC_DEF_OUTPUT (With " + ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME + ") ") + sb.append("ALC_DEF_OUTPUT (With " + ALHelpers.ALC_ENUMERATE_ALL_EXT + ") ") .append(alc.alcGetString(device, ALCConstants.ALC_DEFAULT_ALL_DEVICES_SPECIFIER)); sb.append(Platform.getNewline()); } @@ -156,7 +157,7 @@ public class JoalVersion extends JogampVersion { sb.append("ALC_DEF_CAPTURE ").append(alc.alcGetString(device, ALCConstants.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); sb.append(Platform.getNewline()); } else { - sb.append("ALC_DEF_CAPTURE Unknown (Missing "+ALCConstants.ALC_ENUMERATION_EXT_NAME+")"); + sb.append("ALC_DEF_CAPTURE Unknown (Missing "+ALHelpers.ALC_ENUMERATION_EXT+")"); sb.append(Platform.getNewline()); } } @@ -270,11 +271,11 @@ public class JoalVersion extends JogampVersion { public static void devicesToString(final StringBuilder sb, final ALC alc, final boolean enumerationExtIsPresent, final boolean enumerateAllExtIsPresent) { if (!enumerationExtIsPresent && !enumerateAllExtIsPresent) { sb.append("No output devices infos available (Missing "+ - ALCConstants.ALC_ENUMERATION_EXT_NAME+" and "+ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME+")"); + ALHelpers.ALC_ENUMERATION_EXT+" and "+ALHelpers.ALC_ENUMERATE_ALL_EXT+")"); } else { if (enumerateAllExtIsPresent) { final String defOutAllDeviceName = alc.alcGetString(null, ALCConstants.ALC_DEFAULT_ALL_DEVICES_SPECIFIER); - sb.append("Output devices (With " + ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME + "):" + System.lineSeparator()); + sb.append("Output devices (With " + ALHelpers.ALC_ENUMERATE_ALL_EXT + "):" + System.lineSeparator()); { final String[] outDevices = alc.alcGetAllDeviceSpecifiers(); if (null != outDevices) { @@ -286,7 +287,7 @@ public class JoalVersion extends JogampVersion { } if (enumerationExtIsPresent) { final String defOutDeviceName = alc.alcGetString(null, ALCConstants.ALC_DEFAULT_DEVICE_SPECIFIER); - sb.append("Output devices (With " + ALCConstants.ALC_ENUMERATION_EXT_NAME + "):" + System.lineSeparator()); + sb.append("Output devices (With " + ALHelpers.ALC_ENUMERATION_EXT + "):" + System.lineSeparator()); { final String[] outDevices = alc.alcGetDeviceSpecifiers(); if (null != outDevices) { @@ -298,7 +299,7 @@ public class JoalVersion extends JogampVersion { } } if (!enumerationExtIsPresent) { - sb.append("No capture devices infos available (Missing " + ALCConstants.ALC_ENUMERATION_EXT_NAME + ")"); + sb.append("No capture devices infos available (Missing " + ALHelpers.ALC_ENUMERATION_EXT + ")"); } else { final String defInDeviceName = alc.alcGetString(null, ALCConstants.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); sb.append("Capture devices:" + System.lineSeparator()); diff --git a/src/java/com/jogamp/openal/util/ALHelpers.java b/src/java/com/jogamp/openal/util/ALHelpers.java index 93dfa6e..fda3167 100644 --- a/src/java/com/jogamp/openal/util/ALHelpers.java +++ b/src/java/com/jogamp/openal/util/ALHelpers.java @@ -52,6 +52,9 @@ public class ALHelpers { public static final String ALC_EXT_thread_local_context = "ALC_EXT_thread_local_context"; + public static final String ALC_ENUMERATION_EXT = "ALC_ENUMERATION_EXT"; + public static final String ALC_ENUMERATE_ALL_EXT = "ALC_ENUMERATE_ALL_EXT"; + /** * Returns a compatible {@link AudioFormat} based on given OpenAL channel-layout, sample-type and format, * as well as the generic sample-rate and sample-size. diff --git a/src/java/jogamp/openal/ALCImpl.java b/src/java/jogamp/openal/ALCImpl.java index bdd0a8a..f08541c 100644 --- a/src/java/jogamp/openal/ALCImpl.java +++ b/src/java/jogamp/openal/ALCImpl.java @@ -7,6 +7,8 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.openal.ALCConstants; import com.jogamp.openal.ALException; import com.jogamp.openal.ALCdevice; +import com.jogamp.openal.util.ALHelpers; + import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -17,11 +19,11 @@ import java.util.ArrayList; */ public class ALCImpl extends ALCAbstractImpl { public boolean aclEnumerationExtIsPresent() { - return alcIsExtensionPresent(null, ALCConstants.ALC_ENUMERATION_EXT_NAME); + return alcIsExtensionPresent(null, ALHelpers.ALC_ENUMERATION_EXT); } public boolean aclEnumerateAllExtIsPresent() { - return alcIsExtensionPresent(null, ALCConstants.ALC_ENUMERATE_ALL_EXT_NAME); + return alcIsExtensionPresent(null, ALHelpers.ALC_ENUMERATE_ALL_EXT); } public boolean alcIsDoubleNullTerminatedString(final ALCdevice device, final int param) { -- cgit v1.2.3