mirror of
https://github.com/samsonjs/media.git
synced 2026-04-02 10:45:51 +00:00
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:
parent
e174d8a989
commit
b89dc8fbfd
2 changed files with 7 additions and 4 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue