DefaultAudioSink.Builder


class DefaultAudioSink.Builder


A builder to create DefaultAudioSink instances.

Summary

Public constructors

This function is deprecated.

Use Builder instead.

Builder(context: Context!)

Creates a new builder.

Public functions

DefaultAudioSink!

Builds the DefaultAudioSink.

DefaultAudioSink.Builder!

This function is deprecated.

These audio capabilities are only used in the absence of a context.

DefaultAudioSink.Builder!

Sets an AudioOffloadSupportProvider to provide the sink's offload support capabilities for a given Format and AudioAttributes for calls to getFormatOffloadSupport.

DefaultAudioSink.Builder!

Sets the androidx.media3.common.audio.AudioProcessorChain to process audio before playback.

DefaultAudioSink.Builder!

Sets an array of AudioProcessorss that will process PCM audio before output.

DefaultAudioSink.Builder!

Sets an AudioTrackBufferSizeProvider to compute the buffer size when configure is called with specifiedBufferSize == 0.

DefaultAudioSink.Builder!

Sets the AudioTrackProvider used to create AudioTrack instances.

DefaultAudioSink.Builder!
@CanIgnoreReturnValue
setEnableAudioTrackPlaybackParams(
    enableAudioTrackPlaybackParams: Boolean
)

Sets whether to control the playback speed using the platform implementation (see setPlaybackParams), if supported.

DefaultAudioSink.Builder!

Sets whether to enable 32-bit float output or integer output.

DefaultAudioSink.Builder!

Sets an optional AudioOffloadListener to receive events relevant to offloaded playback.

Public constructors

Builder

Builder()

Builder

Builder(context: Context!)

Creates a new builder.

Parameters
context: Context!

The Context.

Public functions

build

fun build(): DefaultAudioSink!

Builds the DefaultAudioSink. Must only be called once per Builder instance.

setAudioCapabilities

@CanIgnoreReturnValue
fun setAudioCapabilities(audioCapabilities: AudioCapabilities!): DefaultAudioSink.Builder!

setAudioOffloadSupportProvider

@CanIgnoreReturnValue
fun setAudioOffloadSupportProvider(
    audioOffloadSupportProvider: DefaultAudioSink.AudioOffloadSupportProvider!
): DefaultAudioSink.Builder!

Sets an AudioOffloadSupportProvider to provide the sink's offload support capabilities for a given Format and AudioAttributes for calls to getFormatOffloadSupport.

If this setter is not called, then the DefaultAudioSink uses an instance of .

setAudioProcessorChain

@CanIgnoreReturnValue
fun setAudioProcessorChain(audioProcessorChain: AudioProcessorChain!): DefaultAudioSink.Builder!

Sets the androidx.media3.common.audio.AudioProcessorChain to process audio before playback. The instance passed in must not be reused in other sinks. Processing chains are only supported for PCM playback (not passthrough or offload).

By default, no processing will be applied.

setAudioProcessors

@CanIgnoreReturnValue
fun setAudioProcessors(audioProcessors: Array<AudioProcessor!>!): DefaultAudioSink.Builder!

Sets an array of AudioProcessorss that will process PCM audio before output. May be empty. Equivalent of setAudioProcessorChain(new DefaultAudioProcessorChain(audioProcessors).

The default value is an empty array.

setAudioTrackBufferSizeProvider

@CanIgnoreReturnValue
fun setAudioTrackBufferSizeProvider(
    audioTrackBufferSizeProvider: DefaultAudioSink.AudioTrackBufferSizeProvider!
): DefaultAudioSink.Builder!

Sets an AudioTrackBufferSizeProvider to compute the buffer size when configure is called with specifiedBufferSize == 0.

The default value is DEFAULT.

setAudioTrackProvider

@CanIgnoreReturnValue
fun setAudioTrackProvider(
    audioTrackProvider: DefaultAudioSink.AudioTrackProvider!
): DefaultAudioSink.Builder!

Sets the AudioTrackProvider used to create AudioTrack instances.

Parameters
audioTrackProvider: DefaultAudioSink.AudioTrackProvider!

The AudioTrackProvider.

Returns
DefaultAudioSink.Builder!

This builder.

setEnableAudioTrackPlaybackParams

@CanIgnoreReturnValue
fun setEnableAudioTrackPlaybackParams(
    enableAudioTrackPlaybackParams: Boolean
): DefaultAudioSink.Builder!

Sets whether to control the playback speed using the platform implementation (see setPlaybackParams), if supported. If set to false, speed up/down of the audio will be done by ExoPlayer (see SonicAudioProcessor). Platform speed adjustment is lower latency, but less reliable.

The default value is false.

setEnableFloatOutput

@CanIgnoreReturnValue
fun setEnableFloatOutput(enableFloatOutput: Boolean): DefaultAudioSink.Builder!

Sets whether to enable 32-bit float output or integer output. Where possible, 32-bit float output will be used if the input is 32-bit float, and also if the input is high resolution (24-bit or 32-bit) integer PCM. Audio processing (for example, speed adjustment) will not be available when float output is in use.

The default value is false.

setExperimentalAudioOffloadListener

@CanIgnoreReturnValue
fun setExperimentalAudioOffloadListener(
    audioOffloadListener: ExoPlayer.AudioOffloadListener?
): DefaultAudioSink.Builder!

Sets an optional AudioOffloadListener to receive events relevant to offloaded playback.

The default value is null.