Bug 1352319. P1 - add LOW_BUFFER_THRESHOLD and replace the use of LOW_DATA_THRESHOLD_USECS with it. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 28 Mar 2017 14:56:35 +0800
changeset 553977 055259e5d55f456ab63cf425503dcc53a827f4e7
parent 553973 073edc2d4721fbddceeed6980a538fada1bba90f
child 553978 f4396b988b8682ddf54173fa7f09b10c2bd475a1
push id51855
push userjwwang@mozilla.com
push dateFri, 31 Mar 2017 05:49:16 +0000
bugs1352319
milestone55.0a1
Bug 1352319. P1 - add LOW_BUFFER_THRESHOLD and replace the use of LOW_DATA_THRESHOLD_USECS with it. MozReview-Commit-ID: HNQR7Y93pAz
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -127,16 +127,18 @@ static const int THRESHOLD_FACTOR = 2;
 namespace detail {
 
 // If we have less than this much undecoded data available, we'll consider
 // ourselves to be running low on undecoded data. We determine how much
 // undecoded data we have remaining using the reader's GetBuffered()
 // implementation.
 static const int64_t LOW_DATA_THRESHOLD_USECS = 5000000;
 
+static constexpr auto LOW_BUFFER_THRESHOLD = TimeUnit::FromMicroseconds(LOW_DATA_THRESHOLD_USECS);
+
 // LOW_DATA_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_DATA_THRESHOLD_USECS > AMPLE_AUDIO_USECS,
               "LOW_DATA_THRESHOLD_USECS is too small");
 
 } // namespace detail
 
 // Amount of excess usecs of data to add in to the "should we buffer" calculation.
@@ -3311,17 +3313,17 @@ bool MediaDecoderStateMachine::OutOfDeco
     return IsAudioDecoding() && !AudioQueue().IsFinished()
            && AudioQueue().GetSize() == 0
            && !mMediaSink->HasUnplayedFrames(TrackInfo::kAudioTrack);
 }
 
 bool MediaDecoderStateMachine::HasLowBufferedData()
 {
   MOZ_ASSERT(OnTaskQueue());
-  return HasLowBufferedData(detail::LOW_DATA_THRESHOLD_USECS);
+  return HasLowBufferedData(detail::LOW_BUFFER_THRESHOLD.ToMicroseconds());
 }
 
 bool MediaDecoderStateMachine::HasLowBufferedData(int64_t aUsecs)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   // If we don't have a duration, mBuffered is probably not going to have
   // a useful buffered range. Return false here so that we don't get stuck in