Bug 1353644 - change the type of EXHAUSTED_DATA_MARGIN_USECS to TimeUnit. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 29 Mar 2017 15:04:50 +0800
changeset 559388 e0e85e9aff7597ab63c779b3bb4a6285e22ecd2b
parent 559365 45692c884fdd5136a64fb2f8a61a0c8183b69331
child 559509 820cbe34858867ea5c4b48ac06dc4445931454b6
push id53070
push userjwwang@mozilla.com
push dateMon, 10 Apr 2017 02:27:53 +0000
bugs1353644
milestone55.0a1
Bug 1353644 - change the type of EXHAUSTED_DATA_MARGIN_USECS to TimeUnit. 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
@@ -3289,18 +3289,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;