diff options
author | Sven Gothel <[email protected]> | 2023-05-21 16:44:17 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-05-21 16:44:17 +0200 |
commit | 742cf0cd053f968cbf291ed367d4568c12d8bde2 (patch) | |
tree | 6036ad8cdabf04ebf90988eb81a466c39d6b7d9c /src/java/com/jogamp/common/av/AudioSink.java | |
parent | 5c33470aea6b30c81681992567d7c92e100bdab3 (diff) |
AudioFormat/AudioSink: Use float in seconds for duration to avoid losing precision when dealing with stats, averages etc
Diffstat (limited to 'src/java/com/jogamp/common/av/AudioSink.java')
-rw-r--r-- | src/java/com/jogamp/common/av/AudioSink.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/java/com/jogamp/common/av/AudioSink.java b/src/java/com/jogamp/common/av/AudioSink.java index 704c2a6..b4738b3 100644 --- a/src/java/com/jogamp/common/av/AudioSink.java +++ b/src/java/com/jogamp/common/av/AudioSink.java @@ -65,9 +65,18 @@ public interface AudioSink { public static abstract class AudioFrame extends TimeFrameI { protected int byteSize; + /** + * Ctor w/ zero duration, {@link #INVALID_PTS} and zero byte size + */ public AudioFrame() { this.byteSize = 0; } + /** + * Create a new instance + * @param pts frame pts in milliseconds + * @param duration frame duration in milliseconds + * @param byteCount size in bytes + */ public AudioFrame(final int pts, final int duration, final int byteCount) { super(pts, duration); this.byteSize=byteCount; @@ -89,6 +98,13 @@ public interface AudioSink { public static class AudioDataFrame extends AudioFrame { protected final ByteBuffer data; + /** + * Create a new instance + * @param pts frame pts in milliseconds + * @param duration frame duration in milliseconds + * @param bytes audio data + * @param byteCount size in bytes + */ public AudioDataFrame(final int pts, final int duration, final ByteBuffer bytes, final int byteCount) { super(pts, duration, byteCount); if( byteCount > bytes.remaining() ) { @@ -343,13 +359,13 @@ public interface AudioSink { public int getQueuedByteCount(); /** - * Returns the current queued frame time in milliseconds for playing. + * Returns the current queued frame time in seconds for playing. * <p> * {@link #init(AudioFormat, float, int, int, int)} must be called first. * </p> * @see #init(AudioFormat, float, int, int, int) */ - public int getQueuedTime(); + public float getQueuedTime(); /** * Returns average frame duration last assessed @ {@link #enqueueData(int, ByteBuffer, int)} when queue was full. @@ -357,7 +373,7 @@ public interface AudioSink { * avgFrameDuration = {@link #getQueuedTime()} / {@link #getQueuedFrameCount()} * </pre> */ - public int getAvgFrameDuration(); + public float getAvgFrameDuration(); /** * Return the current audio presentation timestamp (PTS) in milliseconds. @@ -381,7 +397,7 @@ public interface AudioSink { * <p> * {@link #init(AudioFormat, float, int, int, int)} must be called first. * </p> - * @param pts presentation time stamp for the newly enqueued {@link AudioFrame} + * @param pts presentation time stamp in milliseconds for the newly enqueued {@link AudioFrame} * @param bytes audio data for the newly enqueued {@link AudioFrame} * @returns the enqueued internal {@link AudioFrame}. * @see #init(AudioFormat, float, int, int, int) |