Bug 1353607. P6 - use TimeUnit in CheckSlowDecoding(). draft
authorJW Wang <jwwang@mozilla.com>
Tue, 28 Mar 2017 17:27:56 +0800
changeset 557653 9583ba8562fcfc6401cf568a86ef2ea65bbb71cf
parent 557652 9b6bde5c7577dbbe8f2eea31180c771854b8c277
child 557654 7d6a035331a9913388f1c903805eeec33ba0ac94
push id52775
push userjwwang@mozilla.com
push dateFri, 07 Apr 2017 03:28:07 +0000
bugs1353607
milestone55.0a1
Bug 1353607. P6 - use TimeUnit in CheckSlowDecoding(). MozReview-Commit-ID: 524aRA1uUaQ
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -810,23 +810,22 @@ private:
     // don't run out of audio. This is unnecessary for async readers,
     // since they decode audio and video on different threads so they
     // are unlikely to run out of decoded audio.
     if (Reader()->IsAsync()) {
       return;
     }
 
     TimeDuration decodeTime = TimeStamp::Now() - aDecodeStart;
-    int64_t adjustedTime = THRESHOLD_FACTOR * DurationToUsecs(decodeTime);
-    if (adjustedTime > mMaster->mLowAudioThreshold.ToMicroseconds()
+    auto adjusted = TimeUnit::FromTimeDuration(decodeTime * THRESHOLD_FACTOR);
+    if (adjusted > mMaster->mLowAudioThreshold
         && !mMaster->HasLowBufferedData())
     {
       mMaster->mLowAudioThreshold = std::min(
-        TimeUnit::FromMicroseconds(adjustedTime),
-        mMaster->mAmpleAudioThreshold);
+        adjusted, mMaster->mAmpleAudioThreshold);
 
       mMaster->mAmpleAudioThreshold = std::max(
         mMaster->mLowAudioThreshold * THRESHOLD_FACTOR,
         mMaster->mAmpleAudioThreshold);
 
       SLOG("Slow video decode, set "
            "mLowAudioThreshold=%" PRId64
            " mAmpleAudioThreshold=%" PRId64,