summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmake/joal.cfg14
-rw-r--r--src/java/net/java/games/sound3d/AudioSystem3D.java58
2 files changed, 56 insertions, 16 deletions
diff --git a/make/joal.cfg b/make/joal.cfg
index 3bc9350..9c1901a 100755
--- a/make/joal.cfg
+++ b/make/joal.cfg
@@ -19,21 +19,11 @@ Import com.sun.gluegen.runtime.*
# Factor out the OpenAL constants into their own interface
Ignore ^AL_.+
-# alGetProcAddress is broken for core OpenAL routines at least up
-# through OpenAL 1.1, so we have to implement our own dlsym()
-# operation in order to populate the ALProcAddressTable and
-# ALCProcAddressTable. If / when it is fixed and we don't need
-# compatibility with preexisting OpenAL 1.0 and 1.1 installations we
-# can enable the code below, except presumably for the bootstrapping
-# routines alcOpenDevice, alcCreateContext, alcMakeContextCurrent, and
-# alGetProcAddress itself.
-Ignore alGetProcAddress
-
# This routine is not exposed in the public API
-# AccessControl alGetProcAddress PACKAGE_PRIVATE
+AccessControl alGetProcAddress PACKAGE_PRIVATE
# We also have to hack its return type for now because we can't make
# just that void* opaque
-# Opaque long ALproc
+Opaque long ALproc
# This routine doesn't seem to exist
Ignore alHint
diff --git a/src/java/net/java/games/sound3d/AudioSystem3D.java b/src/java/net/java/games/sound3d/AudioSystem3D.java
index ea1affa..91fd45a 100644
--- a/src/java/net/java/games/sound3d/AudioSystem3D.java
+++ b/src/java/net/java/games/sound3d/AudioSystem3D.java
@@ -37,7 +37,7 @@ import net.java.games.joal.*;
import net.java.games.joal.util.WAVData;
import net.java.games.joal.util.WAVLoader;
-import java.io.IOException;
+import java.io.*;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -137,7 +137,7 @@ public class AudioSystem3D {
*
* @throws IOException If the file cannot be found or some other IO error
* occurs.
- * @throws UnsupportedAudioFileException If the format of the sudio data is
+ * @throws UnsupportedAudioFileException If the format of the audio data is
* not supported
*/
public static Buffer loadBuffer(String filename)
@@ -153,8 +153,37 @@ public class AudioSystem3D {
}
/**
+ * Loads a Sound3D buffer with the specified audio file.
+ *
+ * @param stream contains the stream associated with the audio file.
+ *
+ * @return a new Sound3D buffer containing the audio data from the
+ * passed stream.
+ *
+ * @throws IOException If the stream cannot be read or some other IO error
+ * occurs.
+ * @throws UnsupportedAudioFileException If the format of the audio data is
+ * not supported
+ */
+ public static Buffer loadBuffer(InputStream stream)
+ throws IOException, UnsupportedAudioFileException {
+ Buffer result;
+ Buffer[] tmp = generateBuffers(1);
+ result = tmp[0];
+
+ if (!(stream instanceof BufferedInputStream)) {
+ stream = new BufferedInputStream(stream);
+ }
+ WAVData wd = WAVLoader.loadFromStream(stream);
+
+ result.configure(wd.data, wd.format, wd.freq);
+
+ return result;
+ }
+
+ /**
* Loads a Sound3D Source with the specified audio file. This is
- * functionally equivelant to generateSource(loadBuffer(fileName));
+ * functionally equivalent to generateSource(loadBuffer(fileName));
*
* @param filename the name of the file to load.
*
@@ -163,7 +192,7 @@ public class AudioSystem3D {
*
* @throws IOException If the file cannot be found or some other IO error
* occurs.
- * @throws UnsupportedAudioFileException If the format of the sudio data is
+ * @throws UnsupportedAudioFileException If the format of the audio data is
* not supported
*/
public static Source loadSource(String filename)
@@ -174,6 +203,27 @@ public class AudioSystem3D {
}
/**
+ * Loads a Sound3D Source with the specified audio stream. This is
+ * functionally equivalent to generateSource(loadBuffer(stream));
+ *
+ * @param stream contains the stream associated with the audio file.
+ *
+ * @return a new Sound3D Source containing the audio data from the
+ * passed stream.
+ *
+ * @throws IOException If the file cannot be found or some other IO error
+ * occurs.
+ * @throws UnsupportedAudioFileException If the format of the audio data is
+ * not supported
+ */
+ public static Source loadSource(InputStream stream)
+ throws IOException, UnsupportedAudioFileException {
+ Buffer buffer = loadBuffer(stream);
+
+ return generateSource(buffer);
+ }
+
+ /**
* Generates a set of uninitialized Source3D sources
*
* @param numSources the number of Sound3D sources to generate.