Bug 1136576 - Properly align source buffer starts with current decoder. r=cajbir, a=lsblakk
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 25 Feb 2015 20:55:14 +1100
changeset 250093 5a0ed5076b4f
parent 250092 4fc445cb5642
child 250094 432de8008403
push id4501
push userryanvm@gmail.com
push date2015-02-27 20:57 +0000
treeherdermozilla-beta@2aa1ca037446 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir, lsblakk
bugs1136576
milestone37.0
Bug 1136576 - Properly align source buffer starts with current decoder. r=cajbir, a=lsblakk
dom/media/mediasource/TrackBuffer.cpp
--- a/dom/media/mediasource/TrackBuffer.cpp
+++ b/dom/media/mediasource/TrackBuffer.cpp
@@ -410,19 +410,25 @@ TrackBuffer::EvictData(double aPlaybackT
               aPlaybackTime, decoders[i]->GetResource()->GetSize());
     toEvict -= decoders[i]->GetResource()->EvictAll();
   }
 
   RemoveEmptyDecoders(decoders);
 
   bool evicted = toEvict < (totalSize - aThreshold);
   if (evicted) {
-    nsRefPtr<dom::TimeRanges> ranges = new dom::TimeRanges();
-    mCurrentDecoder->GetBuffered(ranges);
-    *aBufferStartTime = std::max(0.0, ranges->GetStartTime());
+    if (playingDecoder) {
+      nsRefPtr<dom::TimeRanges> ranges = new dom::TimeRanges();
+      playingDecoder->GetBuffered(ranges);
+      *aBufferStartTime = std::max(0.0, ranges->GetStartTime());
+    } else {
+      // We do not currently have data to play yet.
+      // Avoid evicting anymore data to minimize rebuffering time.
+      *aBufferStartTime = 0.0;
+    }
   }
 
   return evicted;
 }
 
 void
 TrackBuffer::RemoveEmptyDecoders(nsTArray<mozilla::SourceBufferDecoder*>& aDecoders)
 {