Bug 1310140. Part 10 - have SeekingState handle suspend-video-decoding. r=kaku,kamidphish
authorJW Wang <jwwang@mozilla.com>
Tue, 18 Oct 2016 11:11:38 +0800
changeset 318574 df85afebba7bc35630e69357c685129b9646acba
parent 318573 d2870b4ff3d0fa374cb30144dd22cc318b86ee31
child 318575 6b99ecc25e0ae2296729747bef071dfb6168b863
push id82960
push usercbook@mozilla.com
push dateWed, 19 Oct 2016 15:04:04 +0000
treeherdermozilla-inbound@c48c53e3492e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku, kamidphish
bugs1310140
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1310140. Part 10 - have SeekingState handle suspend-video-decoding. r=kaku,kamidphish MozReview-Commit-ID: DRGfP3VN2OG
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -624,16 +624,25 @@ class MediaDecoderStateMachine::SeekingS
 {
 public:
   explicit SeekingState(Master* aPtr) : StateObject(aPtr) {}
 
   RefPtr<MediaDecoder::SeekPromise> Enter(SeekJob aSeekJob)
   {
     mSeekJob = Move(aSeekJob);
 
+    // Always switch off the blank decoder otherwise we might become visible
+    // in the middle of seeking and won't have a valid video frame to show
+    // when seek is done.
+    if (mMaster->mVideoDecodeSuspended) {
+      mMaster->mVideoDecodeSuspended = false;
+      mMaster->mOnPlaybackEvent.Notify(MediaEventType::ExitVideoSuspend);
+      Reader()->SetVideoBlankDecode(false);
+    }
+
     // SeekTask will register its callbacks to MediaDecoderReaderWrapper.
     mMaster->CancelMediaDecoderReaderWrapperCallback();
 
     // Create a new SeekTask instance for the incoming seek task.
     if (mSeekJob.mTarget.IsAccurate() ||
         mSeekJob.mTarget.IsFast()) {
       mSeekTask = new AccurateSeekTask(
         mMaster->mDecoderID, OwnerThread(), Reader(), mSeekJob.mTarget,
@@ -713,16 +722,21 @@ public:
   bool HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override
   {
     MOZ_ASSERT(false);
     return true;
   }
 
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override;
 
+  void HandleVideoSuspendTimeout() override
+  {
+    // Do nothing since we want a valid video frame to show when seek is done.
+  }
+
 private:
   void OnSeekTaskResolved(const SeekTaskResolveValue& aValue)
   {
     mSeekTaskRequest.Complete();
 
     if (aValue.mSeekedAudioData) {
       mMaster->Push(aValue.mSeekedAudioData, MediaData::AUDIO_DATA);
       mMaster->mDecodedAudioEndTime = std::max(
@@ -2323,19 +2337,16 @@ void MediaDecoderStateMachine::Visibilit
   }
 
   // Resuming from suspended decoding
 
   // If suspend timer exists, destroy it.
   mVideoDecodeSuspendTimer.Reset();
 
   if (mVideoDecodeSuspended) {
-    mVideoDecodeSuspended = false;
-    mOnPlaybackEvent.Notify(MediaEventType::ExitVideoSuspend);
-    mReader->SetVideoBlankDecode(false);
 
     if (mIsReaderSuspended) {
       return;
     }
 
     // If an existing seek is in flight don't bother creating a new
     // one to catch up.
     if (mState == DECODER_STATE_SEEKING || mQueuedSeek.Exists()) {