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
This commit is contained in:
hoangtc 2017-09-14 04:28:56 -07:00 committed by Oliver Woodman
parent 7d59383cc4
commit b3004ab1c3

View file

@ -1355,18 +1355,25 @@ import java.io.IOException;
} else if (!renderer.isCurrentStreamFinal()) {
TrackSelection newSelection = newTrackSelectorResult.selections.get(i);
boolean newRendererEnabled = newTrackSelectorResult.renderersEnabled[i];
boolean isNoSampleRenderer = rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE;
RendererConfiguration oldConfig = oldTrackSelectorResult.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
// 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);
renderer.replaceStream(formats, readingPeriodHolder.sampleStreams[i],
readingPeriodHolder.getRendererOffset());
} else {
// The renderer will be disabled when transitioning to playing the next period, either
// because there's no new selection or because a configuration change is required. Mark
// the SampleStream as final to play out any remaining data.
// The renderer will be disabled when transitioning to playing the next period, because
// there's no new selection, or because a configuration change is required, or because
// 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();
}
}