Bug 1352319. P1 - add LOW_BUFFER_THRESHOLD and replace the use of LOW_DATA_THRESHOLD_USECS with it.
MozReview-Commit-ID: HNQR7Y93pAz
--- 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