Bug 1352319. P4 - move AudioPrerollUsecs/VideoPrerollFrames into DecodingState. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 28 Mar 2017 15:38:34 +0800
changeset 554253 6dbf68a6eb09f29e70a7c2e111a862d78ec43b50
parent 554252 f5f0102eddaaa44852868c184c718831edf946d7
child 554254 72536abcb5c16eef6529f6d5e9c2e19d60d719b2
push id51883
push userjwwang@mozilla.com
push dateFri, 31 Mar 2017 09:16:07 +0000
bugs1352319
milestone55.0a1
Bug 1352319. P4 - move AudioPrerollUsecs/VideoPrerollFrames into DecodingState. MozReview-Commit-ID: 3VuDj1TXZV2
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -832,28 +832,44 @@ private:
       SLOG("Slow video decode, set "
            "mLowAudioThreshold=%" PRId64
            " mAmpleAudioThreshold=%" PRId64,
            mMaster->mLowAudioThreshold.ToMicroseconds(),
            mMaster->mAmpleAudioThreshold.ToMicroseconds());
     }
   }
 
+  // At the start of decoding we want to "preroll" the decode until we've
+  // got a few frames decoded before we consider whether decode is falling
+  // behind. Otherwise our "we're falling behind" logic will trigger
+  // unnecessarily if we start playing as soon as the first sample is
+  // decoded. These two fields store how many video frames and audio
+  // samples we must consume before are considered to be finished prerolling.
+  uint32_t AudioPrerollUsecs() const
+  {
+    return mMaster->mAmpleAudioThreshold.ToMicroseconds() / 2;
+  }
+
+  uint32_t VideoPrerollFrames() const
+  {
+    return mMaster->GetAmpleVideoFrames() / 2;
+  }
+
   bool DonePrerollingAudio()
   {
     return !mMaster->IsAudioDecoding()
            || mMaster->GetDecodedAudioDuration()
-              >= mMaster->AudioPrerollUsecs() * mMaster->mPlaybackRate;
+              >= AudioPrerollUsecs() * mMaster->mPlaybackRate;
   }
 
   bool DonePrerollingVideo()
   {
     return !mMaster->IsVideoDecoding()
            || static_cast<uint32_t>(mMaster->VideoQueue().GetSize())
-              >= mMaster->VideoPrerollFrames() * mMaster->mPlaybackRate + 1;
+              >= VideoPrerollFrames() * mMaster->mPlaybackRate + 1;
   }
 
   void MaybeStopPrerolling()
   {
     if (mIsPrerolling
         && (DonePrerollingAudio() || mMaster->IsWaitingAudioData())
         && (DonePrerollingVideo() || mMaster->IsWaitingVideoData())) {
       mIsPrerolling = false;
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -588,34 +588,16 @@ private:
   // Our "ample" audio threshold. Once we've this much audio decoded, we
   // pause decoding. If we increase mLowAudioThreshold, we'll also
   // increase this too appropriately (we don't want mLowAudioThreshold
   // to be greater than mAmpleAudioThreshold, else we'd stop decoding!).
   // Note that we don't ever reset this threshold, it only ever grows as
   // we detect that the decode can't keep up with rendering.
   media::TimeUnit mAmpleAudioThreshold;
 
-  // At the start of decoding we want to "preroll" the decode until we've
-  // got a few frames decoded before we consider whether decode is falling
-  // behind. Otherwise our "we're falling behind" logic will trigger
-  // unnecessarily if we start playing as soon as the first sample is
-  // decoded. These two fields store how many video frames and audio
-  // samples we must consume before are considered to be finished prerolling.
-  uint32_t AudioPrerollUsecs() const
-  {
-    MOZ_ASSERT(OnTaskQueue());
-    return mAmpleAudioThreshold.ToMicroseconds() / 2;
-  }
-
-  uint32_t VideoPrerollFrames() const
-  {
-    MOZ_ASSERT(OnTaskQueue());
-    return GetAmpleVideoFrames() / 2;
-  }
-
   // Only one of a given pair of ({Audio,Video}DataPromise, WaitForDataPromise)
   // should exist at any given moment.
   using AudioDataPromise = MediaDecoderReader::AudioDataPromise;
   using VideoDataPromise = MediaDecoderReader::VideoDataPromise;
   using WaitForDataPromise = MediaDecoderReader::WaitForDataPromise;
   MozPromiseRequestHolder<AudioDataPromise> mAudioDataRequest;
   MozPromiseRequestHolder<VideoDataPromise> mVideoDataRequest;
   MozPromiseRequestHolder<WaitForDataPromise> mAudioWaitRequest;