Bug 998284. When entering the buffering state from AdvanceFrame, be prepared to accept a second's delay before reevaluating whether to exit buffering. r=cpearce
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 25 Mar 2014 00:58:11 +1300
changeset 179966 8c7e0c36f4eaf5e762724357c11ca89aab3255a2
parent 179965 0920db1ab388e4a6f32a9cdb49d769988ded3d0c
child 179967 17e6827f48e0172b55c255be50e88084c16afc35
push idunknown
push userunknown
push dateunknown
reviewerscpearce
bugs998284
milestone31.0a1
Bug 998284. When entering the buffering state from AdvanceFrame, be prepared to accept a second's delay before reevaluating whether to exit buffering. r=cpearce
content/media/MediaDecoderStateMachine.cpp
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -2461,17 +2461,20 @@ void MediaDecoderStateMachine::AdvanceFr
       HasLowDecodedData(remainingTime + EXHAUSTED_DATA_MARGIN_USECS) &&
       !mDecoder->IsDataCachedToEndOfResource() &&
       !resource->IsSuspended()) {
     if (JustExitedQuickBuffering() || HasLowUndecodedData()) {
       if (currentFrame) {
         mReader->VideoQueue().PushFront(currentFrame.forget());
       }
       StartBuffering();
-      ScheduleStateMachine();
+      // Don't go straight back to the state machine loop since that might
+      // cause us to start decoding again and we could flip-flop between
+      // decoding and quick-buffering.
+      ScheduleStateMachine(USECS_PER_S);
       return;
     }
   }
 
   // We've got enough data to keep playing until at least the next frame.
   // Start playing now if need be.
   if (!IsPlaying() && ((mFragmentEndTime >= 0 && clock_time < mFragmentEndTime) || mFragmentEndTime < 0)) {
     StartPlayback();