From 706d4e51fedcd8fd6450888a590fd27cee959b96 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Mon, 17 Jul 2017 03:00:30 -0700 Subject: [PATCH] Don't offset the first period holder by the start position If seek is called for a non-seekable period, when the period is prepared the start position will be updated from the seek position to zero. Because the start position is part of the renderer offset for the first loaded period holder, after the update the renderer offset start position and the new start position would no longer cancel out, leading to the player position being negative. The first period holder's renderer offset is the fixed base offset (60 seconds) plus its start position, but the start position is always subtracted. Avoid subtracting the start position for the first period holder so that when it changes there is no need to update the renderer offset. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=162188133 --- .../com/google/android/exoplayer2/ExoPlayerImplInternal.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java index 7d92a6a85c..8d9720b291 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java @@ -1326,7 +1326,7 @@ import java.io.IOException; } long rendererPositionOffsetUs = loadingPeriodHolder == null - ? (info.startPositionUs + RENDERER_TIMESTAMP_OFFSET_US) + ? RENDERER_TIMESTAMP_OFFSET_US : (loadingPeriodHolder.getRendererOffset() + loadingPeriodHolder.info.durationUs); int holderIndex = loadingPeriodHolder == null ? 0 : loadingPeriodHolder.index + 1; Object uid = timeline.getPeriod(info.id.periodIndex, period, true).uid; @@ -1515,7 +1515,8 @@ import java.io.IOException; } public long getRendererOffset() { - return rendererPositionOffsetUs - info.startPositionUs; + return index == 0 ? rendererPositionOffsetUs + : (rendererPositionOffsetUs - info.startPositionUs); } public boolean isFullyBuffered() {