public final class

DefaultAudioSink.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.exoplayer.audio.DefaultAudioSink.Builder

Overview

A builder to create DefaultAudioSink instances.

Summary

Constructors
publicBuilder()

publicBuilder(Context context)

Creates a new builder.

Methods
public DefaultAudioSinkbuild()

Builds the DefaultAudioSink.

public DefaultAudioSink.BuildersetAudioCapabilities(AudioCapabilities audioCapabilities)

public DefaultAudioSink.BuildersetAudioOffloadSupportProvider(DefaultAudioSink.AudioOffloadSupportProvider audioOffloadSupportProvider)

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

public DefaultAudioSink.BuildersetAudioProcessorChain(AudioProcessorChain audioProcessorChain)

Sets the AudioProcessorChain to process audio before playback.

public DefaultAudioSink.BuildersetAudioProcessors(AudioProcessor audioProcessors[])

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

public DefaultAudioSink.BuildersetAudioTrackBufferSizeProvider(DefaultAudioSink.AudioTrackBufferSizeProvider audioTrackBufferSizeProvider)

Sets an DefaultAudioSink.AudioTrackBufferSizeProvider to compute the buffer size when DefaultAudioSink.configure(Format, int, int[]) is called with specifiedBufferSize == 0.

public DefaultAudioSink.BuildersetEnableAudioTrackPlaybackParams(boolean enableAudioTrackPlaybackParams)

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

public DefaultAudioSink.BuildersetEnableFloatOutput(boolean enableFloatOutput)

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

public DefaultAudioSink.BuildersetExperimentalAudioOffloadListener(ExoPlayer.AudioOffloadListener audioOffloadListener)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Deprecated: Use DefaultAudioSink.Builder.Builder(Context) instead.

public Builder(Context context)

Creates a new builder.

Parameters:

context: The .

Methods

public DefaultAudioSink.Builder setAudioCapabilities(AudioCapabilities audioCapabilities)

Deprecated: These audio capabilities are only used in the absence of a . In the case when the Context is null and the audioCapabilities is not set to the Builder, the default capabilities (no encoded audio passthrough support) should be assumed.

public DefaultAudioSink.Builder setAudioProcessors(AudioProcessor audioProcessors[])

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.

public DefaultAudioSink.Builder setAudioProcessorChain(AudioProcessorChain audioProcessorChain)

Sets the 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.

public DefaultAudioSink.Builder setEnableFloatOutput(boolean enableFloatOutput)

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.

public DefaultAudioSink.Builder setEnableAudioTrackPlaybackParams(boolean enableAudioTrackPlaybackParams)

Sets whether to control the playback speed using the platform implementation (see AudioTrack), 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.

public DefaultAudioSink.Builder setAudioTrackBufferSizeProvider(DefaultAudioSink.AudioTrackBufferSizeProvider audioTrackBufferSizeProvider)

Sets an DefaultAudioSink.AudioTrackBufferSizeProvider to compute the buffer size when DefaultAudioSink.configure(Format, int, int[]) is called with specifiedBufferSize == 0.

The default value is DefaultAudioSink.AudioTrackBufferSizeProvider.DEFAULT.

public DefaultAudioSink.Builder setAudioOffloadSupportProvider(DefaultAudioSink.AudioOffloadSupportProvider audioOffloadSupportProvider)

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

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

public DefaultAudioSink.Builder setExperimentalAudioOffloadListener(ExoPlayer.AudioOffloadListener audioOffloadListener)

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

The default value is null.

public DefaultAudioSink build()

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