Bug 1350837. P3 - rename the variable and fix comments. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 28 Mar 2017 14:38:30 +0800
changeset 553392 4987e4d66e347043f425e462e9b9a2988e00fd0c
parent 553391 040167eece526351f2aa1b9fdebb13396d7d85ae
child 553972 e44b6882ccd3f9ecc25f28404bf0c48ae07b41df
push id51626
push userjwwang@mozilla.com
push dateThu, 30 Mar 2017 00:55:27 +0000
bugs1350837
milestone55.0a1
Bug 1350837. P3 - rename the variable and fix comments. MozReview-Commit-ID: JI1sp6f6Xnb
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -89,22 +89,22 @@ using namespace mozilla::media;
 namespace detail {
 
 // If audio queue has less than this much decoded audio, we won't risk
 // trying to decode the video, we'll skip decoding video up to the next
 // keyframe. We may increase this value for an individual decoder if we
 // encounter video frames which take a long time to decode.
 static constexpr auto LOW_AUDIO_THRESHOLD = TimeUnit::FromMicroseconds(300000);
 
-// If more than this many usecs of decoded audio is queued, we'll hold off
+static const int64_t AMPLE_AUDIO_USECS = 2000000;
+
+// If more than this much decoded audio is queued, we'll hold off
 // decoding more audio. If we increase the low audio threshold (see
 // LOW_AUDIO_THRESHOLD above) we'll also increase this value to ensure it's not
 // less than the low audio threshold.
-static const int64_t AMPLE_AUDIO_USECS = 2000000;
-
 static constexpr auto AMPLE_AUDIO_THRESHOLD = TimeUnit::FromMicroseconds(AMPLE_AUDIO_USECS);
 
 } // namespace detail
 
 // If we have fewer than LOW_VIDEO_FRAMES decoded frames, and
 // we're not "prerolling video", we'll skip the video up to the next keyframe
 // which is at or after the current playback position.
 static const uint32_t LOW_VIDEO_FRAMES = 2;
@@ -816,27 +816,27 @@ private:
 
     TimeDuration decodeTime = TimeStamp::Now() - aDecodeStart;
     int64_t adjustedTime = THRESHOLD_FACTOR * DurationToUsecs(decodeTime);
     if (adjustedTime > mMaster->mLowAudioThreshold.ToMicroseconds()
         && !mMaster->HasLowBufferedData())
     {
       mMaster->mLowAudioThreshold = std::min(
         TimeUnit::FromMicroseconds(adjustedTime),
-        mMaster->mAmpleAudioThresholdUsecs);
-
-      mMaster->mAmpleAudioThresholdUsecs = std::max(
+        mMaster->mAmpleAudioThreshold);
+
+      mMaster->mAmpleAudioThreshold = std::max(
         mMaster->mLowAudioThreshold * THRESHOLD_FACTOR,
-        mMaster->mAmpleAudioThresholdUsecs);
+        mMaster->mAmpleAudioThreshold);
 
       SLOG("Slow video decode, set "
-           "mLowAudioThresholdUsecs=%" PRId64
-           " mAmpleAudioThresholdUsecs=%" PRId64,
+           "mLowAudioThreshold=%" PRId64
+           " mAmpleAudioThreshold=%" PRId64,
            mMaster->mLowAudioThreshold.ToMicroseconds(),
-           mMaster->mAmpleAudioThresholdUsecs.ToMicroseconds());
+           mMaster->mAmpleAudioThreshold.ToMicroseconds());
     }
   }
 
   bool DonePrerollingAudio()
   {
     return !mMaster->IsAudioDecoding()
            || mMaster->GetDecodedAudioDuration()
               >= mMaster->AudioPrerollUsecs() * mMaster->mPlaybackRate;
@@ -2593,17 +2593,17 @@ MediaDecoderStateMachine::MediaDecoderSt
   mCurrentFrameID(0),
   INIT_WATCHABLE(mObservedDuration, TimeUnit()),
   mFragmentEndTime(-1),
   mReader(new MediaDecoderReaderWrapper(mTaskQueue, aReader)),
   mDecodedAudioEndTime(0),
   mDecodedVideoEndTime(0),
   mPlaybackRate(1.0),
   mLowAudioThreshold(detail::LOW_AUDIO_THRESHOLD),
-  mAmpleAudioThresholdUsecs(detail::AMPLE_AUDIO_THRESHOLD),
+  mAmpleAudioThreshold(detail::AMPLE_AUDIO_THRESHOLD),
   mAudioCaptured(false),
   mMinimizePreroll(aDecoder->GetMinimizePreroll()),
   mSentLoadedMetadataEvent(false),
   mSentFirstFrameLoadedEvent(false),
   mVideoDecodeSuspended(false),
   mVideoDecodeSuspendTimer(mTaskQueue),
   mOutputStreamManager(new OutputStreamManager()),
   mResource(aDecoder->GetResource()),
@@ -2751,17 +2751,17 @@ MediaDecoderStateMachine::GetDecodedAudi
   // MediaSink not started. All audio samples are in the queue.
   return AudioQueue().Duration();
 }
 
 bool
 MediaDecoderStateMachine::HaveEnoughDecodedAudio()
 {
   MOZ_ASSERT(OnTaskQueue());
-  auto ampleAudioUSecs = mAmpleAudioThresholdUsecs.ToMicroseconds() * mPlaybackRate;
+  auto ampleAudioUSecs = mAmpleAudioThreshold.ToMicroseconds() * mPlaybackRate;
   return AudioQueue().GetSize() > 0
          && GetDecodedAudioDuration() >= ampleAudioUSecs;
 }
 
 bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
 {
   MOZ_ASSERT(OnTaskQueue());
   return VideoQueue().GetSize() >= GetAmpleVideoFrames() * mPlaybackRate + 1;
@@ -3785,17 +3785,17 @@ MediaDecoderStateMachine::SetAudioCaptur
 
   // Restore playback parameters.
   mMediaSink->SetPlaybackParams(params);
 
   mAudioCaptured = aCaptured;
 
   // Don't buffer as much when audio is captured because we don't need to worry
   // about high latency audio devices.
-  mAmpleAudioThresholdUsecs = mAudioCaptured
+  mAmpleAudioThreshold = mAudioCaptured
     ? detail::AMPLE_AUDIO_THRESHOLD / 2 : detail::AMPLE_AUDIO_THRESHOLD;
 
   mStateObj->HandleAudioCaptured();
 }
 
 uint32_t MediaDecoderStateMachine::GetAmpleVideoFrames() const
 {
   MOZ_ASSERT(OnTaskQueue());
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -583,31 +583,31 @@ private:
   // decode video frames, in order to reduce the chance of audio underruns.
   // 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 mLowAudioThreshold;
 
   // 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 ampleAudioThreshold, else we'd stop decoding!).
+  // 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 mAmpleAudioThresholdUsecs;
+  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 mAmpleAudioThresholdUsecs.ToMicroseconds() / 2;
+    return mAmpleAudioThreshold.ToMicroseconds() / 2;
   }
 
   uint32_t VideoPrerollFrames() const
   {
     MOZ_ASSERT(OnTaskQueue());
     return GetAmpleVideoFrames() / 2;
   }