aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-12-13 07:57:40 +0100
committerSven Gothel <[email protected]>2010-12-13 07:57:40 +0100
commitc2f6ba872805f25f968697c47962861745330d43 (patch)
tree0be6309c1a5612d856419bc025948b43cd873829 /src/test/com/jogamp
parentb0c39f3f4259cf6eca8e1f7af0f0924cf7472abe (diff)
Playing audio again
- test: use jar file joal-test.jar - test: use proper getResourceAsStream() on class instance - test: plays sound TODO: - check on windows and osx - add jnlp file template - joal-demos
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/openal/test/junit/ALTest.java5
-rw-r--r--src/test/com/jogamp/openal/test/manual/OpenALTest.java5
-rw-r--r--src/test/com/jogamp/openal/test/manual/Sound3DTest.java2
-rw-r--r--src/test/com/jogamp/openal/test/resources/ResourceLocation.java26
4 files changed, 31 insertions, 7 deletions
diff --git a/src/test/com/jogamp/openal/test/junit/ALTest.java b/src/test/com/jogamp/openal/test/junit/ALTest.java
index 6a465f2..33d7b0d 100644
--- a/src/test/com/jogamp/openal/test/junit/ALTest.java
+++ b/src/test/com/jogamp/openal/test/junit/ALTest.java
@@ -382,10 +382,7 @@ public class ALTest {
}
private WAVData loadTestWAV() throws IOException, UnsupportedAudioFileException {
- InputStream resource = ResourceLocation.class.getResourceAsStream(TEST_FILE);
- if(resource == null) {
- throw new FileNotFoundException(TEST_FILE+" not found");
- }
+ InputStream resource = ResourceLocation.getInputStream(TEST_FILE, true);
return WAVLoader.loadFromStream(resource);
}
}
diff --git a/src/test/com/jogamp/openal/test/manual/OpenALTest.java b/src/test/com/jogamp/openal/test/manual/OpenALTest.java
index 98843c7..abd335c 100644
--- a/src/test/com/jogamp/openal/test/manual/OpenALTest.java
+++ b/src/test/com/jogamp/openal/test/manual/OpenALTest.java
@@ -42,7 +42,9 @@ import java.io.IOException;
import java.nio.*;
import com.jogamp.openal.eax.*;
+import com.jogamp.openal.test.resources.ResourceLocation;
import com.jogamp.openal.util.*;
+import java.io.InputStream;
import javax.sound.sampled.UnsupportedAudioFileException;
/**
@@ -50,7 +52,6 @@ import javax.sound.sampled.UnsupportedAudioFileException;
* @author Michael Bien
*/
public class OpenALTest {
-
public static void main(String[] args) throws InterruptedException, UnsupportedAudioFileException, IOException {
ALC alc = ALFactory.getALC();
ALCdevice device = alc.alcOpenDevice(null);
@@ -76,7 +77,7 @@ public class OpenALTest {
int[] buffers = new int[1];
al.alGenBuffers(1, buffers, 0);
- WAVData wd = WAVLoader.loadFromStream(OpenALTest.class.getResourceAsStream("lewiscarroll.wav"));
+ WAVData wd = WAVLoader.loadFromStream(ResourceLocation.getTestStream0());
al.alBufferData(buffers[0], wd.format, wd.data, wd.size, wd.freq);
int[] sources = new int[1];
diff --git a/src/test/com/jogamp/openal/test/manual/Sound3DTest.java b/src/test/com/jogamp/openal/test/manual/Sound3DTest.java
index d91f0ec..55bf28a 100644
--- a/src/test/com/jogamp/openal/test/manual/Sound3DTest.java
+++ b/src/test/com/jogamp/openal/test/manual/Sound3DTest.java
@@ -63,7 +63,7 @@ public class Sound3DTest {
listener.setPosition(0, 0, 0);
// load a source and play it
- Source source1 = AudioSystem3D.loadSource(ResourceLocation.class.getResourceAsStream("lewiscarroll.wav"));
+ Source source1 = AudioSystem3D.loadSource(ResourceLocation.getTestStream0());
source1.setPosition(0, 0, 0);
source1.setLooping(true);
source1.play();
diff --git a/src/test/com/jogamp/openal/test/resources/ResourceLocation.java b/src/test/com/jogamp/openal/test/resources/ResourceLocation.java
index 74f1356..f223644 100644
--- a/src/test/com/jogamp/openal/test/resources/ResourceLocation.java
+++ b/src/test/com/jogamp/openal/test/resources/ResourceLocation.java
@@ -1,6 +1,32 @@
package com.jogamp.openal.test.resources;
+import java.io.InputStream;
+
/** just a tag to locate the resources */
public class ResourceLocation {
+ public static final String lewiscarrol_wav = "lewiscarroll.wav";
+
+ static final ResourceLocation rl;
+
+ static {
+ rl = new ResourceLocation();
+
+ }
+
+ public static InputStream getTestStream0() {
+ return getInputStream(lewiscarrol_wav, true);
+ }
+
+ public static InputStream getInputStream(String fileName) {
+ return getInputStream(fileName, false);
+ }
+
+ public static InputStream getInputStream(String fileName, boolean throwException) {
+ InputStream stream = rl.getClass().getResourceAsStream(fileName);
+ if(throwException && null == stream) {
+ throw new RuntimeException("File '"+fileName+"' not found");
+ }
+ return stream;
+ }
}