aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java63
4 files changed, 72 insertions, 9 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java
index f4ea29084..1d835dd33 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java
@@ -335,6 +335,12 @@ public interface AudioSink {
int initialQueueSize, int queueGrowAmount, int queueLimit);
/**
+ * Returns the {@link AudioFormat} as chosen by {@link #init(AudioFormat, float, int, int, int)},
+ * i.e. it shall match the <i>requestedFormat</i>.
+ */
+ public AudioFormat getChosenFormat();
+
+ /**
* Returns true, if {@link #play()} has been requested <i>and</i> the sink is still playing,
* otherwise false.
*/
diff --git a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java
index eeaaa5872..da6c8fde7 100644
--- a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java
+++ b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java
@@ -396,6 +396,11 @@ public class ALAudioSink implements AudioSink {
return true;
}
+ @Override
+ public final AudioFormat getChosenFormat() {
+ return chosenFormat;
+ }
+
private static int[] concat(int[] first, int[] second) {
final int[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
diff --git a/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java
index 6e006d9c0..f5b2dd8ea 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java
@@ -31,7 +31,7 @@ public class JavaSoundAudioSink implements AudioSink {
private DataLine.Info info;
private SourceDataLine auline;
private int bufferCount;
- private byte [] sampleData = new byte[BUFFER_SIZE];
+ private final byte [] sampleData = new byte[BUFFER_SIZE];
private boolean initialized = false;
private AudioSink.AudioFormat chosenFormat = null;
@@ -119,6 +119,11 @@ public class JavaSoundAudioSink implements AudioSink {
}
@Override
+ public final AudioFormat getChosenFormat() {
+ return chosenFormat;
+ }
+
+ @Override
public boolean isPlaying() {
return playRequested && auline.isRunning();
}
diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
index 8d3dbdf44..a68adb3a4 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
@@ -1,21 +1,56 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
package jogamp.opengl.util.av;
-
import java.nio.ByteBuffer;
import com.jogamp.opengl.util.av.AudioSink;
public class NullAudioSink implements AudioSink {
- @Override
- public boolean isInitialized() {
- return true;
- }
-
private volatile float playSpeed = 1.0f;
private volatile boolean playRequested = false;
+ private volatile int playingPTS = AudioFrame.INVALID_PTS;
private float volume = 1.0f;
+ private AudioFormat chosenFormat;
+ private boolean initialized;
+
+ public NullAudioSink() {
+ initialized = true;
+ chosenFormat = null;
+ }
+
+ @Override
+ public boolean isInitialized() {
+ return initialized;
+ }
+
@Override
public final float getPlaySpeed() { return playSpeed; }
@@ -58,10 +93,16 @@ public class NullAudioSink implements AudioSink {
@Override
public boolean init(AudioFormat requestedFormat, float frameDuration, int initialQueueSize, int queueGrowAmount, int queueLimit) {
+ chosenFormat = requestedFormat;
return true;
}
@Override
+ public final AudioFormat getChosenFormat() {
+ return chosenFormat;
+ }
+
+ @Override
public boolean isPlaying() {
return playRequested;
}
@@ -82,6 +123,8 @@ public class NullAudioSink implements AudioSink {
@Override
public void destroy() {
+ initialized = false;
+ chosenFormat = null;
}
@Override
@@ -110,7 +153,7 @@ public class NullAudioSink implements AudioSink {
}
@Override
- public final int getPTS() { return 0; }
+ public final int getPTS() { return playingPTS; }
@Override
public int getFreeFrameCount() {
@@ -119,11 +162,15 @@ public class NullAudioSink implements AudioSink {
@Override
public AudioFrame enqueueData(AudioDataFrame audioDataFrame) {
- return null;
+ return enqueueData(audioDataFrame.getPTS(), audioDataFrame.getData(), audioDataFrame.getByteSize());
}
@Override
public AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount) {
+ if( !initialized || null == chosenFormat ) {
+ return null;
+ }
+ playingPTS = pts;
return null;
}
}