Bug 1353644 - change the type of EXHAUSTED_DATA_MARGIN_USECS to TimeUnit. r=kaku
authorJW Wang <jwwang@mozilla.com>
Wed, 29 Mar 2017 15:04:50 +0800
changeset 560259 a25e24d077b8e16c441f0f622342452108fd79db
parent 560258 e2c9182cddb13a3b3141e39f03302d629397b846
child 560260 992b8a6ae635c5e8f0aa0ab03e161ef243add7b4
push id53365
push userjichen@mozilla.com
push dateTue, 11 Apr 2017 08:35:12 +0000
reviewerskaku
bugs1353644
milestone55.0a1
Bug 1353644 - change the type of EXHAUSTED_DATA_MARGIN_USECS to TimeUnit. r=kaku MozReview-Commit-ID: CXc9DjoUc4m
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -136,18 +136,18 @@ static constexpr auto LOW_BUFFER_THRESHO
 
 // LOW_BUFFER_THRESHOLD_USECS needs to be greater than AMPLE_AUDIO_USECS, otherwise
 // the skip-to-keyframe logic can activate when we're running low on data.
 static_assert(LOW_BUFFER_THRESHOLD_USECS > AMPLE_AUDIO_USECS,
               "LOW_BUFFER_THRESHOLD_USECS is too small");
 
 } // namespace detail
 
-// Amount of excess usecs of data to add in to the "should we buffer" calculation.
-static const uint32_t EXHAUSTED_DATA_MARGIN_USECS = 100000;
+// Amount of excess data to add in to the "should we buffer" calculation.
+static constexpr auto EXHAUSTED_DATA_MARGIN = TimeUnit::FromMicroseconds(100000);
 
 static const uint32_t MIN_VIDEO_QUEUE_SIZE = 3;
 static const uint32_t MAX_VIDEO_QUEUE_SIZE = 10;
 #ifdef MOZ_APPLEMEDIA
 static const uint32_t HW_VIDEO_QUEUE_SIZE = 10;
 #else
 static const uint32_t HW_VIDEO_QUEUE_SIZE = 3;
 #endif
@@ -3295,18 +3295,18 @@ MediaDecoderStateMachine::StartMediaSink
   }
 }
 
 bool
 MediaDecoderStateMachine::HasLowDecodedAudio()
 {
   MOZ_ASSERT(OnTaskQueue());
   return IsAudioDecoding()
-         && GetDecodedAudioDuration().ToMicroseconds()
-            < EXHAUSTED_DATA_MARGIN_USECS * mPlaybackRate;
+         && GetDecodedAudioDuration()
+            < EXHAUSTED_DATA_MARGIN.MultDouble(mPlaybackRate);
 }
 
 bool
 MediaDecoderStateMachine::HasLowDecodedVideo()
 {
   MOZ_ASSERT(OnTaskQueue());
   return IsVideoDecoding()
          && VideoQueue().GetSize() < LOW_VIDEO_FRAMES * mPlaybackRate;