summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-09 23:51:03 +0200
committerSven Gothel <[email protected]>2014-06-09 23:51:03 +0200
commit2d50663d43b627b5569d8d9538a0507813ac0fc6 (patch)
treea095a242b133beb3001a7a474b37e25913f08de7 /src/jogl/classes/jogamp
parent99230cc04b6d0143088129ccc1a20d5c8799ca67 (diff)
GLMediaPlayer: Fix video stutter if using NullAudioSink
NullAudioSink shall return the last enqueued PTS in getPTS() not causing a-v delta measure based on lagging audio in player.
Diffstat (limited to 'src/jogl/classes/jogamp')
-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
3 files changed, 66 insertions, 9 deletions
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;
}
}