Commit 6ef8c3a6 by Oliver Woodman

Avoid loading the first HLS segment twice.

Issue: #788
parent 8a723706
...@@ -191,14 +191,23 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader, ...@@ -191,14 +191,23 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
downstreamMediaFormats[track] = null; downstreamMediaFormats[track] = null;
pendingDiscontinuities[track] = false; pendingDiscontinuities[track] = false;
downstreamFormat = null; downstreamFormat = null;
boolean wasLoadControlRegistered = loadControlRegistered;
if (!loadControlRegistered) { if (!loadControlRegistered) {
loadControl.register(this, bufferSizeContribution); loadControl.register(this, bufferSizeContribution);
loadControlRegistered = true; loadControlRegistered = true;
} }
if (enabledTrackCount == 1) { if (enabledTrackCount == 1) {
downstreamPositionUs = positionUs;
lastSeekPositionUs = positionUs; lastSeekPositionUs = positionUs;
restartFrom(positionUs); if (wasLoadControlRegistered && downstreamPositionUs == positionUs) {
// TODO: Address [Internal: b/21743989] to remove the need for this kind of hack.
// This is the first track to be enabled after preparation and the position is the same as
// was passed to prepare. In this case we can avoid restarting, which would reload the same
// chunks as were loaded during preparation.
maybeStartLoading();
} else {
downstreamPositionUs = positionUs;
restartFrom(positionUs);
}
} }
} }
......
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