Bug 1353607. P12 - replace |TimeUnit::ToMicroseconds()*double| with |TimeUnit::MultDouble()|. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 29 Mar 2017 15:00:46 +0800
changeset 557659 3610ce907c1bb8debeaebbd539ca303f3a886ba4
parent 557658 cfc53067374ef073389194c7d40633d2617a10a8
child 557660 36a9db5c9107bdefafa2090b3cfb4dfcafb6bcea
push id52775
push userjwwang@mozilla.com
push dateFri, 07 Apr 2017 03:28:07 +0000
bugs1353607
milestone55.0a1
Bug 1353607. P12 - replace |TimeUnit::ToMicroseconds()*double| with |TimeUnit::MultDouble()|. MozReview-Commit-ID: 3QIBCCNf5G0
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -843,18 +843,18 @@ private:
   uint32_t VideoPrerollFrames() const
   {
     return mMaster->GetAmpleVideoFrames() / 2;
   }
 
   bool DonePrerollingAudio()
   {
     return !mMaster->IsAudioDecoding()
-           || mMaster->GetDecodedAudioDuration().ToMicroseconds()
-              >= AudioPrerollThreshold().ToMicroseconds() * mMaster->mPlaybackRate;
+           || mMaster->GetDecodedAudioDuration()
+              >= AudioPrerollThreshold().MultDouble(mMaster->mPlaybackRate);
   }
 
   bool DonePrerollingVideo()
   {
     return !mMaster->IsVideoDecoding()
            || static_cast<uint32_t>(mMaster->VideoQueue().GetSize())
               >= VideoPrerollFrames() * mMaster->mPlaybackRate + 1;
   }
@@ -2306,22 +2306,22 @@ DecodingState::NeedToSkipToNextKeyframe(
   // we won't start keyframe skipping, as we'll be pausing playback to buffer
   // soon anyway and we'll want to be able to display frames immediately
   // after buffering finishes. We ignore the low audio calculations for
   // readers that are async, as since their audio decode runs on a different
   // task queue it should never run low and skipping won't help their decode.
   bool isLowOnDecodedAudio =
     !Reader()->IsAsync()
     && mMaster->IsAudioDecoding()
-    && (mMaster->GetDecodedAudioDuration().ToMicroseconds()
-        < mMaster->mLowAudioThreshold.ToMicroseconds() * mMaster->mPlaybackRate);
+    && (mMaster->GetDecodedAudioDuration()
+        < mMaster->mLowAudioThreshold.MultDouble(mMaster->mPlaybackRate));
   bool isLowOnDecodedVideo =
-    (mMaster->GetClock() - mMaster->mDecodedVideoEndTime).ToMicroseconds()
-    * mMaster->mPlaybackRate
-    > LOW_VIDEO_THRESHOLD.ToMicroseconds();
+    (mMaster->GetClock()
+     - mMaster->mDecodedVideoEndTime).MultDouble(mMaster->mPlaybackRate)
+    > LOW_VIDEO_THRESHOLD;
   bool lowBuffered = mMaster->HasLowBufferedData();
 
   if ((isLowOnDecodedAudio || isLowOnDecodedVideo) && !lowBuffered) {
     SLOG("Skipping video decode to the next keyframe lowAudio=%d lowVideo=%d "
          "lowUndecoded=%d async=%d",
          isLowOnDecodedAudio, isLowOnDecodedVideo, lowBuffered,
          Reader()->IsAsync());
     return true;
@@ -2758,19 +2758,19 @@ MediaDecoderStateMachine::GetDecodedAudi
   // MediaSink not started. All audio samples are in the queue.
   return TimeUnit::FromMicroseconds(AudioQueue().Duration());
 }
 
 bool
 MediaDecoderStateMachine::HaveEnoughDecodedAudio()
 {
   MOZ_ASSERT(OnTaskQueue());
-  auto ampleAudioUSecs = mAmpleAudioThreshold.ToMicroseconds() * mPlaybackRate;
+  auto ampleAudio = mAmpleAudioThreshold.MultDouble(mPlaybackRate);
   return AudioQueue().GetSize() > 0
-         && GetDecodedAudioDuration().ToMicroseconds() >= ampleAudioUSecs;
+         && GetDecodedAudioDuration() >= ampleAudio;
 }
 
 bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
 {
   MOZ_ASSERT(OnTaskQueue());
   return VideoQueue().GetSize() >= GetAmpleVideoFrames() * mPlaybackRate + 1;
 }