summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/java/com/jogamp/openal/ALFactory.java60
-rw-r--r--src/java/jogamp/openal/ALDynamicLibraryBundleInfo.java56
2 files changed, 80 insertions, 36 deletions
diff --git a/src/java/com/jogamp/openal/ALFactory.java b/src/java/com/jogamp/openal/ALFactory.java
index f442f00..08d0a48 100644
--- a/src/java/com/jogamp/openal/ALFactory.java
+++ b/src/java/com/jogamp/openal/ALFactory.java
@@ -33,21 +33,56 @@
package com.jogamp.openal;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import jogamp.openal.ALCImpl;
+import jogamp.openal.ALExtImpl;
+import jogamp.openal.ALImpl;
+import jogamp.openal.Debug;
+
import com.jogamp.common.os.Platform;
-import com.jogamp.openal.AL;
-import com.jogamp.openal.ALC;
-import com.jogamp.openal.ALExt;
-import jogamp.openal.*;
/**
* This class provides factory methods for generating AL and ALC objects.
*
- * @author Athomas Goldberg
- * @author Kenneth Russell
+ * <p>
+ * Select preferred OpenAL native library type via system properties,
+ * i.e. System-OpenAL or bundled Soft-OpenAL.<br/>
+ * If the preferred choice fails, implementation falls back to the other.
+ * <PRE>
+ -Djoal.openal.lib=auto Prefer System-OpenAL over bundled Soft-OpenAL for OSX. Prefer bundled Soft-OpenAL over System-OpenAL for all others. This is the default.
+ -Djoal.openal.lib=system Prefer System-OpenAL over bundled Soft-OpenAL for all.
+ -Djoal.openal.lib=soft Prefer bundled Soft-OpenAL over System-OpenAL for all.
+ </PRE>
+ * Note: You may use the 'jnlp.' prefix, allowing using above property names w/ Applets and WebStart,
+ * e.g. 'jnlp.joal.openal.lib=system'.
+ * </p>
+ *
+ * @author Athomas Goldberg, Kenneth Russell, et.al.
*/
public class ALFactory {
public static final boolean DEBUG = Debug.debug("Factory");
-
+ /** If true, prefer System-OpenAL over bundled Soft-OpenAL, otherwise vice versa. */
+ public static final boolean PREFER_SYSTEM_OPENAL;
+
+ static {
+ Platform.initSingleton();
+ final String choice= AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return Debug.getProperty("joal.openal.lib", true, null);
+ } });
+ boolean useSystem = Platform.OSType.MACOS == Platform.OS_TYPE; // default
+ if( null != choice ) {
+ if( choice.equals("system") ) {
+ useSystem = true;
+ } else if( choice.equals("soft") ) {
+ useSystem = false;
+ }
+ }
+ PREFER_SYSTEM_OPENAL = useSystem;
+ }
+
private static boolean initialized = false;
private static AL al;
private static ALC alc;
@@ -58,7 +93,6 @@ public class ALFactory {
private static synchronized void initialize() throws ALException {
try {
if (!initialized) {
- Platform.initSingleton();
if(null == ALImpl.getALProcAddressTable()) {
throw new ALException("AL not initialized (ProcAddressTable null)");
}
@@ -71,6 +105,16 @@ public class ALFactory {
throw new ALException(e);
}
}
+
+ /**
+ * If the system property <code>joal.SystemOpenAL</code> is set
+ * @return
+ * @throws ALException
+ */
+ public static boolean getPreferSystemOpenAL() throws ALException {
+ initialize();
+ return PREFER_SYSTEM_OPENAL;
+ }
/**
* Get the default AL object. This object is used to access most of the
diff --git a/src/java/jogamp/openal/ALDynamicLibraryBundleInfo.java b/src/java/jogamp/openal/ALDynamicLibraryBundleInfo.java
index 55f6ed7..6ba81f0 100644
--- a/src/java/jogamp/openal/ALDynamicLibraryBundleInfo.java
+++ b/src/java/jogamp/openal/ALDynamicLibraryBundleInfo.java
@@ -34,6 +34,7 @@ import com.jogamp.common.os.DynamicLibraryBundleInfo;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.RunnableExecutor;
import com.jogamp.common.util.cache.TempJarCache;
+import com.jogamp.openal.ALFactory;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -78,40 +79,39 @@ public class ALDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
public List<List<String>> getToolLibNames() {
List<List<String>> libNamesList = new ArrayList<List<String>>();
- List<String> alLibNames = new ArrayList<String>();
-
- if(Debug.isPropertyDefined("joal.SystemOpenAL", true)) {
- // First test the System OpenAL
+ final List<String> alSystemLibNames = new ArrayList<String>();
+ {
// this is the default AL lib name, according to the spec
- alLibNames.add("libopenal.so.1"); // unix
- alLibNames.add("OpenAL32"); // windows
- alLibNames.add("OpenAL"); // OSX
-
+ alSystemLibNames.add("libopenal.so.1"); // unix
+ alSystemLibNames.add("OpenAL32"); // windows
+ alSystemLibNames.add("OpenAL"); // OSX
+
// try this one as well, if spec fails
- alLibNames.add("libOpenAL.so.1");
- alLibNames.add("libopenal.so");
- alLibNames.add("libOpenAL.so");
-
- // last but not least .. the generic one
+ alSystemLibNames.add("libOpenAL.so.1");
+ alSystemLibNames.add("libopenal.so");
+ alSystemLibNames.add("libOpenAL.so");
+ }
+ final List<String> alSoftLibNames = new ArrayList<String>();
+ {
// These names are in use by the bundled OpenAL-soft
- alLibNames.add("openal");
- alLibNames.add("OpenAL");
+ alSoftLibNames.add("openal");
+ alSoftLibNames.add("OpenAL");
+ }
+
+ final List<String> alLibNames = new ArrayList<String>();
+
+ if( ALFactory.PREFER_SYSTEM_OPENAL ) {
+ // First test the System OpenAL
+ alLibNames.addAll(alSystemLibNames);
+
+ // last but not least .. bundled OpenAL-soft
+ alLibNames.addAll(alSoftLibNames);
} else {
// First test use of the bundled OpenAL-soft
- // the generic one
- alLibNames.add("openal");
- alLibNames.add("OpenAL");
-
+ alLibNames.addAll(alSoftLibNames);
+
// Then try the System OpenAL
- // this is the default AL lib name, according to the spec
- alLibNames.add("libopenal.so.1"); // unix
- alLibNames.add("OpenAL32"); // windows
- alLibNames.add("OpenAL"); // OSX
-
- // try this one as well, if spec fails
- alLibNames.add("libOpenAL.so.1");
- alLibNames.add("libopenal.so");
- alLibNames.add("libOpenAL.so");
+ alLibNames.addAll(alSystemLibNames);
}
// last but not least .. the generic one