Commit 706d4e51 by andrewlewis Committed by Oliver Woodman

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
parent 508db5fd
...@@ -1326,7 +1326,7 @@ import java.io.IOException; ...@@ -1326,7 +1326,7 @@ import java.io.IOException;
} }
long rendererPositionOffsetUs = loadingPeriodHolder == null long rendererPositionOffsetUs = loadingPeriodHolder == null
? (info.startPositionUs + RENDERER_TIMESTAMP_OFFSET_US) ? RENDERER_TIMESTAMP_OFFSET_US
: (loadingPeriodHolder.getRendererOffset() + loadingPeriodHolder.info.durationUs); : (loadingPeriodHolder.getRendererOffset() + loadingPeriodHolder.info.durationUs);
int holderIndex = loadingPeriodHolder == null ? 0 : loadingPeriodHolder.index + 1; int holderIndex = loadingPeriodHolder == null ? 0 : loadingPeriodHolder.index + 1;
Object uid = timeline.getPeriod(info.id.periodIndex, period, true).uid; Object uid = timeline.getPeriod(info.id.periodIndex, period, true).uid;
...@@ -1515,7 +1515,8 @@ import java.io.IOException; ...@@ -1515,7 +1515,8 @@ import java.io.IOException;
} }
public long getRendererOffset() { public long getRendererOffset() {
return rendererPositionOffsetUs - info.startPositionUs; return index == 0 ? rendererPositionOffsetUs
: (rendererPositionOffsetUs - info.startPositionUs);
} }
public boolean isFullyBuffered() { public boolean isFullyBuffered() {
......
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