mirror of
https://github.com/samsonjs/media.git
synced 2026-04-01 10:35:48 +00:00
Limit the maximum number of sources to buffer.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125698923
This commit is contained in:
parent
aa313f234d
commit
6031f89fe9
1 changed files with 10 additions and 4 deletions
|
|
@ -82,6 +82,13 @@ import java.util.ArrayList;
|
|||
private static final int RENDERING_INTERVAL_MS = 10;
|
||||
private static final int IDLE_INTERVAL_MS = 1000;
|
||||
|
||||
/**
|
||||
* Limits the maximum number of sources to buffer ahead of the current source in the timeline. The
|
||||
* source buffering policy normally prevents buffering too far ahead, but the policy could allow
|
||||
* too many very small sources to be buffered if the buffered source count were not limited.
|
||||
*/
|
||||
private static final int MAXIMUM_BUFFER_AHEAD_SOURCES = 100;
|
||||
|
||||
private final TrackSelector trackSelector;
|
||||
private final StandaloneMediaClock standaloneMediaClock;
|
||||
private final long minBufferUs;
|
||||
|
|
@ -601,10 +608,9 @@ import java.util.ArrayList;
|
|||
// TODO[playlists]: Let sample source providers invalidate sources that are already buffering.
|
||||
|
||||
int sourceCount = sampleSourceProvider.getSourceCount();
|
||||
// TODO: There should probably be some kind of read ahead limit here to prevent the number of
|
||||
// sources between the playing source and the buffering source from growing excessively large
|
||||
// (e.g. >100)?
|
||||
if (bufferingSource == null || bufferingSource.isFullyBuffered()) {
|
||||
if (bufferingSource == null
|
||||
|| (bufferingSource.isFullyBuffered() && bufferingSource.index
|
||||
- (playingSource != null ? playingSource.index : 0) < MAXIMUM_BUFFER_AHEAD_SOURCES)) {
|
||||
// Try and obtain the next source to start buffering.
|
||||
int sourceIndex = bufferingSource == null ? pendingSourceIndex : bufferingSource.index + 1;
|
||||
if (sourceCount == SampleSourceProvider.UNKNOWN_SOURCE_COUNT || sourceIndex < sourceCount) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue