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 262185 4338ca9969349061833b98a8277b9ff49579f8b6
parent 262184 884b4f4c4d6798c39ea19727218956c53aa39c54
child 262186 5bb976753d27ccc441eb2d8f49a412808c58973e
push id1963
push userpaolo.mozmail@amadzone.org
push dateSun, 10 May 2015 10:26:20 +0000
reviewerscajbir, lsblakk
bugs1136576
milestone38.0a2
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
@@ -422,19 +422,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)
 {