aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-08-24 17:38:32 +0200
committerSven Gothel <[email protected]>2013-08-24 17:38:32 +0200
commitdeae6def7a818d3189bec403f8cde2ad9936d416 (patch)
tree45d27f0f55fd2cda0de6a22597264af4397b83f9 /src/jogl/classes/jogamp/opengl/util
parent413762735dc54a82fbc98e6b7909543cbbd8622a (diff)
*AudioSink: Add byte/time calc to AudioDataFormat, *AudioFrame OO changes, Reuses ALAudioFrames to ease GC, Ringbuffer changes
- Adapt to Ringbuffer changes of GlueGen commit f9f881e59c78e3036cb3f956bc97cfc3197f620d - Favor AudioSink 'AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount)', - Impl. shall reuse AudioFrame's instead of creating them on the fly - User shall simply pass the net data required, while receiving an internal AudioFrame - Add byte/time calc to AudioDataFormat: - Add getDuration(byteCount) and getByteCount(ms). - *AudioFrame OO changes: - abstract AudioFrame extends TimeFrameI - allow setting of all components to reuse instanced (GC clean) - ALAudioSink reuses ALAudioFrames to ease GC: - Remove creating temporary objects to ease GC - ALAudioFrame holds ALBuffer name, remove ActiveBuffer type. - Use ALAudioFrame similar to TextureFrame in GLMediaPlayerImpl, i.e. fill them in 'full' Ringbuffer and move them in-between 'full'/'playing' Ringbuffer. -
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java28
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java10
2 files changed, 27 insertions, 11 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java
index 93be9db8d..dcf096f05 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java
@@ -1,5 +1,6 @@
package jogamp.opengl.util.av;
+import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.sound.sampled.AudioSystem;
@@ -155,23 +156,30 @@ public class JavaSoundAudioSink implements AudioSink {
// FIXEM: complete code!
}
- public void enqueueData(AudioFrame audioFrame) {
- int data_size = audioFrame.dataSize;
- final byte[] lala = new byte[data_size];
- final int p = audioFrame.data.position();
- audioFrame.data.get(lala, 0, data_size);
- audioFrame.data.position(p);
+ @Override
+ public AudioFrame enqueueData(AudioDataFrame audioDataFrame) {
+ int byteSize = audioDataFrame.getByteSize();
+ final ByteBuffer byteBuffer = audioDataFrame.getData();
+ final byte[] bytes = new byte[byteSize];
+ final int p = byteBuffer.position();
+ byteBuffer.get(bytes, 0, byteSize);
+ byteBuffer.position(p);
int written = 0;
int len;
- while (data_size > 0) {
- // Nope: We don't make compromises for this crappy API !
- len = auline.write(lala, written, data_size);
- data_size -= len;
+ while (byteSize > 0) {
+ len = auline.write(bytes, written, byteSize);
+ byteSize -= len;
written += len;
}
playImpl();
+ return audioDataFrame;
}
+
+ @Override
+ public AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount) {
+ return enqueueData(new AudioDataFrame(pts, chosenFormat.getDuration(byteCount), bytes, byteCount));
+ }
@Override
public int getQueuedByteCount() {
diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
index 609973d7a..af4b83bb6 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
@@ -1,6 +1,8 @@
package jogamp.opengl.util.av;
+import java.nio.ByteBuffer;
+
import com.jogamp.opengl.util.av.AudioSink;
public class NullAudioSink implements AudioSink {
@@ -92,6 +94,12 @@ public class NullAudioSink implements AudioSink {
}
@Override
- public void enqueueData(AudioFrame audioFrame) {
+ public AudioFrame enqueueData(AudioDataFrame audioDataFrame) {
+ return null;
+ }
+
+ @Override
+ public AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount) {
+ return null;
}
}