Commit 21fe2f1e by olly Committed by Oliver Woodman

Make the output mode more explicit in DefaultAudioSink

PiperOrigin-RevId: 322609230
parent bdadd572
......@@ -34,12 +34,12 @@ import java.lang.reflect.Method;
* Wraps an {@link AudioTrack}, exposing a position based on {@link
* AudioTrack#getPlaybackHeadPosition()} and {@link AudioTrack#getTimestamp(AudioTimestamp)}.
*
* <p>Call {@link #setAudioTrack(AudioTrack, int, int, int)} to set the audio track to wrap. Call
* {@link #mayHandleBuffer(long)} if there is input data to write to the track. If it returns false,
* the audio track position is stabilizing and no data may be written. Call {@link #start()}
* immediately before calling {@link AudioTrack#play()}. Call {@link #pause()} when pausing the
* track. Call {@link #handleEndOfStream(long)} when no more data will be written to the track. When
* the audio track will no longer be used, call {@link #reset()}.
* <p>Call {@link #setAudioTrack(AudioTrack, boolean, int, int, int)} to set the audio track to
* wrap. Call {@link #mayHandleBuffer(long)} if there is input data to write to the track. If it
* returns false, the audio track position is stabilizing and no data may be written. Call {@link
* #start()} immediately before calling {@link AudioTrack#play()}. Call {@link #pause()} when
* pausing the track. Call {@link #handleEndOfStream(long)} when no more data will be written to the
* track. When the audio track will no longer be used, call {@link #reset()}.
*/
/* package */ final class AudioTrackPositionTracker {
......@@ -193,6 +193,7 @@ import java.lang.reflect.Method;
* track's position, until the next call to {@link #reset()}.
*
* @param audioTrack The audio track to wrap.
* @param isPassthrough Whether passthrough mode is being used.
* @param outputEncoding The encoding of the audio track.
* @param outputPcmFrameSize For PCM output encodings, the frame size. The value is ignored
* otherwise.
......@@ -200,6 +201,7 @@ import java.lang.reflect.Method;
*/
public void setAudioTrack(
AudioTrack audioTrack,
boolean isPassthrough,
@C.Encoding int outputEncoding,
int outputPcmFrameSize,
int bufferSize) {
......@@ -208,7 +210,7 @@ import java.lang.reflect.Method;
this.bufferSize = bufferSize;
audioTimestampPoller = new AudioTimestampPoller(audioTrack);
outputSampleRate = audioTrack.getSampleRate();
needsPassthroughWorkarounds = needsPassthroughWorkarounds(outputEncoding);
needsPassthroughWorkarounds = isPassthrough && needsPassthroughWorkarounds(outputEncoding);
isOutputPcm = Util.isEncodingLinearPcm(outputEncoding);
bufferSizeUs = isOutputPcm ? framesToDurationUs(bufferSize / outputPcmFrameSize) : C.TIME_UNSET;
lastRawPlaybackHeadPosition = 0;
......@@ -390,7 +392,7 @@ import java.lang.reflect.Method;
/**
* Resets the position tracker. Should be called when the audio track previously passed to {@link
* #setAudioTrack(AudioTrack, int, int, int)} is no longer in use.
* #setAudioTrack(AudioTrack, boolean, int, int, int)} is no longer in use.
*/
public void reset() {
resetSyncParams();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment