From 517371b2c200783890e2f6a173748cf65d3c8c91 Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * Note:
+ * Note: To retrieve the byte size for all channels, you need to pre-multiply
+ * ( 1000f * sampleCount ) / sampleRate
+ *
+ * @param sampleCount sample count per frame and channel
+ */
+ public final float getSamplesDuration(int sampleCount) {
+ return ( 1000f * (float) sampleCount ) / (float)sampleRate;
+ }
+
+ /**
+ * Returns the rounded frame count of the given milliseconds and frame duration.
+ *
+ * Math.max( 1, millisecs / frameDuration + 0.5f )
+ *
+ * frameDuration
can be derived by sample count per frame and channel
+ * via {@link #getSamplesDuration(int)}.
+ *
+ * sampleCount * ( sampleSize / 8 )
+ *
+ * sampleCount
+ * with {@link #channelCount}.
+ *
requestedFormat
and this sinks capabilities, otherwise null
.
+ * @param frameDuration average or fixed frame duration in milliseconds
+ * helping a caching {@link AudioFrame} based implementation to determine the frame count in the queue.
+ * See {@link #DefaultFrameDuration}.
+ * @param initialQueueSize initial time in milliseconds to queue in this sink, see {@link #DefaultInitialQueueSize}.
+ * @param queueGrowAmount time in milliseconds to grow queue if full, see {@link #DefaultQueueGrowAmount}.
+ * @param queueLimit maximum time in milliseconds the queue can hold (and grow), see {@link #DefaultQueueLimitWithVideo} and {@link #DefaultQueueLimitAudioOnly}.
+ * @return if successful the chosen AudioDataFormat based on the requestedFormat
and this sinks capabilities, otherwise null
.
*/
- public AudioDataFormat initSink(AudioDataFormat requestedFormat, int initialFrameCount, int frameGrowAmount, int frameLimit);
+ public AudioDataFormat init(AudioDataFormat requestedFormat, float frameDuration,
+ int initialQueueSize, int queueGrowAmount, int queueLimit);
/**
* Returns true, if {@link #play()} has been requested and the sink is still playing,
@@ -207,7 +267,7 @@ public interface AudioSink {
/**
* Flush all queued buffers, implies {@link #pause()}.
* - * {@link #initSink(AudioDataFormat, int, int, int)} must be called first. + * {@link #init(AudioDataFormat, float, int, int, int)} must be called first. *
* @see #play() * @see #pause() @@ -220,17 +280,17 @@ public interface AudioSink { /** * Returns the number of allocated buffers as requested by - * {@link #initSink(AudioDataFormat, int, int, int)}. + * {@link #init(AudioDataFormat, float, int, int, int)}. */ public int getFrameCount(); - /** @return the current enqueued frames count since {@link #initSink(AudioDataFormat, int, int, int)}. */ + /** @return the current enqueued frames count since {@link #init(AudioDataFormat, float, int, int, int)}. */ public int getEnqueuedFrameCount(); /** * Returns the current number of frames queued for playing. *- * {@link #initSink(AudioDataFormat, int, int, int)} must be called first. + * {@link #init(AudioDataFormat, float, int, int, int)} must be called first. *
*/ public int getQueuedFrameCount(); @@ -238,7 +298,7 @@ public interface AudioSink { /** * Returns the current number of bytes queued for playing. *- * {@link #initSink(AudioDataFormat, int, int, int)} must be called first. + * {@link #init(AudioDataFormat, float, int, int, int)} must be called first. *
*/ public int getQueuedByteCount(); @@ -246,7 +306,7 @@ public interface AudioSink { /** * Returns the current queued frame time in milliseconds for playing. *- * {@link #initSink(AudioDataFormat, int, int, int)} must be called first. + * {@link #init(AudioDataFormat, float, int, int, int)} must be called first. *
*/ public int getQueuedTime(); @@ -259,7 +319,7 @@ public interface AudioSink { /** * Returns the current number of frames in the sink available for writing. *- * {@link #initSink(AudioDataFormat, int, int, int)} must be called first. + * {@link #init(AudioDataFormat, float, int, int, int)} must be called first. *
*/ public int getFreeFrameCount(); @@ -270,7 +330,7 @@ public interface AudioSink { * The data must comply with the chosen {@link AudioDataFormat} as returned by {@link #initSink(AudioDataFormat)}. * *- * {@link #initSink(AudioDataFormat, int, int, int)} must be called first. + * {@link #init(AudioDataFormat, float, int, int, int)} must be called first. *
* @returns the enqueued internal {@link AudioFrame}, which may differ from the inputaudioDataFrame
.
* @deprecated User shall use {@link #enqueueData(int, ByteBuffer, int)}, which allows implementation
@@ -284,7 +344,7 @@ public interface AudioSink {
* The data must comply with the chosen {@link AudioDataFormat} as returned by {@link #initSink(AudioDataFormat)}.
*
* - * {@link #initSink(AudioDataFormat, int, int, int)} must be called first. + * {@link #init(AudioDataFormat, float, int, int, int)} must be called first. *
* @returns the enqueued internal {@link AudioFrame}. */ -- cgit v1.2.3