|Modifier and Type||Method and Description|
Asserts that dump of this sink is equal to expected dump which is read from
Configures (or reconfigures) the sink.
Dumps the fields of the object using the
Flushes the sink, after which it is ready to receive buffers from a new playback position.
Attempts to process data from a
Signals to the sink that the next buffer may be discontinuous with the previous buffer.
Resets the renderer, releasing any resources that it currently holds.
disableTunneling, enableTunnelingV21, getCurrentPositionUs, getPlaybackParameters, hasPendingData, isEnded, pause, play, playToEndOfStream, setAudioAttributes, setAudioSessionId, setAuxEffectInfo, setListener, setPlaybackParameters, setVolume, supportsOutput
public CapturingAudioSink(AudioSink sink)
public void configure(int inputEncoding, int inputChannelCount, int inputSampleRate, int specifiedBufferSize, @Nullable int outputChannels, int trimStartFrames, int trimEndFrames) throws AudioSink.ConfigurationException
inputEncoding- The encoding of audio data provided in the input buffers.
inputChannelCount- The number of channels.
inputSampleRate- The sample rate in Hz.
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. Specify
nullto leave the input unchanged. Otherwise, the element at index
ispecifies index of the input channel to map to output channel
iwhen preprocessing input buffers. After the map is applied the audio data will have
trimStartFrames- The number of audio frames to trim from the start of data written to the sink after this call.
trimEndFrames- The number of audio frames to trim from data written to the sink immediately preceding the next call to
AudioSink.flush()or this method.
AudioSink.ConfigurationException- If an error occurs configuring the sink.
public void handleDiscontinuity()
public boolean handleBuffer(ByteBuffer buffer, long presentationTimeUs) throws AudioSink.InitializationException, AudioSink.WriteException
ByteBuffer, starting from its current position and ending at its limit (exclusive). The position of the
ByteBufferis advanced by the number of bytes that were handled.
AudioSink.Listener.onPositionDiscontinuity()will be called if
presentationTimeUsis 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
ByteBuffer must be provided to subsequent calls until it has been fully consumed,
except in the case of an intervening call to
AudioSink.flush() (or to
int, int, int, int, int, int) that causes the sink to be flushed).
buffer- The buffer containing audio data.
presentationTimeUs- The presentation timestamp of the buffer in microseconds.
AudioSink.InitializationException- If an error occurs initializing the sink.
AudioSink.WriteException- If an error occurs writing the audio data.
public void flush()
The audio session may remain active until
AudioSink.reset() is called.
public void reset()
public void assertOutput(Context context, String dumpFile) throws IOException
If assertion fails because of an intended change in the output or a new dump file needs to
be created, set
WRITE_DUMP flag to true and run the test again. Instead of assertion,
actual dump will be written to
dumpFile. This new dump file needs to be copied to the
library/src/androidTest/assets folder manually.