Bug 1302465: [MSE] Schedule eviction, even if previously the source buffer was full. r?gerald
Conditions may have changed (such as currentTime moving since the last attempt). So we try again.
MozReview-Commit-ID: 2zexl1FzOd7
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -282,27 +282,31 @@ TrackBuffersManager::EvictData(const Tim
return EvictDataResult::NO_DATA_EVICTED;
}
if (toEvict <= 512*1024) {
// Don't bother evicting less than 512KB.
mEvictionState = EvictionState::NO_EVICTION_NEEDED;
return EvictDataResult::CANT_EVICT;
}
- if (mBufferFull && mEvictionState == EvictionState::EVICTION_COMPLETED) {
- return EvictDataResult::BUFFER_FULL;
- }
+ EvictDataResult result;
- MSE_DEBUG("Reaching our size limit, schedule eviction of %lld bytes", toEvict);
-
- mEvictionState = EvictionState::EVICTION_NEEDED;
-
+ if (mBufferFull && mEvictionState == EvictionState::EVICTION_COMPLETED) {
+ // Our buffer is currently full. We will make another eviction attempt.
+ // However, the current appendBuffer will fail as we can't know ahead of
+ // time if the eviction will later succeed.
+ result = EvictDataResult::BUFFER_FULL;
+ } else {
+ mEvictionState = EvictionState::EVICTION_NEEDED;
+ result = EvictDataResult::NO_DATA_EVICTED;
+ }
+ MSE_DEBUG("Reached our size limit, schedule eviction of %lld bytes", toEvict);
QueueTask(new EvictDataTask(aPlaybackTime, toEvict));
- return EvictDataResult::NO_DATA_EVICTED;
+ return result;
}
TimeIntervals
TrackBuffersManager::Buffered()
{
MSE_DEBUG("");
// http://w3c.github.io/media-source/index.html#widl-SourceBuffer-buffered
// 2. Let highest end time be the largest track buffer ranges end time across all the track buffers managed by this SourceBuffer object.