Class ForwardingAudioSink
- java.lang.Object
-
- com.google.android.exoplayer2.audio.ForwardingAudioSink
-
- All Implemented Interfaces:
AudioSink
- Direct Known Subclasses:
CapturingAudioSink
,OggFileAudioBufferSink
@Deprecated public class ForwardingAudioSink extends Object implements AudioSink
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.An overridableAudioSink
implementation forwarding all methods to another sink.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.audio.AudioSink
AudioSink.ConfigurationException, AudioSink.InitializationException, AudioSink.Listener, AudioSink.SinkFormatSupport, AudioSink.UnexpectedDiscontinuityException, AudioSink.WriteException
-
-
Field Summary
-
Fields inherited from interface com.google.android.exoplayer2.audio.AudioSink
CURRENT_POSITION_NOT_SET, SINK_FORMAT_SUPPORTED_DIRECTLY, SINK_FORMAT_SUPPORTED_WITH_TRANSCODING, SINK_FORMAT_UNSUPPORTED
-
-
Constructor Summary
Constructors Constructor Description ForwardingAudioSink(AudioSink sink)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
configure(Format inputFormat, int specifiedBufferSize, int[] outputChannels)
Deprecated.Configures (or reconfigures) the sink.void
disableTunneling()
Deprecated.Disables tunneling.void
enableTunnelingV21()
Deprecated.Enables tunneling, if possible.void
experimentalFlushWithoutAudioTrackRelease()
Deprecated.Flushes the sink, after which it is ready to receive buffers from a new playback position.void
flush()
Deprecated.Flushes the sink, after which it is ready to receive buffers from a new playback position.AudioAttributes
getAudioAttributes()
Deprecated.Returns the audio attributes used for audio playback, ornull
if the sink does not use audio attributes.long
getCurrentPositionUs(boolean sourceEnded)
Deprecated.Returns the playback position in the stream starting at zero, in microseconds, orAudioSink.CURRENT_POSITION_NOT_SET
if it is not yet available.@com.google.android.exoplayer2.audio.AudioSink.SinkFormatSupport int
getFormatSupport(Format format)
Deprecated.Returns the level of support that the sink provides for a givenFormat
.PlaybackParameters
getPlaybackParameters()
Deprecated.Returns the activePlaybackParameters
.boolean
getSkipSilenceEnabled()
Deprecated.Returns whether silences are skipped in the audio stream.boolean
handleBuffer(ByteBuffer buffer, long presentationTimeUs, int encodedAccessUnitCount)
Deprecated.Attempts to process data from aByteBuffer
, starting from its current position and ending at its limit (exclusive).void
handleDiscontinuity()
Deprecated.Signals to the sink that the next buffer may be discontinuous with the previous buffer.boolean
hasPendingData()
Deprecated.Returns whether the sink has data pending that has not been consumed yet.boolean
isEnded()
Deprecated.Returns whetherAudioSink.playToEndOfStream()
has been called and all buffers have been processed.void
pause()
Deprecated.Pauses playback.void
play()
Deprecated.Starts or resumes consuming audio if initialized.void
playToEndOfStream()
Deprecated.Processes any remaining data.void
reset()
Deprecated.Resets the sink, releasing any resources that it currently holds.void
setAudioAttributes(AudioAttributes audioAttributes)
Deprecated.Sets attributes for audio playback.void
setAudioSessionId(int audioSessionId)
Deprecated.Sets the audio session id.void
setAuxEffectInfo(AuxEffectInfo auxEffectInfo)
Deprecated.Sets the auxiliary effect.void
setListener(AudioSink.Listener listener)
Deprecated.Sets the listener for sink events, which should be the audio renderer.void
setOutputStreamOffsetUs(long outputStreamOffsetUs)
Deprecated.Sets the offset that is added to the media timestamp before it is passed aspresentationTimeUs
inAudioSink.handleBuffer(ByteBuffer, long, int)
.void
setPlaybackParameters(PlaybackParameters playbackParameters)
Deprecated.Attempts to set the playback parameters.void
setPlayerId(PlayerId playerId)
Deprecated.Sets thePlayerId
of the player using this audio sink.void
setPreferredDevice(AudioDeviceInfo audioDeviceInfo)
Deprecated.Sets the preferred audio device.void
setSkipSilenceEnabled(boolean skipSilenceEnabled)
Deprecated.Sets whether silences should be skipped in the audio stream.void
setVolume(float volume)
Deprecated.Sets the playback volume.boolean
supportsFormat(Format format)
Deprecated.Returns whether the sink supports a givenFormat
.
-
-
-
Constructor Detail
-
ForwardingAudioSink
public ForwardingAudioSink(AudioSink sink)
Deprecated.
-
-
Method Detail
-
setListener
public void setListener(AudioSink.Listener listener)
Deprecated.Description copied from interface:AudioSink
Sets the listener for sink events, which should be the audio renderer.- Specified by:
setListener
in interfaceAudioSink
- Parameters:
listener
- The listener for sink events, which should be the audio renderer.
-
setPlayerId
public void setPlayerId(@Nullable PlayerId playerId)
Deprecated.Description copied from interface:AudioSink
Sets thePlayerId
of the player using this audio sink.- Specified by:
setPlayerId
in interfaceAudioSink
- Parameters:
playerId
- ThePlayerId
, or null to clear a previously set id.
-
supportsFormat
public boolean supportsFormat(Format format)
Deprecated.Description copied from interface:AudioSink
Returns whether the sink supports a givenFormat
.- Specified by:
supportsFormat
in interfaceAudioSink
- Parameters:
format
- The format.- Returns:
- Whether the sink supports the format.
-
getFormatSupport
public @com.google.android.exoplayer2.audio.AudioSink.SinkFormatSupport int getFormatSupport(Format format)
Deprecated.Description copied from interface:AudioSink
Returns the level of support that the sink provides for a givenFormat
.- Specified by:
getFormatSupport
in interfaceAudioSink
- Parameters:
format
- The format.- Returns:
- The level of support provided.
-
getCurrentPositionUs
public long getCurrentPositionUs(boolean sourceEnded)
Deprecated.Description copied from interface:AudioSink
Returns the playback position in the stream starting at zero, in microseconds, orAudioSink.CURRENT_POSITION_NOT_SET
if it is not yet available.- Specified by:
getCurrentPositionUs
in interfaceAudioSink
- Parameters:
sourceEnded
- Specifytrue
if no more input buffers will be provided.- Returns:
- The playback position relative to the start of playback, in microseconds.
-
configure
public void configure(Format inputFormat, int specifiedBufferSize, @Nullable int[] outputChannels) throws AudioSink.ConfigurationException
Deprecated.Description copied from interface:AudioSink
Configures (or reconfigures) the sink.- Specified by:
configure
in interfaceAudioSink
- Parameters:
inputFormat
- The format of audio data provided in the input buffers.specifiedBufferSize
- A specific size for the playback buffer in bytes, or 0 to infer a suitable buffer size.outputChannels
- A mapping from input to output channels that is applied to this sink's input as a preprocessing step, if handling PCM input. Specifynull
to leave the input unchanged. Otherwise, the element at indexi
specifies index of the input channel to map to output channeli
when preprocessing input buffers. After the map is applied the audio data will haveoutputChannels.length
channels.- Throws:
AudioSink.ConfigurationException
- If an error occurs configuring the sink.
-
play
public void play()
Deprecated.Description copied from interface:AudioSink
Starts or resumes consuming audio if initialized.
-
handleDiscontinuity
public void handleDiscontinuity()
Deprecated.Description copied from interface:AudioSink
Signals to the sink that the next buffer may be discontinuous with the previous buffer.- Specified by:
handleDiscontinuity
in interfaceAudioSink
-
handleBuffer
public boolean handleBuffer(ByteBuffer buffer, long presentationTimeUs, int encodedAccessUnitCount) throws AudioSink.InitializationException, AudioSink.WriteException
Deprecated.Description copied from interface:AudioSink
Attempts to process data from aByteBuffer
, starting from its current position and ending at its limit (exclusive). The position of theByteBuffer
is advanced by the number of bytes that were handled.AudioSink.Listener.onPositionDiscontinuity()
will be called ifpresentationTimeUs
is discontinuous with the last buffer handled since the last reset.Returns whether the data was handled in full. If the data was not handled in full then the same
ByteBuffer
must be provided to subsequent calls until it has been fully consumed, except in the case of an intervening call toAudioSink.flush()
(or toAudioSink.configure(Format, int, int[])
that causes the sink to be flushed).- Specified by:
handleBuffer
in interfaceAudioSink
- Parameters:
buffer
- The buffer containing audio data.presentationTimeUs
- The presentation timestamp of the buffer in microseconds.encodedAccessUnitCount
- The number of encoded access units in the buffer, or 1 if the buffer contains PCM audio. This allows batching multiple encoded access units in one buffer.- Returns:
- Whether the buffer was handled fully.
- Throws:
AudioSink.InitializationException
- If an error occurs initializing the sink.AudioSink.WriteException
- If an error occurs writing the audio data.
-
playToEndOfStream
public void playToEndOfStream() throws AudioSink.WriteException
Deprecated.Description copied from interface:AudioSink
Processes any remaining data.AudioSink.isEnded()
will returntrue
when no data remains.- Specified by:
playToEndOfStream
in interfaceAudioSink
- Throws:
AudioSink.WriteException
- If an error occurs draining data to the sink.
-
isEnded
public boolean isEnded()
Deprecated.Description copied from interface:AudioSink
Returns whetherAudioSink.playToEndOfStream()
has been called and all buffers have been processed.
-
hasPendingData
public boolean hasPendingData()
Deprecated.Description copied from interface:AudioSink
Returns whether the sink has data pending that has not been consumed yet.- Specified by:
hasPendingData
in interfaceAudioSink
-
setPlaybackParameters
public void setPlaybackParameters(PlaybackParameters playbackParameters)
Deprecated.Description copied from interface:AudioSink
Attempts to set the playback parameters. The audio sink may override these parameters if they are not supported.- Specified by:
setPlaybackParameters
in interfaceAudioSink
- Parameters:
playbackParameters
- The new playback parameters to attempt to set.
-
getPlaybackParameters
public PlaybackParameters getPlaybackParameters()
Deprecated.Description copied from interface:AudioSink
Returns the activePlaybackParameters
.- Specified by:
getPlaybackParameters
in interfaceAudioSink
-
setSkipSilenceEnabled
public void setSkipSilenceEnabled(boolean skipSilenceEnabled)
Deprecated.Description copied from interface:AudioSink
Sets whether silences should be skipped in the audio stream.- Specified by:
setSkipSilenceEnabled
in interfaceAudioSink
-
getSkipSilenceEnabled
public boolean getSkipSilenceEnabled()
Deprecated.Description copied from interface:AudioSink
Returns whether silences are skipped in the audio stream.- Specified by:
getSkipSilenceEnabled
in interfaceAudioSink
-
setAudioAttributes
public void setAudioAttributes(AudioAttributes audioAttributes)
Deprecated.Description copied from interface:AudioSink
Sets attributes for audio playback. If the attributes have changed and if the sink is not configured for use with tunneling, then it is reset and the audio session id is cleared.If the sink is configured for use with tunneling then the audio attributes are ignored. The sink is not reset and the audio session id is not cleared. The passed attributes will be used if the sink is later re-configured into non-tunneled mode.
- Specified by:
setAudioAttributes
in interfaceAudioSink
- Parameters:
audioAttributes
- The attributes for audio playback.
-
getAudioAttributes
@Nullable public AudioAttributes getAudioAttributes()
Deprecated.Description copied from interface:AudioSink
Returns the audio attributes used for audio playback, ornull
if the sink does not use audio attributes.- Specified by:
getAudioAttributes
in interfaceAudioSink
-
setAudioSessionId
public void setAudioSessionId(int audioSessionId)
Deprecated.Description copied from interface:AudioSink
Sets the audio session id.- Specified by:
setAudioSessionId
in interfaceAudioSink
-
setAuxEffectInfo
public void setAuxEffectInfo(AuxEffectInfo auxEffectInfo)
Deprecated.Description copied from interface:AudioSink
Sets the auxiliary effect.- Specified by:
setAuxEffectInfo
in interfaceAudioSink
-
setPreferredDevice
@RequiresApi(23) public void setPreferredDevice(@Nullable AudioDeviceInfo audioDeviceInfo)
Deprecated.Description copied from interface:AudioSink
Sets the preferred audio device.- Specified by:
setPreferredDevice
in interfaceAudioSink
- Parameters:
audioDeviceInfo
- The preferred audio device, or null to restore the default.
-
setOutputStreamOffsetUs
public void setOutputStreamOffsetUs(long outputStreamOffsetUs)
Deprecated.Description copied from interface:AudioSink
Sets the offset that is added to the media timestamp before it is passed aspresentationTimeUs
inAudioSink.handleBuffer(ByteBuffer, long, int)
.- Specified by:
setOutputStreamOffsetUs
in interfaceAudioSink
- Parameters:
outputStreamOffsetUs
- The output stream offset in microseconds.
-
enableTunnelingV21
public void enableTunnelingV21()
Deprecated.Description copied from interface:AudioSink
Enables tunneling, if possible. The sink is reset if tunneling was previously disabled. Enabling tunneling is only possible if the sink is based on a platformAudioTrack
, and requires platform API version 21 onwards.- Specified by:
enableTunnelingV21
in interfaceAudioSink
-
disableTunneling
public void disableTunneling()
Deprecated.Description copied from interface:AudioSink
Disables tunneling. If tunneling was previously enabled then the sink is reset and any audio session id is cleared.- Specified by:
disableTunneling
in interfaceAudioSink
-
setVolume
public void setVolume(float volume)
Deprecated.Description copied from interface:AudioSink
Sets the playback volume.
-
pause
public void pause()
Deprecated.Description copied from interface:AudioSink
Pauses playback.
-
flush
public void flush()
Deprecated.Description copied from interface:AudioSink
Flushes the sink, after which it is ready to receive buffers from a new playback position.The audio session may remain active until
AudioSink.reset()
is called.
-
experimentalFlushWithoutAudioTrackRelease
public void experimentalFlushWithoutAudioTrackRelease()
Deprecated.Description copied from interface:AudioSink
Flushes the sink, after which it is ready to receive buffers from a new playback position.Does not release the
AudioTrack
held by the sink.This method is experimental, and will be renamed or removed in a future release.
Only for experimental use as part of
MediaCodecAudioRenderer.experimentalSetEnableKeepAudioTrackOnSeek(boolean)
.- Specified by:
experimentalFlushWithoutAudioTrackRelease
in interfaceAudioSink
-
-