Bug 1298217. Part 6 - Move some code to the entry action of DECODER_STATE_COMPLETED. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 26 Aug 2016 06:25:15 +1200
changeset 406599 7d4ec09265558221cd8a4bfa14168fe8df965988
parent 406598 1402d7f069af0b835827563b6745af93ec9fe4df
child 406600 7ffcbf4ca19705722bacfa2a534094463c240818
push id27772
push userjwwang@mozilla.com
push dateMon, 29 Aug 2016 06:35:00 +0000
bugs1298217
milestone51.0a1
Bug 1298217. Part 6 - Move some code to the entry action of DECODER_STATE_COMPLETED. MozReview-Commit-ID: 5hf3NV5uLvS
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -711,17 +711,16 @@ MediaDecoderStateMachine::OnNotDecoded(M
   switch (mState) {
     case DECODER_STATE_BUFFERING:
     case DECODER_STATE_DECODING: {
       if (MaybeFinishDecodeFirstFrame()) {
         return;
       }
       if (CheckIfDecodeComplete()) {
         SetState(DECODER_STATE_COMPLETED);
-        ScheduleStateMachine();
         return;
       }
       // Schedule next cycle to see if we can leave buffering state.
       if (mState == DECODER_STATE_BUFFERING) {
         ScheduleStateMachine();
       }
       return;
     }
@@ -1091,16 +1090,19 @@ MediaDecoderStateMachine::EnterState(Sta
     case DECODER_STATE_DORMANT:
       DiscardSeekTaskIfExist();
       if (IsPlaying()) {
         StopPlayback();
       }
       Reset();
       mReader->ReleaseResources();
       break;
+    case DECODER_STATE_COMPLETED:
+      ScheduleStateMachine();
+      break;
     case DECODER_STATE_ERROR:
     case DECODER_STATE_SHUTDOWN:
       mIsShutdown = true;
       break;
     default:
       break;
   }
 }
@@ -1274,17 +1276,16 @@ void MediaDecoderStateMachine::StartDeco
     if (mQueuedSeek.Exists()) {
       InitiateSeek(Move(mQueuedSeek));
       return;
     }
   }
 
   if (CheckIfDecodeComplete()) {
     SetState(DECODER_STATE_COMPLETED);
-    ScheduleStateMachine();
     return;
   }
 
   mDecodeStartTime = TimeStamp::Now();
 
   // Reset other state to pristine values before starting decode.
   mIsAudioPrerolling = !DonePrerollingAudio() && !mReader->IsWaitingAudioData();
   mIsVideoPrerolling = !DonePrerollingVideo() && !mReader->IsWaitingVideoData();