mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
A mini bit of Timeline simplification.
Pretty sure this does the same thing. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125581858
This commit is contained in:
parent
5eca669474
commit
3e6c0ced82
1 changed files with 9 additions and 14 deletions
|
|
@ -592,12 +592,11 @@ import java.util.ArrayList;
|
||||||
private final ArrayList<TrackStream> oldStreams;
|
private final ArrayList<TrackStream> oldStreams;
|
||||||
private final ArrayList<TrackSelection> newSelections;
|
private final ArrayList<TrackSelection> newSelections;
|
||||||
|
|
||||||
private int nextSourceIndex;
|
|
||||||
|
|
||||||
private Source playingSource;
|
private Source playingSource;
|
||||||
private Source readingSource;
|
private Source readingSource;
|
||||||
private Source bufferingSource;
|
private Source bufferingSource;
|
||||||
|
|
||||||
|
private int pendingSourceIndex;
|
||||||
private long playingSourceEndPositionUs;
|
private long playingSourceEndPositionUs;
|
||||||
private long bufferingSourceOffsetUs;
|
private long bufferingSourceOffsetUs;
|
||||||
|
|
||||||
|
|
@ -612,16 +611,15 @@ import java.util.ArrayList;
|
||||||
public void updateSources() throws ExoPlaybackException, IOException {
|
public void updateSources() throws ExoPlaybackException, IOException {
|
||||||
// TODO[playlists]: Let sample source providers invalidate sources that are already buffering.
|
// TODO[playlists]: Let sample source providers invalidate sources that are already buffering.
|
||||||
|
|
||||||
// Continue buffering the first source that is not yet buffered, if any.
|
|
||||||
int sourceCount = sampleSourceProvider.getSourceCount();
|
int sourceCount = sampleSourceProvider.getSourceCount();
|
||||||
if (bufferingSource == null || bufferingSource.isFullyBuffered()) {
|
if (bufferingSource == null || bufferingSource.isFullyBuffered()) {
|
||||||
if (sourceCount == SampleSourceProvider.UNKNOWN_SOURCE_COUNT
|
// Try and obtain the next source to start buffering.
|
||||||
|| nextSourceIndex < sourceCount) {
|
int sourceIndex = bufferingSource == null ? pendingSourceIndex : bufferingSource.index + 1;
|
||||||
// Create the next source and prepare to buffer it.
|
if (sourceCount == SampleSourceProvider.UNKNOWN_SOURCE_COUNT || sourceIndex < sourceCount) {
|
||||||
int index = nextSourceIndex++;
|
// Attempt to create the next source.
|
||||||
SampleSource sampleSource = sampleSourceProvider.createSource(index);
|
SampleSource sampleSource = sampleSourceProvider.createSource(sourceIndex);
|
||||||
if (sampleSource != null) {
|
if (sampleSource != null) {
|
||||||
Source newSource = new Source(sampleSource, index, renderers.length);
|
Source newSource = new Source(sampleSource, sourceIndex, renderers.length);
|
||||||
if (bufferingSource != null) {
|
if (bufferingSource != null) {
|
||||||
bufferingSource.nextSource = newSource;
|
bufferingSource.nextSource = newSource;
|
||||||
bufferingSourceOffsetUs += bufferingSource.sampleSource.getDurationUs();
|
bufferingSourceOffsetUs += bufferingSource.sampleSource.getDurationUs();
|
||||||
|
|
@ -734,7 +732,6 @@ import java.util.ArrayList;
|
||||||
setPlayingSource(newPlayingSource, sourceOffsetUs);
|
setPlayingSource(newPlayingSource, sourceOffsetUs);
|
||||||
bufferingSource = playingSource;
|
bufferingSource = playingSource;
|
||||||
bufferingSourceOffsetUs = sourceOffsetUs;
|
bufferingSourceOffsetUs = sourceOffsetUs;
|
||||||
nextSourceIndex = sourceIndex + 1;
|
|
||||||
} else {
|
} else {
|
||||||
// TODO[REFACTOR]: Presumably we need to disable the renderers somewhere in here?
|
// TODO[REFACTOR]: Presumably we need to disable the renderers somewhere in here?
|
||||||
playingSource = null;
|
playingSource = null;
|
||||||
|
|
@ -742,8 +739,7 @@ import java.util.ArrayList;
|
||||||
bufferingSource = null;
|
bufferingSource = null;
|
||||||
bufferingSourceOffsetUs = 0;
|
bufferingSourceOffsetUs = 0;
|
||||||
sampleSource = null;
|
sampleSource = null;
|
||||||
// Set the next source index so that the required source is created in updateSources.
|
pendingSourceIndex = sourceIndex;
|
||||||
nextSourceIndex = sourceIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sampleSource;
|
return sampleSource;
|
||||||
|
|
@ -780,7 +776,6 @@ import java.util.ArrayList;
|
||||||
playingSource.nextSource = null;
|
playingSource.nextSource = null;
|
||||||
readingSource = playingSource;
|
readingSource = playingSource;
|
||||||
bufferingSource = playingSource;
|
bufferingSource = playingSource;
|
||||||
nextSourceIndex = playingSource.index + 1;
|
|
||||||
playingSourceEndPositionUs = C.UNSET_TIME_US;
|
playingSourceEndPositionUs = C.UNSET_TIME_US;
|
||||||
bufferingSourceOffsetUs = sourceOffsetUs;
|
bufferingSourceOffsetUs = sourceOffsetUs;
|
||||||
|
|
||||||
|
|
@ -822,7 +817,7 @@ import java.util.ArrayList;
|
||||||
readingSource = null;
|
readingSource = null;
|
||||||
bufferingSource = null;
|
bufferingSource = null;
|
||||||
playingSourceEndPositionUs = C.UNSET_TIME_US;
|
playingSourceEndPositionUs = C.UNSET_TIME_US;
|
||||||
nextSourceIndex = 0;
|
pendingSourceIndex = 0;
|
||||||
sourceOffsetUs = 0;
|
sourceOffsetUs = 0;
|
||||||
bufferingSourceOffsetUs = 0;
|
bufferingSourceOffsetUs = 0;
|
||||||
playbackInfo = new PlaybackInfo(0);
|
playbackInfo = new PlaybackInfo(0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue