Commit b3004ab1 by hoangtc Committed by Oliver Woodman

Do not apply SampleStream skip-ahead for NoSampleRenderer.

Currently, to make transition to next media period seamless, after the renderer
has read until the end of the current SampleStream, we may send it the next
SampleStream so the renderer may read from the next SampleStream ahead of the
transition.
For NoSampleRenderer, we should avoid doing this: skipping ahead for such
renderer doesn't have any benefit (the renderer does not consume data from
SampleStream), and it will change the provided rendererOffsetUs while the
renderer is still rendering from the playing media period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168669800
parent 7d59383c
...@@ -1355,18 +1355,25 @@ import java.io.IOException; ...@@ -1355,18 +1355,25 @@ import java.io.IOException;
} else if (!renderer.isCurrentStreamFinal()) { } else if (!renderer.isCurrentStreamFinal()) {
TrackSelection newSelection = newTrackSelectorResult.selections.get(i); TrackSelection newSelection = newTrackSelectorResult.selections.get(i);
boolean newRendererEnabled = newTrackSelectorResult.renderersEnabled[i]; boolean newRendererEnabled = newTrackSelectorResult.renderersEnabled[i];
boolean isNoSampleRenderer = rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE;
RendererConfiguration oldConfig = oldTrackSelectorResult.rendererConfigurations[i]; RendererConfiguration oldConfig = oldTrackSelectorResult.rendererConfigurations[i];
RendererConfiguration newConfig = newTrackSelectorResult.rendererConfigurations[i]; RendererConfiguration newConfig = newTrackSelectorResult.rendererConfigurations[i];
if (newRendererEnabled && newConfig.equals(oldConfig)) { if (newRendererEnabled && newConfig.equals(oldConfig) && !isNoSampleRenderer) {
// Replace the renderer's SampleStream so the transition to playing the next period can // Replace the renderer's SampleStream so the transition to playing the next period can
// be seamless. // be seamless.
// This should be avoided for no-sample renderer, because skipping ahead for such
// renderer doesn't have any benefit (the renderer does not consume the sample stream),
// and it will change the provided rendererOffsetUs while the renderer is still
// rendering from the playing media period.
Format[] formats = getFormats(newSelection); Format[] formats = getFormats(newSelection);
renderer.replaceStream(formats, readingPeriodHolder.sampleStreams[i], renderer.replaceStream(formats, readingPeriodHolder.sampleStreams[i],
readingPeriodHolder.getRendererOffset()); readingPeriodHolder.getRendererOffset());
} else { } else {
// The renderer will be disabled when transitioning to playing the next period, either // The renderer will be disabled when transitioning to playing the next period, because
// because there's no new selection or because a configuration change is required. Mark // there's no new selection, or because a configuration change is required, or because
// the SampleStream as final to play out any remaining data. // it's a no-sample renderer for which rendererOffsetUs should be updated only when
// starting to play the next period. Mark the SampleStream as final to play out any
// remaining data.
renderer.setCurrentStreamFinal(); renderer.setCurrentStreamFinal();
} }
} }
......
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