Commit b89dc8fb by tonihei Committed by Oliver Woodman

Prevent negative total buffered duration at the point where it is calculated.

In some edge cases the renderer position may be slightly ahead of the
buffered position and the total buffered duration is thus negative. We already
filter that in ExoPlayerImpl for the publicly accessible value. However, we
forward the unfiltered value to other components like the LoadControl, which
may be confusing.

Issue:#6015
PiperOrigin-RevId: 253780460
parent e174d8a9
......@@ -512,7 +512,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
@Override
public long getTotalBufferedDuration() {
return Math.max(0, C.usToMs(playbackInfo.totalBufferedDurationUs));
return C.usToMs(playbackInfo.totalBufferedDurationUs);
}
@Override
......
......@@ -1797,9 +1797,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
private long getTotalBufferedDurationUs(long bufferedPositionInLoadingPeriodUs) {
MediaPeriodHolder loadingPeriodHolder = queue.getLoadingPeriod();
return loadingPeriodHolder == null
? 0
: bufferedPositionInLoadingPeriodUs - loadingPeriodHolder.toPeriodTime(rendererPositionUs);
if (loadingPeriodHolder == null) {
return 0;
}
long totalBufferedDurationUs =
bufferedPositionInLoadingPeriodUs - loadingPeriodHolder.toPeriodTime(rendererPositionUs);
return Math.max(0, totalBufferedDurationUs);
}
private void updateLoadControlTrackSelection(
......
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