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!

This function is deprecated.

Use setAudioOutputProvider instead and customize setAudioOffloadSupportProvider.

DefaultAudioSink.Builder!

Sets the AudioOutputProvider used to create AudioOutput instances.

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!

This function is deprecated.

Use setAudioOutputProvider instead and customize setAudioTrackBufferSizeProvider.

DefaultAudioSink.Builder!

This function is deprecated.

Use setAudioOutputProvider instead and customize setAudioTrackBuilderModifier or wrap AudioTrackAudioOutputProvider in a ForwardingAudioOutputProvider.

DefaultAudioSink.Builder!
@CanIgnoreReturnValue
setEnableAudioOutputPlaybackParameters(
    enableAudioOutputPlaybackParameters: Boolean
)

Sets whether to control the playback speed using the AudioOutput implementation (using setPlaybackParams by default), if supported.

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

This function is deprecated.

Use setEnableAudioOutputPlaybackParameters instead.

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 DefaultAudioOffloadSupportProvider.

Must not be called if setAudioOutputProvider is used.

setAudioOutputProvider

@CanIgnoreReturnValue
fun setAudioOutputProvider(audioOutputProvider: AudioOutputProvider!): DefaultAudioSink.Builder!

Sets the AudioOutputProvider used to create AudioOutput instances.

Must not be used with the deprecated Builder constructor.

Parameters
audioOutputProvider: AudioOutputProvider!

The AudioOutputProvider.

Returns
DefaultAudioSink.Builder!

This builder.

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.

Must not be called if setAudioOutputProvider is used.

setAudioTrackProvider

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

Sets the AudioTrackProvider used to create AudioTrack instances.

Must not be called if setAudioOutputProvider is used.

Parameters
audioTrackProvider: DefaultAudioSink.AudioTrackProvider!

The AudioTrackProvider.

Returns
DefaultAudioSink.Builder!

This builder.

setEnableAudioOutputPlaybackParameters

@CanIgnoreReturnValue
fun setEnableAudioOutputPlaybackParameters(
    enableAudioOutputPlaybackParameters: Boolean
): DefaultAudioSink.Builder!

Sets whether to control the playback speed using the AudioOutput implementation (using setPlaybackParams by default), if supported. If set to false, speed up/down of the audio will be done by ExoPlayer (see SonicAudioProcessor). The AudioOutput speed adjustment is lower latency, but device-dependent, less reliable or may offer fewer available speeds.

The default value is false.

setEnableAudioTrackPlaybackParams

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

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.