DefaultAudioSink.Builder
public final class DefaultAudioSink.Builder
A builder to create DefaultAudioSink instances.
Summary
Public constructors |
|---|
This method is deprecated. Use |
|
Creates a new builder. |
Public constructors
Public methods
build
public DefaultAudioSink build()
Builds the DefaultAudioSink. Must only be called once per Builder instance.
setAudioCapabilities
@CanIgnoreReturnValue
public DefaultAudioSink.BuildersetAudioCapabilities(AudioCapabilities audioCapabilities)
setAudioOffloadSupportProvider
@CanIgnoreReturnValue
public DefaultAudioSink.BuildersetAudioOffloadSupportProvider(
DefaultAudioSink.AudioOffloadSupportProvider audioOffloadSupportProvider
)
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
public DefaultAudioSink.Builder setAudioOutputProvider(AudioOutputProvider audioOutputProvider)
Sets the AudioOutputProvider used to create AudioOutput instances.
Must not be used with the deprecated Builder constructor.
| Parameters | |
|---|---|
AudioOutputProvider audioOutputProvider |
The |
| Returns | |
|---|---|
DefaultAudioSink.Builder |
This builder. |
setAudioProcessorChain
@CanIgnoreReturnValue
public DefaultAudioSink.Builder setAudioProcessorChain(AudioProcessorChain audioProcessorChain)
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
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.
setAudioTrackBufferSizeProvider
@CanIgnoreReturnValue
public DefaultAudioSink.BuildersetAudioTrackBufferSizeProvider(
DefaultAudioSink.AudioTrackBufferSizeProvider audioTrackBufferSizeProvider
)
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
public DefaultAudioSink.BuildersetAudioTrackProvider(
DefaultAudioSink.AudioTrackProvider audioTrackProvider
)
Sets the AudioTrackProvider used to create AudioTrack instances.
Must not be called if setAudioOutputProvider is used.
| Parameters | |
|---|---|
DefaultAudioSink.AudioTrackProvider audioTrackProvider |
The |
| Returns | |
|---|---|
DefaultAudioSink.Builder |
This builder. |
setEnableAudioOutputPlaybackParameters
@CanIgnoreReturnValue
public DefaultAudioSink.Builder setEnableAudioOutputPlaybackParameters(
boolean enableAudioOutputPlaybackParameters
)
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
public DefaultAudioSink.BuildersetEnableAudioTrackPlaybackParams(
boolean enableAudioTrackPlaybackParams
)
setEnableFloatOutput
@CanIgnoreReturnValue
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.
setExperimentalAudioOffloadListener
@CanIgnoreReturnValue
public DefaultAudioSink.Builder setExperimentalAudioOffloadListener(
@Nullable ExoPlayer.AudioOffloadListener audioOffloadListener
)
Sets an optional AudioOffloadListener to receive events relevant to offloaded playback.
The default value is null.