mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Set TrackStreams to be final on renderers that will be disabled.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125691172
This commit is contained in:
parent
494510d6ad
commit
aa313f234d
@ -681,21 +681,26 @@ import java.util.ArrayList;
|
||||
playingSourceEndPositionUs = C.UNSET_TIME_US;
|
||||
} else if (playingSource.nextSource != null && playingSource.nextSource.prepared) {
|
||||
readingSource = playingSource.nextSource;
|
||||
// Replace enabled renderers' TrackStreams if they will continue to be enabled when the
|
||||
// new source starts playing, so that the transition can be seamless.
|
||||
TrackSelectionArray newTrackSelections = readingSource.trackSelections;
|
||||
TrackGroupArray groups = readingSource.sampleSource.getTrackGroups();
|
||||
for (int i = 0; i < renderers.length; i++) {
|
||||
TrackRenderer renderer = renderers[i];
|
||||
TrackSelection selection = newTrackSelections.get(i);
|
||||
if (selection != null && renderer.getState() != TrackRenderer.STATE_DISABLED) {
|
||||
// The renderer is enabled and will continue to be enabled after the transition.
|
||||
Format[] formats = new Format[selection.length];
|
||||
for (int j = 0; j < formats.length; j++) {
|
||||
formats[j] = groups.get(selection.group).getFormat(selection.getTrack(j));
|
||||
if (renderer.getState() != TrackRenderer.STATE_DISABLED) {
|
||||
if (selection != null) {
|
||||
// Replace the renderer's TrackStream so the transition to playing the next source can
|
||||
// be seamless.
|
||||
Format[] formats = new Format[selection.length];
|
||||
for (int j = 0; j < formats.length; j++) {
|
||||
formats[j] = groups.get(selection.group).getFormat(selection.getTrack(j));
|
||||
}
|
||||
renderer.replaceTrackStream(formats, readingSource.trackStreams[i],
|
||||
playingSourceEndPositionUs);
|
||||
} else {
|
||||
// The renderer will be disabled when transitioning to playing the next source. Send
|
||||
// end-of-stream to play out any remaining data.
|
||||
renderer.setCurrentTrackStreamIsFinal();
|
||||
}
|
||||
renderer.replaceTrackStream(formats, readingSource.trackStreams[i],
|
||||
playingSourceEndPositionUs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user