Bug 1307725. Part 8 - move DonePrerolling{Audio,Video} into DecodingState. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 05 Oct 2016 17:40:01 +0800
changeset 424560 1856f7181503742d9bcbe48b919501a93c90d113
parent 424559 1d1c21c75023785a5004530e8df8810348a025f0
child 424562 264f163758d75bb18622cc2fbc7b59d96514d89c
push id32190
push userjwwang@mozilla.com
push dateThu, 13 Oct 2016 01:42:53 +0000
bugs1307725
milestone52.0a1
Bug 1307725. Part 8 - move DonePrerolling{Audio,Video} into DecodingState. MozReview-Commit-ID: I173Qo7hH9X
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -697,21 +697,35 @@ private:
       SLOG("Slow video decode, set "
            "mLowAudioThresholdUsecs=%lld "
            "mAmpleAudioThresholdUsecs=%lld",
            mMaster->mLowAudioThresholdUsecs,
            mMaster->mAmpleAudioThresholdUsecs);
     }
   }
 
+  bool DonePrerollingAudio()
+  {
+    return !mMaster->IsAudioDecoding() ||
+           mMaster->GetDecodedAudioDuration() >=
+             mMaster->AudioPrerollUsecs() * mMaster->mPlaybackRate;
+  }
+
+  bool DonePrerollingVideo()
+  {
+    return !mMaster->IsVideoDecoding() ||
+           static_cast<uint32_t>(mMaster->VideoQueue().GetSize()) >=
+             mMaster->VideoPrerollFrames() * mMaster->mPlaybackRate + 1;
+  }
+
   void MaybeStopPrerolling()
   {
     if (mIsPrerolling &&
-        (mMaster->DonePrerollingAudio() || Reader()->IsWaitingAudioData()) &&
-        (mMaster->DonePrerollingVideo() || Reader()->IsWaitingVideoData())) {
+        (DonePrerollingAudio() || Reader()->IsWaitingAudioData()) &&
+        (DonePrerollingVideo() || Reader()->IsWaitingVideoData())) {
       mIsPrerolling = false;
       // Check if we can start playback.
       mMaster->ScheduleStateMachine();
     }
   }
 
   // Time at which we started decoding.
   TimeStamp mDecodeStartTime;
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -672,31 +672,16 @@ private:
   }
 
   uint32_t VideoPrerollFrames() const
   {
     MOZ_ASSERT(OnTaskQueue());
     return GetAmpleVideoFrames() / 2;
   }
 
-  bool DonePrerollingAudio()
-  {
-    MOZ_ASSERT(OnTaskQueue());
-    return !IsAudioDecoding() ||
-        GetDecodedAudioDuration() >= AudioPrerollUsecs() * mPlaybackRate;
-  }
-
-  bool DonePrerollingVideo()
-  {
-    MOZ_ASSERT(OnTaskQueue());
-    return !IsVideoDecoding() ||
-        static_cast<uint32_t>(VideoQueue().GetSize()) >=
-            VideoPrerollFrames() * mPlaybackRate + 1;
-  }
-
   // Only one of a given pair of ({Audio,Video}DataPromise, WaitForDataPromise)
   // should exist at any given moment.
 
   MediaEventListener mAudioCallback;
   MediaEventListener mVideoCallback;
   MediaEventListener mAudioWaitCallback;
   MediaEventListener mVideoWaitCallback;