mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix handling of getLatency throwing
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=189582319
This commit is contained in:
parent
e3a90a44b7
commit
99959d6130
1 changed files with 4 additions and 4 deletions
|
|
@ -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;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue