public interface AudioSink
Modifier and Type | Interface and Description |
---|---|
static class |
AudioSink.AudioDataFrame |
static class |
AudioSink.AudioFormat
Specifies the linear audio PCM format.
|
static class |
AudioSink.AudioFrame |
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
static AudioSink.AudioFormat |
DefaultFormat
Default
AudioSink.AudioFormat , [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed, fixedP, !planar, littleEndian]. |
static int |
DefaultFrameDuration
Default frame duration in millisecond, i.e.
|
static int |
DefaultInitialQueueSize
Initial audio queue size in milliseconds.
|
static int |
DefaultQueueGrowAmount
Audio queue grow size in milliseconds.
|
static int |
DefaultQueueLimitAudioOnly
Audio queue limit w/o video in milliseconds.
|
static int |
DefaultQueueLimitWithVideo
Audio queue limit w/ video in milliseconds.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroys this instance, i.e.
|
AudioSink.AudioFrame |
enqueueData(int pts,
ByteBuffer bytes,
int byteCount)
Enqueue
byteCount bytes of the remaining bytes of the given NIO ByteBuffer to this sink. |
void |
flush()
Flush all queued buffers, implies
pause() . |
AudioSink.AudioFormat |
getChosenFormat()
Returns the
AudioSink.AudioFormat as chosen by init(AudioFormat, float, int, int, int) ,
i.e. |
int |
getEnqueuedFrameCount() |
int |
getFrameCount()
Returns the number of allocated buffers as requested by
init(AudioFormat, float, int, int, int) . |
int |
getFreeFrameCount()
Returns the current number of frames in the sink available for writing.
|
int |
getMaxSupportedChannels()
Return the maximum number of supported channels.
|
float |
getPlaySpeed()
Returns the playback speed.
|
AudioSink.AudioFormat |
getPreferredFormat()
Returns the preferred
AudioSink.AudioFormat by this sink. |
int |
getPTS()
Return the current audio presentation timestamp (PTS) in milliseconds.
|
int |
getQueuedByteCount()
Returns the current number of bytes queued for playing.
|
int |
getQueuedFrameCount()
Returns the current number of frames queued for playing.
|
int |
getQueuedTime()
Returns the current queued frame time in milliseconds for playing.
|
float |
getVolume()
Returns the volume.
|
boolean |
init(AudioSink.AudioFormat requestedFormat,
float frameDuration,
int initialQueueSize,
int queueGrowAmount,
int queueLimit)
Initializes the sink.
|
boolean |
isInitialized()
Returns the
initialized state of this instance. |
boolean |
isPlaying()
Returns true, if
play() has been requested and the sink is still playing,
otherwise false. |
boolean |
isSupported(AudioSink.AudioFormat format)
Returns true if the given format is supported by the sink, otherwise false.
|
void |
pause()
Pause playing buffers while keeping enqueued data incl.
|
void |
play()
Play buffers queued via
#enqueueData(AudioFrame) from current internal position. |
boolean |
setPlaySpeed(float s)
Sets the playback speed.
|
boolean |
setVolume(float v)
Sets the volume [0f..1f].
|
static final boolean DEBUG
static final int DefaultFrameDuration
static final int DefaultInitialQueueSize
init(AudioFormat, float, int, int, int)
.static final int DefaultQueueGrowAmount
init(AudioFormat, float, int, int, int)
.static final int DefaultQueueLimitWithVideo
init(AudioFormat, float, int, int, int)
.static final int DefaultQueueLimitAudioOnly
init(AudioFormat, float, int, int, int)
.static final AudioSink.AudioFormat DefaultFormat
AudioSink.AudioFormat
, [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed, fixedP, !planar, littleEndian].boolean isInitialized()
initialized state
of this instance.
The initialized state
is affected by this instance
overall availability, i.e. after instantiation,
as well as by destroy()
.
float getPlaySpeed()
boolean setPlaySpeed(float s)
To simplify test, play speed is normalized, i.e.
1.0f
: if Math.abs(1.0f - rate) < 0.01f
float getVolume()
boolean setVolume(float v)
To simplify test, volume is normalized, i.e.
0.0f
: if Math.abs(v) < 0.01f
1.0f
: if Math.abs(1.0f - v) < 0.01f
AudioSink.AudioFormat getPreferredFormat()
AudioSink.AudioFormat
by this sink.
The preferred format is guaranteed to be supported and shall reflect this sinks most native format, i.e. best performance w/o data conversion.
Known #AudioFormat
attributes considered by implementations:
AudioSink.AudioFormat.sampleRate
.
#initSink(AudioFormat)
,
isSupported(AudioFormat)
int getMaxSupportedChannels()
boolean isSupported(AudioSink.AudioFormat format)
#initSink(AudioFormat)
,
getPreferredFormat()
boolean init(AudioSink.AudioFormat requestedFormat, float frameDuration, int initialQueueSize, int queueGrowAmount, int queueLimit)
Implementation must match the given requestedFormat
AudioSink.AudioFormat
.
Caller shall validate requestedFormat
via isSupported(AudioFormat)
beforehand and try to find a suitable supported one.
getPreferredFormat()
and getMaxSupportedChannels()
may help.
requestedFormat
- the requested AudioSink.AudioFormat
.frameDuration
- average or fixed frame duration in milliseconds
helping a caching AudioSink.AudioFrame
based implementation to determine the frame count in the queue.
See DefaultFrameDuration
.initialQueueSize
- initial time in milliseconds to queue in this sink, see DefaultInitialQueueSize
.queueGrowAmount
- time in milliseconds to grow queue if full, see DefaultQueueGrowAmount
.queueLimit
- maximum time in milliseconds the queue can hold (and grow), see DefaultQueueLimitWithVideo
and DefaultQueueLimitAudioOnly
.AudioSink.AudioFormat getChosenFormat()
AudioSink.AudioFormat
as chosen by init(AudioFormat, float, int, int, int)
,
i.e. it shall match the requestedFormat.boolean isPlaying()
play()
has been requested and the sink is still playing,
otherwise false.void play()
#enqueueData(AudioFrame)
from current internal position.
If no buffers are yet queued or the queue runs empty, playback is being continued when buffers are enqueued later on.#enqueueData(AudioFrame)
,
pause()
void pause()
void flush()
pause()
.
init(AudioFormat, float, int, int, int)
must be called first.
void destroy()
int getFrameCount()
init(AudioFormat, float, int, int, int)
.int getEnqueuedFrameCount()
init(AudioFormat, float, int, int, int)
.int getQueuedFrameCount()
init(AudioFormat, float, int, int, int)
must be called first.
int getQueuedByteCount()
init(AudioFormat, float, int, int, int)
must be called first.
int getQueuedTime()
init(AudioFormat, float, int, int, int)
must be called first.
int getPTS()
int getFreeFrameCount()
init(AudioFormat, float, int, int, int)
must be called first.
AudioSink.AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount)
byteCount
bytes of the remaining bytes of the given NIO ByteBuffer
to this sink.
The data must comply with the chosen AudioSink.AudioFormat
as returned by #initSink(AudioFormat)
.
init(AudioFormat, float, int, int, int)
must be called first.
Copyright 2010 JogAmp Community.