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
This commit is contained in:
andrewlewis 2017-07-17 03:00:30 -07:00 committed by Oliver Woodman
parent 508db5fd0a
commit 706d4e51fe

View file

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