Bug 1324371. Part 4 - assert NeedMoreVideo() in some functions. r?kaku draft
authorJW Wang <jwwang@mozilla.com>
Mon, 19 Dec 2016 17:18:03 +0800
changeset 451474 20576875dc3a50170fdb6081d4ec4e9d698bff8a
parent 451473 0254b1fe43dab26dcc5eb003304eef724cc30e64
child 451475 536df1369e59f78e656b1dbbb6f8f50ac21dceb0
push id39197
push userjwwang@mozilla.com
push dateTue, 20 Dec 2016 12:45:19 +0000
reviewerskaku
bugs1324371
milestone53.0a1
Bug 1324371. Part 4 - assert NeedMoreVideo() in some functions. r?kaku Because !mSeekJob.mPromise.IsEmpty() now always implies NeedMoreVideo(). MozReview-Commit-ID: BN0NZzaBlCF
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1330,32 +1330,32 @@ private:
   {
     mMaster->Push(aAudio);
   }
 
   void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override
   {
     MOZ_ASSERT(aVideo);
     MOZ_ASSERT(!mSeekJob.mPromise.IsEmpty(), "Seek shouldn't be finished");
+    MOZ_ASSERT(NeedMoreVideo());
 
     if (aVideo->mTime > mCurrentTime) {
       mMaster->Push(aVideo);
-    }
-
-    if (NeedMoreVideo()) {
+    } else {
       RequestVideoData();
       return;
     }
 
     MaybeFinishSeek();
   }
 
   void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override
   {
     MOZ_ASSERT(!mSeekJob.mPromise.IsEmpty(), "Seek shouldn't be finished");
+    MOZ_ASSERT(NeedMoreVideo());
 
     switch (aType) {
     case MediaData::AUDIO_DATA:
     {
       // We don't care about audio decode errors in this state which will be
       // handled by other states after seeking.
       break;
     }
@@ -1396,42 +1396,35 @@ private:
   void HandleAudioWaited(MediaData::Type aType) override
   {
     // We don't care about audio in this state.
   }
 
   void HandleVideoWaited(MediaData::Type aType) override
   {
     MOZ_ASSERT(!mSeekJob.mPromise.IsEmpty(), "Seek shouldn't be finished");
-
-    if (NeedMoreVideo()) {
-      RequestVideoData();
-      return;
-    }
-    MaybeFinishSeek();
+    MOZ_ASSERT(NeedMoreVideo());
+    RequestVideoData();
   }
 
   void HandleNotWaited(const WaitForDataRejectValue& aRejection) override
   {
     MOZ_ASSERT(!mSeekJob.mPromise.IsEmpty(), "Seek shouldn't be finished");
+    MOZ_ASSERT(NeedMoreVideo());
 
     switch(aRejection.mType) {
     case MediaData::AUDIO_DATA:
     {
       // We don't care about audio in this state.
       break;
     }
     case MediaData::VIDEO_DATA:
     {
-      if (NeedMoreVideo()) {
-        // Error out if we can't finish video seeking.
-        mMaster->DecodeError(NS_ERROR_DOM_MEDIA_CANCELED);
-        return;
-      }
-      MaybeFinishSeek();
+      // Error out if we can't finish video seeking.
+      mMaster->DecodeError(NS_ERROR_DOM_MEDIA_CANCELED);
       break;
     }
     default:
       MOZ_ASSERT_UNREACHABLE("We cannot handle RAW_DATA or NULL_DATA here.");
     }
   }
 
   int64_t CalculateNewCurrentTime() const override