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 243784 bbd9460d9987
parent 243783 4f90bd0f1348
child 243785 7f4a993f3336
push id4478
push userryanvm@gmail.com
push date2015-02-17 14:44 +0000
treeherdermozilla-beta@8597521cb8bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, sledru
bugs1126723
milestone36.0
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
@@ -2075,16 +2075,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;
   }