DefaultAudioSink.AudioTrackBufferSizeProvider


interface DefaultAudioSink.AudioTrackBufferSizeProvider

Known direct subclasses
DefaultAudioTrackBufferSizeProvider

Provide the buffer size to use when creating an AudioTrack.


Provides the buffer size to use when creating an AudioTrack.

Summary

Constants

const DefaultAudioSink.AudioTrackBufferSizeProvider!

Default instance.

Public functions

Int
getBufferSizeInBytes(
    minBufferSizeInBytes: Int,
    @C.Encoding encoding: Int,
    @DefaultAudioSink.OutputMode outputMode: Int,
    pcmFrameSize: Int,
    sampleRate: Int,
    bitrate: Int,
    maxAudioTrackPlaybackSpeed: Double
)

Returns the buffer size to use when creating an AudioTrack for a specific format and output mode.

Constants

DEFAULT

const val DEFAULTDefaultAudioSink.AudioTrackBufferSizeProvider!

Default instance.

Public functions

getBufferSizeInBytes

fun getBufferSizeInBytes(
    minBufferSizeInBytes: Int,
    @C.Encoding encoding: Int,
    @DefaultAudioSink.OutputMode outputMode: Int,
    pcmFrameSize: Int,
    sampleRate: Int,
    bitrate: Int,
    maxAudioTrackPlaybackSpeed: Double
): Int

Returns the buffer size to use when creating an AudioTrack for a specific format and output mode.

Parameters
minBufferSizeInBytes: Int

The minimum buffer size in bytes required to play this format. See getMinBufferSize.

@C.Encoding encoding: Int

The C.Encoding of the format.

@DefaultAudioSink.OutputMode outputMode: Int

How the audio will be played. One of the output modes.

pcmFrameSize: Int

The size of the PCM frames if the encoding is PCM, 1 otherwise, in bytes.

sampleRate: Int

The sample rate of the format, in Hz.

bitrate: Int

The bitrate of the audio stream if the stream is compressed, or NO_VALUE if encoding is PCM or the bitrate is not known.

maxAudioTrackPlaybackSpeed: Double

The maximum speed the content will be played using setPlaybackParams. 0.5 is 2x slow motion, 1 is real time, 2 is 2x fast forward, etc. This will be 1 unless setEnableAudioTrackPlaybackParams is enabled.

Returns
Int

The computed buffer size in bytes. It should always be >= minBufferSizeInBytes. The computed buffer size must contain an integer number of frames: bufferSizeInBytes % pcmFrameSize == 0.