aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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;
+ }
}