diff options
author | Kevin Rushforth <[email protected]> | 2004-10-29 16:17:11 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2004-10-29 16:17:11 +0000 |
commit | 36b981685cc1633e24c4622399b95428d89df002 (patch) | |
tree | 454d30b87546128028d807ac9015ac8eaef92b73 /src/classes | |
parent | f8f04314551d9a3208d2fd42a18670b5007c0a1a (diff) |
Disabled JavaSoundMixer by default for users of SimpleUniverse. Added a
"j3d.audiodevice" property to allow an audio device to be specified. See
the following URLs for more details.
http://java3d.dev.java.net/issues/show_bug.cgi?id=24
http://www.javadesktop.org/forums/thread.jspa?threadID=6102
git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@26 9497e636-51bd-65ba-982d-a4982e1767a5
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/share/com/sun/j3d/utils/universe/Viewer.java | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/universe/Viewer.java b/src/classes/share/com/sun/j3d/utils/universe/Viewer.java index d1665f6..207ce08 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/Viewer.java +++ b/src/classes/share/com/sun/j3d/utils/universe/Viewer.java @@ -51,7 +51,8 @@ import java.util.*; import javax.media.j3d.*; import javax.swing.*; import javax.vecmath.*; -import com.sun.j3d.audioengines.javasound.JavaSoundMixer; +import com.sun.j3d.audioengines.AudioEngine3DL2; +import java.lang.reflect.Constructor; import java.applet.*; /** @@ -960,15 +961,42 @@ public class Viewer { * @return reference to created AudioDevice, or null if error occurs. */ public AudioDevice createAudioDevice() { - if (physicalEnvironment != null) { - AudioDevice3DL2 mixer = new JavaSoundMixer(physicalEnvironment); - mixer.initialize(); - return mixer; - } - else + if (physicalEnvironment == null) { + System.err.println("Java 3D: createAudioDevice: physicalEnvironment is null"); return null; + } + + try { + String audioDeviceClassName = + (String) java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Object run() { + return System.getProperty("j3d.audiodevice"); + } + }); + + if (audioDeviceClassName == null) { + throw new UnsupportedOperationException("No AudioDevice specified"); + } + + Class audioDeviceClass = Class.forName(audioDeviceClassName); + Class physEnvClass = PhysicalEnvironment.class; + Constructor audioDeviceConstructor = + audioDeviceClass.getConstructor(new Class[] {physEnvClass}); + PhysicalEnvironment[] args = new PhysicalEnvironment[] { physicalEnvironment }; + AudioEngine3DL2 mixer = + (AudioEngine3DL2) audioDeviceConstructor.newInstance(args); + mixer.initialize(); + return mixer; + } + catch (Throwable e) { + e.printStackTrace(); + physicalEnvironment.setAudioDevice(null); + System.err.println("Java 3D: audio is disabled"); + return null; + } } - + /** * Returns the Universe to which this Viewer is attached * |