Commit 8a0a8339 by tonihei Committed by Oliver Woodman

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
parent 88dea59c
...@@ -1407,9 +1407,10 @@ import java.io.IOException; ...@@ -1407,9 +1407,10 @@ import java.io.IOException;
return; return;
} }
long rendererPositionOffsetUs = loadingPeriodHolder == null long rendererPositionOffsetUs =
? RENDERER_TIMESTAMP_OFFSET_US loadingPeriodHolder == null
: (loadingPeriodHolder.getRendererOffset() + loadingPeriodHolder.info.durationUs); ? (info.startPositionUs + RENDERER_TIMESTAMP_OFFSET_US)
: (loadingPeriodHolder.getRendererOffset() + loadingPeriodHolder.info.durationUs);
int holderIndex = loadingPeriodHolder == null ? 0 : loadingPeriodHolder.index + 1; int holderIndex = loadingPeriodHolder == null ? 0 : loadingPeriodHolder.index + 1;
Object uid = playbackInfo.timeline.getPeriod(info.id.periodIndex, period, true).uid; Object uid = playbackInfo.timeline.getPeriod(info.id.periodIndex, period, true).uid;
MediaPeriodHolder newPeriodHolder = new MediaPeriodHolder(renderers, rendererCapabilities, MediaPeriodHolder newPeriodHolder = new MediaPeriodHolder(renderers, rendererCapabilities,
...@@ -1553,8 +1554,8 @@ import java.io.IOException; ...@@ -1553,8 +1554,8 @@ import java.io.IOException;
public final int index; public final int index;
public final SampleStream[] sampleStreams; public final SampleStream[] sampleStreams;
public final boolean[] mayRetainStreamFlags; public final boolean[] mayRetainStreamFlags;
public final long rendererPositionOffsetUs;
public long rendererPositionOffsetUs;
public MediaPeriodInfo info; public MediaPeriodInfo info;
public boolean prepared; public boolean prepared;
public boolean hasEnabledTracks; public boolean hasEnabledTracks;
...@@ -1574,7 +1575,7 @@ import java.io.IOException; ...@@ -1574,7 +1575,7 @@ import java.io.IOException;
MediaSource mediaSource, Object periodUid, int index, MediaPeriodInfo info) { MediaSource mediaSource, Object periodUid, int index, MediaPeriodInfo info) {
this.renderers = renderers; this.renderers = renderers;
this.rendererCapabilities = rendererCapabilities; this.rendererCapabilities = rendererCapabilities;
this.rendererPositionOffsetUs = rendererPositionOffsetUs; this.rendererPositionOffsetUs = rendererPositionOffsetUs - info.startPositionUs;
this.trackSelector = trackSelector; this.trackSelector = trackSelector;
this.loadControl = loadControl; this.loadControl = loadControl;
this.mediaSource = mediaSource; this.mediaSource = mediaSource;
...@@ -1601,8 +1602,7 @@ import java.io.IOException; ...@@ -1601,8 +1602,7 @@ import java.io.IOException;
} }
public long getRendererOffset() { public long getRendererOffset() {
return index == 0 ? rendererPositionOffsetUs return rendererPositionOffsetUs;
: (rendererPositionOffsetUs - info.startPositionUs);
} }
public boolean isFullyBuffered() { public boolean isFullyBuffered() {
...@@ -1628,6 +1628,7 @@ import java.io.IOException; ...@@ -1628,6 +1628,7 @@ import java.io.IOException;
prepared = true; prepared = true;
selectTracks(playbackSpeed); selectTracks(playbackSpeed);
long newStartPositionUs = updatePeriodTrackSelection(info.startPositionUs, false); long newStartPositionUs = updatePeriodTrackSelection(info.startPositionUs, false);
rendererPositionOffsetUs += info.startPositionUs - newStartPositionUs;
info = info.copyWithStartPositionUs(newStartPositionUs); info = info.copyWithStartPositionUs(newStartPositionUs);
} }
......
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