DefaultAudioSink.DefaultAudioProcessorChain


public class DefaultAudioSink.DefaultAudioProcessorChain implements DefaultAudioSink.AudioProcessorChain


The default audio processor chain, which applies a (possibly empty) chain of user-defined audio processors followed by SilenceSkippingAudioProcessor and SonicAudioProcessor.

Summary

Public fields

final AudioProcessor[]

Public constructors

DefaultAudioProcessorChain(AudioProcessor[] audioProcessors)

Creates a new default chain of audio processors, with the user-defined audioProcessors applied before silence skipping and speed adjustment processors.

DefaultAudioProcessorChain(
    AudioProcessor[] audioProcessors,
    SilenceSkippingAudioProcessor silenceSkippingAudioProcessor,
    SonicAudioProcessor sonicAudioProcessor
)

Creates a new default chain of audio processors, with the user-defined audioProcessors applied before silence skipping and speed adjustment processors.

Public methods

PlaybackParameters

Configures audio processors to apply the specified playback parameters immediately, returning the new playback parameters, which may differ from those passed in.

boolean
applySkipSilenceEnabled(boolean skipSilenceEnabled)

Configures audio processors to apply whether to skip silences immediately, returning the new value.

AudioProcessor[]

Returns the fixed chain of audio processors that will process audio.

long
getMediaDuration(long playoutDuration)

Returns the media duration corresponding to the specified playout duration, taking speed adjustment due to audio processing into account.

long

Returns the number of output audio frames skipped since the audio processors were last flushed.

Public fields

audioProcessors

public final AudioProcessor[] audioProcessors

Public constructors

DefaultAudioProcessorChain

public DefaultAudioProcessorChain(AudioProcessor[] audioProcessors)

Creates a new default chain of audio processors, with the user-defined audioProcessors applied before silence skipping and speed adjustment processors.

DefaultAudioProcessorChain

public DefaultAudioProcessorChain(
    AudioProcessor[] audioProcessors,
    SilenceSkippingAudioProcessor silenceSkippingAudioProcessor,
    SonicAudioProcessor sonicAudioProcessor
)

Creates a new default chain of audio processors, with the user-defined audioProcessors applied before silence skipping and speed adjustment processors.

Public methods

applyPlaybackParameters

public PlaybackParameters applyPlaybackParameters(PlaybackParameters playbackParameters)

Configures audio processors to apply the specified playback parameters immediately, returning the new playback parameters, which may differ from those passed in. Only called when processors have no input pending.

Parameters
PlaybackParameters playbackParameters

The playback parameters to try to apply.

Returns
PlaybackParameters

The playback parameters that were actually applied.

applySkipSilenceEnabled

public boolean applySkipSilenceEnabled(boolean skipSilenceEnabled)

Configures audio processors to apply whether to skip silences immediately, returning the new value. Only called when processors have no input pending.

Parameters
boolean skipSilenceEnabled

Whether silences should be skipped in the audio stream.

Returns
boolean

The new value.

getAudioProcessors

public AudioProcessor[] getAudioProcessors()

Returns the fixed chain of audio processors that will process audio. This method is called once during initialization, but audio processors may change state to become active/inactive during playback.

getMediaDuration

public long getMediaDuration(long playoutDuration)

Returns the media duration corresponding to the specified playout duration, taking speed adjustment due to audio processing into account.

The scaling performed by this method will use the actual playback speed achieved by the audio processor chain, on average, since it was last flushed. This may differ very slightly from the target playback speed.

Parameters
long playoutDuration

The playout duration to scale.

Returns
long

The corresponding media duration, in the same units as duration.

getSkippedOutputFrameCount

public long getSkippedOutputFrameCount()

Returns the number of output audio frames skipped since the audio processors were last flushed.