CapturingAudioSink
@UnstableApi
class CapturingAudioSink : ForwardingAudioSink, Dumper.Dumpable
| kotlin.Any | ||
| ↳ | androidx.media3.exoplayer.audio.ForwardingAudioSink | |
| ↳ | androidx.media3.test.utils.CapturingAudioSink |
An AudioSink forwarding to DefaultAudioSink that captures configuration, discontinuity and buffer events.
Summary
Nested types |
|---|
Protected constructors |
|---|
CapturingAudioSink(sink: AudioSink!) |
Public functions |
|
|---|---|
Unit |
Configures (or reconfigures) the sink. |
java-static CapturingAudioSink! |
create()Creates the capturing audio sink. |
Unit |
Dumps the fields of the object using the |
Boolean |
handleBuffer(Attempts to process data from a |
Unit |
Signals to the sink that the next buffer may be discontinuous with the previous buffer. |
Inherited Constants |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Protected constructors
Public functions
configure
fun configure(
inputFormat: Format!,
specifiedBufferSize: Int,
outputChannels: IntArray?
): Unit
Configures (or reconfigures) the sink.
| Parameters | |
|---|---|
inputFormat: Format! |
The format of audio data provided in the input buffers. |
specifiedBufferSize: Int |
A specific size for the playback buffer in bytes, or 0 to infer a suitable buffer size. |
outputChannels: IntArray? |
A mapping from input to output channels that is applied to this sink's input as a preprocessing step, if handling PCM input. Specify |
| Throws | |
|---|---|
androidx.media3.exoplayer.audio.AudioSink.ConfigurationException |
If an error occurs configuring the sink. |
handleBuffer
fun handleBuffer(
buffer: ByteBuffer!,
presentationTimeUs: Long,
encodedAccessUnitCount: Int
): Boolean
Attempts to process data from a ByteBuffer, starting from its current position and ending at its limit (exclusive). The position of the ByteBuffer is advanced by the number of bytes that were handled. onPositionDiscontinuity will be called if presentationTimeUs is discontinuous with the last buffer handled since the last reset.
Returns whether the data was handled in full. If the data was not handled in full then the same ByteBuffer must be provided to subsequent calls until it has been fully consumed, except in the case of an intervening call to flush (or to configure that causes the sink to be flushed).
| Parameters | |
|---|---|
buffer: ByteBuffer! |
The buffer containing audio data. |
presentationTimeUs: Long |
The presentation timestamp of the buffer in microseconds. |
encodedAccessUnitCount: Int |
The number of encoded access units in the buffer, or 1 if the buffer contains PCM audio. This allows batching multiple encoded access units in one buffer. |
| Returns | |
|---|---|
Boolean |
Whether the buffer was handled fully. |
| Throws | |
|---|---|
androidx.media3.exoplayer.audio.AudioSink.InitializationException |
If an error occurs initializing the sink. |
androidx.media3.exoplayer.audio.AudioSink.WriteException |
If an error occurs writing the audio data. |
handleDiscontinuity
fun handleDiscontinuity(): Unit
Signals to the sink that the next buffer may be discontinuous with the previous buffer.
Protected functions
getDelegateAudioSink
protected fun getDelegateAudioSink(): AudioSink!
Returns the wrapped AudioSink.