28package com.jogamp.common.av;
30import java.nio.ByteBuffer;
32import jogamp.common.Debug;
35 public static final boolean DEBUG = Debug.debug(
"AudioSink");
47 true ,
false ,
true );
78 this.byteSize=byteCount;
84 public final void setByteSize(
final int size) { this.byteSize=size; }
95 protected final ByteBuffer
data;
106 if( byteCount > bytes.remaining() ) {
107 throw new IllegalArgumentException(
"Give size "+byteCount+
" exceeds remaining bytes in ls "+bytes+
". "+
this);
152 public boolean release(
final boolean throwException);
303 public boolean init(
AudioFormat requestedFormat,
int frameDurationHint,
int queueSize);
Audio data frame example of AudioFrame with actual audio data being attached.
final ByteBuffer getData()
Get this frame's data.
AudioDataFrame(final int pts, final int duration, final ByteBuffer bytes, final int byteCount)
Create a new instance.
Abstract audio frame containing multiple audio samples per channel, tracking TimeFrameI pts and size ...
final int getByteSize()
Get this frame's size in bytes.
AudioFrame(final int pts, final int duration, final int byteCount)
Create a new instance.
AudioFrame()
Ctor w/ zero duration, INVALID_PTS and zero byte size.
final void setByteSize(final int size)
Set this frame's size in bytes.
Presentation Timestamp (PTS) with added System Clock Reference (SCR) via set(long,...
Integer time frame in milliseconds, maybe specialized for texture/video, audio, .
static final int DefaultQueueSizeWithVideo
Audio queue size w/ video in milliseconds.
AudioFormat getChosenFormat()
Returns the AudioFormat as chosen by init(AudioFormat, float, int), i.e.
AudioFormat getNativeFormat()
Returns the native AudioFormat by this sink.
static final AudioFormat DefaultFormat
Default AudioFormat, [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed,...
AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount)
Enqueue byteCount bytes as a new AudioFrame to this sink.
float getDefaultLatency()
Returns the default (minimum) latency in seconds.
float getVolume()
Returns the volume.
boolean isPlaying()
Returns true, if play() has been requested and the sink is still playing, otherwise false.
int getQueuedByteCount()
Returns the current number of bytes queued for playing.
void destroy()
Destroys this instance, i.e.
void flush()
Flush all queued buffers, implies pause().
boolean setVolume(float v)
Sets the volume [0f..1f].
boolean makeCurrent(final boolean throwException)
Makes the audio context current on the calling thread, if implementation utilizes context locking.
int getSourceCount()
Returns the number of sources the used device is capable to mix.
float getPlaySpeed()
Returns the playback speed.
static final int DefaultFrameDuration
Default frame duration in millisecond, i.e.
static final int DefaultQueueSize
Initial audio queue size in milliseconds.
int getFreeFrameCount()
Returns the current number of frames in the sink available for writing.
int getFrameCount()
Returns the number of allocated buffers as requested by init(AudioFormat, float, int).
PTS updateQueue()
Update queue beyond enqueueData(int, ByteBuffer, int) including audio PTS.
void pause()
Pause playing buffers while keeping enqueued data incl.
PTS getPTS()
Return the audio presentation timestamp (PTS).
AudioFormat getPreferredFormat()
Returns the preferred AudioFormat by this sink.
boolean setPlaySpeed(float s)
Sets the playback speed.
float getLatency()
Returns the (minimum) latency in seconds of this sink as set by init(AudioFormat, float,...
float getAvgFrameDuration()
Returns average frame duration last assessed @ enqueueData(int, ByteBuffer, int) when queue was full.
void setChannelLimit(final int cc)
Limit maximum supported audio channels by user.
float getQueuedDuration()
Returns the current queued frame time in seconds for playing.
boolean init(AudioFormat requestedFormat, int frameDurationHint, int queueSize)
Initializes the sink.
void play()
Play buffers queued via enqueueData(AudioFrame) from current internal position.
boolean isAvailable()
Returns the available state of this instance.
int getQueuedFrameCount()
Returns the current number of frames queued for playing.
int getEnqueuedFrameCount()
Returns the current enqueued frames count since init(AudioFormat, float, int).
boolean release(final boolean throwException)
Releases control of this audio context from the current thread, if implementation utilizes context lo...
static final boolean DEBUG
boolean isSupported(AudioFormat format)
Returns true if the given format is supported by the sink, otherwise false.
int getLastBufferedPTS()
Return the last buffered audio presentation timestamp (PTS) in milliseconds.