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