From 8a0a8339e84262e72594cfa192f190bbf60ffc10 Mon Sep 17 00:00:00 2001 From: tonihei Date: Tue, 5 Dec 2017 09:10:05 -0800 Subject: [PATCH] Change handling of renderer position offset for first media period. This should be a no-op change. And it eliminates the need to use the index variable which will be removed once the MediaPeriodHolderQueue is implemented. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=177963360 --- .../android/exoplayer2/ExoPlayerImplInternal.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 83e7858eaa..dd3ce136d6 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 @@ -1407,9 +1407,10 @@ import java.io.IOException; return; } - long rendererPositionOffsetUs = loadingPeriodHolder == null - ? RENDERER_TIMESTAMP_OFFSET_US - : (loadingPeriodHolder.getRendererOffset() + loadingPeriodHolder.info.durationUs); + long rendererPositionOffsetUs = + loadingPeriodHolder == null + ? (info.startPositionUs + RENDERER_TIMESTAMP_OFFSET_US) + : (loadingPeriodHolder.getRendererOffset() + loadingPeriodHolder.info.durationUs); int holderIndex = loadingPeriodHolder == null ? 0 : loadingPeriodHolder.index + 1; Object uid = playbackInfo.timeline.getPeriod(info.id.periodIndex, period, true).uid; MediaPeriodHolder newPeriodHolder = new MediaPeriodHolder(renderers, rendererCapabilities, @@ -1553,8 +1554,8 @@ import java.io.IOException; public final int index; public final SampleStream[] sampleStreams; public final boolean[] mayRetainStreamFlags; - public final long rendererPositionOffsetUs; + public long rendererPositionOffsetUs; public MediaPeriodInfo info; public boolean prepared; public boolean hasEnabledTracks; @@ -1574,7 +1575,7 @@ import java.io.IOException; MediaSource mediaSource, Object periodUid, int index, MediaPeriodInfo info) { this.renderers = renderers; this.rendererCapabilities = rendererCapabilities; - this.rendererPositionOffsetUs = rendererPositionOffsetUs; + this.rendererPositionOffsetUs = rendererPositionOffsetUs - info.startPositionUs; this.trackSelector = trackSelector; this.loadControl = loadControl; this.mediaSource = mediaSource; @@ -1601,8 +1602,7 @@ import java.io.IOException; } public long getRendererOffset() { - return index == 0 ? rendererPositionOffsetUs - : (rendererPositionOffsetUs - info.startPositionUs); + return rendererPositionOffsetUs; } public boolean isFullyBuffered() { @@ -1628,6 +1628,7 @@ import java.io.IOException; prepared = true; selectTracks(playbackSpeed); long newStartPositionUs = updatePeriodTrackSelection(info.startPositionUs, false); + rendererPositionOffsetUs += info.startPositionUs - newStartPositionUs; info = info.copyWithStartPositionUs(newStartPositionUs); }