diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 25960a9ef457..5b688778bf39 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -814,20 +814,20 @@ private: TimeDuration decodeTime = TimeStamp::Now() - aDecodeStart; int64_t adjustedTime = THRESHOLD_FACTOR * DurationToUsecs(decodeTime); - if (adjustedTime > mMaster->mLowAudioThresholdUsecs + if (adjustedTime > mMaster->mLowAudioThresholdUsecs.ToMicroseconds() && !mMaster->HasLowBufferedData()) { - mMaster->mLowAudioThresholdUsecs = - std::min(adjustedTime, mMaster->mAmpleAudioThresholdUsecs); + mMaster->mLowAudioThresholdUsecs = TimeUnit::FromMicroseconds( + std::min(adjustedTime, mMaster->mAmpleAudioThresholdUsecs)); mMaster->mAmpleAudioThresholdUsecs = - std::max(THRESHOLD_FACTOR * mMaster->mLowAudioThresholdUsecs, + std::max(THRESHOLD_FACTOR * mMaster->mLowAudioThresholdUsecs.ToMicroseconds(), mMaster->mAmpleAudioThresholdUsecs); SLOG("Slow video decode, set " "mLowAudioThresholdUsecs=%" PRId64 " mAmpleAudioThresholdUsecs=%" PRId64, - mMaster->mLowAudioThresholdUsecs, + mMaster->mLowAudioThresholdUsecs.ToMicroseconds(), mMaster->mAmpleAudioThresholdUsecs); } } @@ -2299,7 +2299,7 @@ DecodingState::NeedToSkipToNextKeyframe() !Reader()->IsAsync() && mMaster->IsAudioDecoding() && (mMaster->GetDecodedAudioDuration() - < mMaster->mLowAudioThresholdUsecs * mMaster->mPlaybackRate); + < mMaster->mLowAudioThresholdUsecs.ToMicroseconds() * mMaster->mPlaybackRate); bool isLowOnDecodedVideo = (mMaster->GetClock() - mMaster->mDecodedVideoEndTime) * mMaster->mPlaybackRate @@ -2594,7 +2594,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder, mDecodedAudioEndTime(0), mDecodedVideoEndTime(0), mPlaybackRate(1.0), - mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS.ToMicroseconds()), + mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS), mAmpleAudioThresholdUsecs(detail::AMPLE_AUDIO_USECS), mAudioCaptured(false), mMinimizePreroll(aDecoder->GetMinimizePreroll()), diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 3c60a2b86ec1..846c699c1b5b 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -583,7 +583,7 @@ 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. - int64_t mLowAudioThresholdUsecs; + media::TimeUnit mLowAudioThresholdUsecs; // Our "ample" audio threshold. Once we've this much audio decoded, we // pause decoding. If we increase mLowAudioThresholdUsecs, we'll also