Class DefaultAudioSink.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.audio.DefaultAudioSink.Builder
-
- Enclosing class:
- DefaultAudioSink
public static final class DefaultAudioSink.Builder extends Object
A builder to createDefaultAudioSink
instances.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Creates a new builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultAudioSink
build()
Builds theDefaultAudioSink
.DefaultAudioSink.Builder
setAudioCapabilities(AudioCapabilities audioCapabilities)
Sets audio capabilities for playback on this device.DefaultAudioSink.Builder
setAudioProcessorChain(DefaultAudioSink.AudioProcessorChain audioProcessorChain)
Sets theDefaultAudioSink.AudioProcessorChain
to process audio before playback.DefaultAudioSink.Builder
setAudioProcessors(AudioProcessor[] audioProcessors)
Sets an array ofAudioProcessors
s that will process PCM audio before output.DefaultAudioSink.Builder
setAudioTrackBufferSizeProvider(com.google.android.exoplayer2.audio.DefaultAudioSink.AudioTrackBufferSizeProvider audioTrackBufferSizeProvider)
Sets anDefaultAudioSink.AudioTrackBufferSizeProvider
to compute the buffer size whenDefaultAudioSink.configure(com.google.android.exoplayer2.Format, int, int[])
is called withspecifiedBufferSize == 0
.DefaultAudioSink.Builder
setEnableAudioTrackPlaybackParams(boolean enableAudioTrackPlaybackParams)
Sets whether to control the playback speed using the platform implementation (seeAudioTrack.setPlaybackParams(PlaybackParams)
), if supported.DefaultAudioSink.Builder
setEnableFloatOutput(boolean enableFloatOutput)
Sets whether to enable 32-bit float output or integer output.DefaultAudioSink.Builder
setOffloadMode(@com.google.android.exoplayer2.audio.DefaultAudioSink.OffloadMode int offloadMode)
Sets the offload mode.
-
-
-
Method Detail
-
setAudioCapabilities
public DefaultAudioSink.Builder setAudioCapabilities(AudioCapabilities audioCapabilities)
Sets audio capabilities for playback on this device. May benull
if the default capabilities (no encoded audio passthrough support) should be assumed.Default is
AudioCapabilities.DEFAULT_AUDIO_CAPABILITIES
.
-
setAudioProcessors
public DefaultAudioSink.Builder setAudioProcessors(AudioProcessor[] audioProcessors)
Sets an array ofAudioProcessors
s that will process PCM audio before output. May be empty. Equivalent ofsetAudioProcessorChain(new DefaultAudioProcessorChain(audioProcessors)
.The default value is an empty array.
-
setAudioProcessorChain
public DefaultAudioSink.Builder setAudioProcessorChain(DefaultAudioSink.AudioProcessorChain audioProcessorChain)
Sets theDefaultAudioSink.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.
-
setEnableFloatOutput
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. Float output is supported from API level 21. Audio processing (for example, speed adjustment) will not be available when float output is in use.The default value is
false
.
-
setEnableAudioTrackPlaybackParams
public DefaultAudioSink.Builder setEnableAudioTrackPlaybackParams(boolean enableAudioTrackPlaybackParams)
Sets whether to control the playback speed using the platform implementation (seeAudioTrack.setPlaybackParams(PlaybackParams)
), if supported. If set tofalse
, speed up/down of the audio will be done by ExoPlayer (seeSonicAudioProcessor
). Platform speed adjustment is lower latency, but less reliable.The default value is
false
.
-
setOffloadMode
public DefaultAudioSink.Builder setOffloadMode(@com.google.android.exoplayer2.audio.DefaultAudioSink.OffloadMode int offloadMode)
Sets the offload mode. If an audio format can be both played with offload and encoded audio passthrough, it will be played in offload. Audio offload is supported from API level 29. Most Android devices can only support one offloadAudioTrack
at a time and can invalidate it at any time. Thus an app can never be guaranteed that it will be able to play in offload. Audio processing (for example, speed adjustment) will not be available when offload is in use.The default value is
DefaultAudioSink.OFFLOAD_MODE_DISABLED
.
-
setAudioTrackBufferSizeProvider
public DefaultAudioSink.Builder setAudioTrackBufferSizeProvider(com.google.android.exoplayer2.audio.DefaultAudioSink.AudioTrackBufferSizeProvider audioTrackBufferSizeProvider)
Sets anDefaultAudioSink.AudioTrackBufferSizeProvider
to compute the buffer size whenDefaultAudioSink.configure(com.google.android.exoplayer2.Format, int, int[])
is called withspecifiedBufferSize == 0
.The default value is
DefaultAudioSink.AudioTrackBufferSizeProvider.DEFAULT
.
-
build
public DefaultAudioSink build()
Builds theDefaultAudioSink
. Must only be called once per Builder instance.
-
-