diff options
author | Sven Gothel <[email protected]> | 2013-02-01 11:55:07 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-02-01 11:55:07 +0100 |
commit | 92e931caf64cf24e2b885d2552e64aebcf70a45a (patch) | |
tree | 22db80e2c621ed4228c835a931d9367265870cc0 /src/java/com/jogamp/openal | |
parent | 14c6e3b98b04d87abf738c5ed7bfd7746dab8e08 (diff) |
OpenAL Library Selection (Bug 662): Use String value of new property 'joal.openal.lib'. OSX: Prefer system OpenAL (nou OpenAL-Soft output device support)
+ * 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>
Diffstat (limited to 'src/java/com/jogamp/openal')
-rw-r--r-- | src/java/com/jogamp/openal/ALFactory.java | 60 |
1 files changed, 52 insertions, 8 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 |