Commit 99959d61 by andrewlewis Committed by Oliver Woodman

Fix handling of getLatency throwing

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=189582319
parent e3a90a44
...@@ -148,7 +148,7 @@ import java.lang.reflect.Method; ...@@ -148,7 +148,7 @@ import java.lang.reflect.Method;
private boolean needsPassthroughWorkarounds; private boolean needsPassthroughWorkarounds;
private @Nullable AudioTimestampV19 audioTimestamp; private @Nullable AudioTimestampV19 audioTimestamp;
private boolean shouldSampleLatency; private boolean isOutputPcm;
private long lastLatencySampleTimeUs; private long lastLatencySampleTimeUs;
private long lastRawPlaybackHeadPosition; private long lastRawPlaybackHeadPosition;
private long rawPlaybackHeadWrapCount; private long rawPlaybackHeadWrapCount;
...@@ -197,12 +197,11 @@ import java.lang.reflect.Method; ...@@ -197,12 +197,11 @@ import java.lang.reflect.Method;
this.outputPcmFrameSize = outputPcmFrameSize; this.outputPcmFrameSize = outputPcmFrameSize;
outputSampleRate = audioTrack.getSampleRate(); outputSampleRate = audioTrack.getSampleRate();
needsPassthroughWorkarounds = needsPassthroughWorkarounds(outputEncoding); needsPassthroughWorkarounds = needsPassthroughWorkarounds(outputEncoding);
boolean isOutputPcm = Util.isEncodingPcm(outputEncoding); isOutputPcm = Util.isEncodingPcm(outputEncoding);
bufferSizeUs = isOutputPcm ? framesToDurationUs(bufferSize / outputPcmFrameSize) : C.TIME_UNSET; bufferSizeUs = isOutputPcm ? framesToDurationUs(bufferSize / outputPcmFrameSize) : C.TIME_UNSET;
if (Util.SDK_INT >= 19) { if (Util.SDK_INT >= 19) {
audioTimestamp = new AudioTimestampV19(audioTrack); audioTimestamp = new AudioTimestampV19(audioTrack);
} }
shouldSampleLatency = isOutputPcm && getLatencyMethod != null;
lastRawPlaybackHeadPosition = 0; lastRawPlaybackHeadPosition = 0;
rawPlaybackHeadWrapCount = 0; rawPlaybackHeadWrapCount = 0;
passthroughWorkaroundPauseOffset = 0; passthroughWorkaroundPauseOffset = 0;
...@@ -419,7 +418,8 @@ import java.lang.reflect.Method; ...@@ -419,7 +418,8 @@ import java.lang.reflect.Method;
} }
private void maybeUpdateLatency(long systemTimeUs) { private void maybeUpdateLatency(long systemTimeUs) {
if (shouldSampleLatency if (isOutputPcm
&& getLatencyMethod != null
&& systemTimeUs - lastLatencySampleTimeUs >= MIN_LATENCY_SAMPLE_INTERVAL_US) { && systemTimeUs - lastLatencySampleTimeUs >= MIN_LATENCY_SAMPLE_INTERVAL_US) {
try { try {
// Compute the audio track latency, excluding the latency due to the buffer (leaving // Compute the audio track latency, excluding the latency due to the buffer (leaving
......
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