Bug 1259916: [MSE] P1. Fix eviction. r?gerald
Bug 1216460 introduced a regression which would cause to always evict from both ends of the current track buffer.
MozReview-Commit-ID: 4f01tNQ2KU8
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -470,26 +470,27 @@ TrackBuffersManager::DoEvictData(const T
partialEvict = 0;
}
if (frame->mTime >= lowerLimit.ToMicroseconds()) {
break;
}
partialEvict += frame->ComputedSizeOfIncludingThis();
}
+ const int64_t finalSize = mSizeSourceBuffer - aSizeToEvict;
+
if (lastKeyFrameIndex > 0) {
MSE_DEBUG("Step1. Evicting %lld bytes prior currentTime",
aSizeToEvict - toEvict);
CodedFrameRemoval(
TimeInterval(TimeUnit::FromMicroseconds(0),
TimeUnit::FromMicroseconds(buffer[lastKeyFrameIndex]->mTime - 1)));
}
- const int64_t finalSize = mSizeSourceBuffer - aSizeToEvict;
- if (mSizeSourceBuffer <= finalSize || !buffer.Length()) {
+ if (mSizeSourceBuffer <= finalSize) {
return;
}
toEvict = mSizeSourceBuffer - finalSize;
// Still some to remove. Remove data starting from the end, up to 30s ahead
// of the later of the playback time or the next sample to be demuxed.
// 30s is a value chosen as it appears to work with YouTube.