From 5c33470aea6b30c81681992567d7c92e100bdab3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 21 May 2023 13:05:29 +0200 Subject: AudioSink: Add getAvgFrameDuration(); API-Doc: Default*: 'frame' -> AudioFrame; init(): Use getAvgFrameDuration() for queue growth and limit. This change renders buffer dequeueing, growth and limit sticking w/ [ms] values while getAvgFrameDuration() assists frame count determination. getAvgFrameDuration() is calculated when buffer is fully filled (queuedBytes / queuedFrames), i.e. a proper representation to be used to dequeue in duration range as well as for growth. This further decouples the frameDuration{->Hint} parameter in init(), as it is now only used for the initial buffer count (and latency adjustment). --- src/java/com/jogamp/common/av/AudioFormat.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/java/com/jogamp/common/av/AudioFormat.java') diff --git a/src/java/com/jogamp/common/av/AudioFormat.java b/src/java/com/jogamp/common/av/AudioFormat.java index 8102034..870ccd2 100644 --- a/src/java/com/jogamp/common/av/AudioFormat.java +++ b/src/java/com/jogamp/common/av/AudioFormat.java @@ -124,13 +124,15 @@ public class AudioFormat { * *

* Note: frameDuration can be derived by sample count per frame and channel - * via {@link #getSamplesDuration(int)}. + * via {@link #getSamplesDuration(int)} or by byte count via {@link #getBytesDuration(int)}. *

*

* Frame Time -> Frame Count *

* @param millisecs time in milliseconds * @param frameDuration duration per frame in milliseconds. + * @see #getSamplesDuration(int) + * @see #getBytesDuration(int) */ public final int getFrameCount(final int millisecs, final int frameDuration) { return Math.max(1, (int) ( (float)millisecs / (float)frameDuration + 0.5f )); -- cgit v1.2.3