Bug 1259916: [MSE] P1. Fix eviction. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 28 Mar 2016 00:41:31 +1100
changeset 345013 52e23ec8be9d9edacef87fe971e79ad0092bdee1
parent 345012 fddcab862b473128b1c7cb44b084c9668e2b655a
child 345014 354e7cb57c14ef8e2c5ba06d0f07b17915c4e341
push id13994
push userbmo:jyavenard@mozilla.com
push dateSun, 27 Mar 2016 14:00:13 +0000
reviewersgerald
bugs1259916, 1216460
milestone48.0a1
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
dom/media/mediasource/TrackBuffersManager.cpp
--- 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.