Bug 1307725. Part 2 - handle prerolling in DecodingState::HandleEndOfStream() and move it to the public section. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 05 Oct 2016 17:07:55 +0800
changeset 424554 fd62e26f42a984f365dbadd3114a0cb0fb2ede63
parent 424553 db74bde6884f233caeab8d0c19fbca9756f984b1
child 424555 6c48a571f2a55a86b5df380def8834e04f96f07b
push id32190
push userjwwang@mozilla.com
push dateThu, 13 Oct 2016 01:42:53 +0000
bugs1307725
milestone52.0a1
Bug 1307725. Part 2 - handle prerolling in DecodingState::HandleEndOfStream() and move it to the public section. MozReview-Commit-ID: DMlLV8KLXvQ
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -630,16 +630,26 @@ public:
     SLOG("Changed state to SEEKING (to %lld)", aTarget.GetTime().ToMicroseconds());
     SeekJob seekJob;
     seekJob.mTarget = aTarget;
     RefPtr<MediaDecoder::SeekPromise> p = seekJob.mPromise.Ensure(__func__);
     mMaster->InitiateSeek(Move(seekJob));
     return p.forget();
   }
 
+  bool HandleEndOfStream() override
+  {
+    if (mMaster->CheckIfDecodeComplete()) {
+      SetState(DECODER_STATE_COMPLETED);
+    } else {
+      mMaster->MaybeStopPrerolling();
+    }
+    return true;
+  }
+
   bool HandleAudioCaptured() override
   {
     mMaster->MaybeStopPrerolling();
     // MediaSink is changed. Schedule Step() to check if we can start playback.
     mMaster->ScheduleStateMachine();
     return true;
   }
 
@@ -670,24 +680,16 @@ private:
       SLOG("Slow video decode, set "
            "mLowAudioThresholdUsecs=%lld "
            "mAmpleAudioThresholdUsecs=%lld",
            mMaster->mLowAudioThresholdUsecs,
            mMaster->mAmpleAudioThresholdUsecs);
     }
   }
 
-  bool HandleEndOfStream() override
-  {
-    if (mMaster->CheckIfDecodeComplete()) {
-      SetState(DECODER_STATE_COMPLETED);
-    }
-    return true;
-  }
-
   // Time at which we started decoding.
   TimeStamp mDecodeStartTime;
 };
 
 class MediaDecoderStateMachine::SeekingState
   : public MediaDecoderStateMachine::StateObject
 {
 public:
@@ -1589,18 +1591,16 @@ MediaDecoderStateMachine::OnNotDecoded(M
   // This is an EOS. Finish off the queue, and then handle things based on our
   // state.
   if (isAudio) {
     AudioQueue().Finish();
   } else {
     VideoQueue().Finish();
   }
 
-  MaybeStopPrerolling();
-
   mStateObj->HandleEndOfStream();
 }
 
 void
 MediaDecoderStateMachine::OnVideoDecoded(MediaData* aVideo,
                                          TimeStamp aDecodeStartTime)
 {
   MOZ_ASSERT(OnTaskQueue());