AudioTrackAudioOutputProvider.Builder


public final class AudioTrackAudioOutputProvider.Builder


A builder to create AudioTrackAudioOutputProvider instances.

Summary

Public constructors

Creates a new builder.

Public methods

AudioTrackAudioOutputProvider

Builds the AudioTrackAudioOutputProvider.

AudioTrackAudioOutputProvider.Builder

Sets an AudioOffloadSupportProvider to provide the provider's offload support capabilities for a given AudioOutputProvider.FormatConfig for calls to getFormatSupport.

AudioTrackAudioOutputProvider.Builder

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

AudioTrackAudioOutputProvider.Builder

Sets a BiConsumer to modify the AudioTrack.Builder before building the AudioTrack.

AudioTrackAudioOutputProvider.Builder

Sets the maximum playback speed that an AudioTrackAudioOutput provided by this instance is going to be configured for.

Public constructors

Builder

public Builder(@Nullable Context context)

Creates a new builder.

Parameters
@Nullable Context context

The Context.

Public methods

setAudioOffloadSupportProvider

@UnstableApi
@CanIgnoreReturnValue
public AudioTrackAudioOutputProvider.Builder setAudioOffloadSupportProvider(
    DefaultAudioSink.AudioOffloadSupportProvider audioOffloadSupportProvider
)

Sets an AudioOffloadSupportProvider to provide the provider's offload support capabilities for a given AudioOutputProvider.FormatConfig for calls to getFormatSupport.

The default is an instance of DefaultAudioOffloadSupportProvider.

Parameters
DefaultAudioSink.AudioOffloadSupportProvider audioOffloadSupportProvider

The AudioOffloadSupportProvider to use.

setAudioTrackBufferSizeProvider

@UnstableApi
@CanIgnoreReturnValue
public AudioTrackAudioOutputProvider.Builder setAudioTrackBufferSizeProvider(
    DefaultAudioSink.AudioTrackBufferSizeProvider bufferSizeProvider
)

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

The default value is DEFAULT.

setAudioTrackBuilderModifier

@CanIgnoreReturnValue
@RequiresApi(value = 24)
public AudioTrackAudioOutputProvider.Builder setAudioTrackBuilderModifier(
    BiConsumer<AudioTrack.BuilderAudioOutputProvider.OutputConfig> audioTrackBuilderModifier
)

Sets a BiConsumer to modify the AudioTrack.Builder before building the AudioTrack.

Parameters
BiConsumer<AudioTrack.BuilderAudioOutputProvider.OutputConfig> audioTrackBuilderModifier

A BiConsumer that accepts an AudioTrack.Builder and an OutputConfig.

setMaxPlaybackSpeed

@UnstableApi
@CanIgnoreReturnValue
public AudioTrackAudioOutputProvider.Builder setMaxPlaybackSpeed(float maxPlaybackSpeed)

Sets the maximum playback speed that an AudioTrackAudioOutput provided by this instance is going to be configured for. This is also used to allocate buffers that are big enough to not underrun at the maximum playback speed. This value has no effect if useAudioOutputPlaybackParams is disabled.

The default value is MAX_PLAYBACK_SPEED.

Parameters
float maxPlaybackSpeed

The maximum playback speed to use. Must be at least 1f.