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
This commit is contained in:
tonihei 2019-06-18 14:50:06 +01:00 committed by Oliver Woodman
parent e174d8a989
commit b89dc8fbfd
2 changed files with 7 additions and 4 deletions

View file

@ -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

View file

@ -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(