Bug 1126723 - Bail out of HasLowUndecodedData if we don't have a duration. r=cpearce, a=sledru
authorBobby Holley <bobbyholley@gmail.com>
Thu, 12 Feb 2015 10:48:14 -0800
changeset 249752 0e0c3bcaeb0e9f3fa42c60a3eb844bf9991ed849
parent 249751 1220d2300693e85b9db663d35d4742326a2c6ab7
child 249753 041646b83f9339048724144078d64ca610672e8b
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, sledru
bugs1126723
milestone37.0a2
Bug 1126723 - Bail out of HasLowUndecodedData if we don't have a duration. r=cpearce, a=sledru GetEstimatedBufferedTimeRanges returns an empty range if the duration is -1.
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2118,16 +2118,23 @@ bool MediaDecoderStateMachine::HasLowUnd
 }
 
 bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
 {
   AssertCurrentThreadInMonitor();
   NS_ASSERTION(mState > DECODER_STATE_DECODING_FIRSTFRAME,
                "Must have loaded first frame for GetBuffered() to work");
 
+  // If we don't have a duration, GetBuffered is probably not going to produce
+  // a useful buffered range. Return false here so that we don't get stuck in
+  // buffering mode for live streams.
+  if (GetDuration() < 0) {
+    return false;
+  }
+
   nsRefPtr<dom::TimeRanges> buffered = new dom::TimeRanges();
   nsresult rv = mReader->GetBuffered(buffered.get());
   NS_ENSURE_SUCCESS(rv, false);
 
   int64_t endOfDecodedVideoData = INT64_MAX;
   if (HasVideo() && !VideoQueue().AtEndOfStream()) {
     endOfDecodedVideoData = VideoQueue().Peek() ? VideoQueue().Peek()->GetEndTime() : mVideoFrameEndTime;
   }