Bug 1350832. P2 - change the type of mLowAudioThresholdUsecs to TimeUnit.
MozReview-Commit-ID: AurJRSuZkkg
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -809,30 +809,30 @@ private:
// 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->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);
}
}
bool DonePrerollingAudio()
{
return !mMaster->IsAudioDecoding()
|| mMaster->GetDecodedAudioDuration()
@@ -2294,17 +2294,17 @@ DecodingState::NeedToSkipToNextKeyframe(
// soon anyway and we'll want to be able to display frames immediately
// after buffering finishes. We ignore the low audio calculations for
// readers that are async, as since their audio decode runs on a different
// task queue it should never run low and skipping won't help their decode.
bool isLowOnDecodedAudio =
!Reader()->IsAsync()
&& mMaster->IsAudioDecoding()
&& (mMaster->GetDecodedAudioDuration()
- < mMaster->mLowAudioThresholdUsecs * mMaster->mPlaybackRate);
+ < mMaster->mLowAudioThresholdUsecs.ToMicroseconds() * mMaster->mPlaybackRate);
bool isLowOnDecodedVideo =
(mMaster->GetClock() - mMaster->mDecodedVideoEndTime)
* mMaster->mPlaybackRate
> LOW_VIDEO_THRESHOLD_USECS;
bool lowBuffered = mMaster->HasLowBufferedData();
if ((isLowOnDecodedAudio || isLowOnDecodedVideo) && !lowBuffered) {
SLOG("Skipping video decode to the next keyframe lowAudio=%d lowVideo=%d "
@@ -2583,17 +2583,17 @@ MediaDecoderStateMachine::MediaDecoderSt
mDelayedScheduler(mTaskQueue),
mCurrentFrameID(0),
INIT_WATCHABLE(mObservedDuration, TimeUnit()),
mFragmentEndTime(-1),
mReader(new MediaDecoderReaderWrapper(mTaskQueue, aReader)),
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()),
mSentLoadedMetadataEvent(false),
mSentFirstFrameLoadedEvent(false),
mVideoDecodeSuspended(false),
mVideoDecodeSuspendTimer(mTaskQueue),
mOutputStreamManager(new OutputStreamManager()),
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -577,17 +577,17 @@ private:
// Low audio threshold. If we've decoded less than this much audio we
// consider our audio decode "behind", and we may skip video decoding
// in order to allow our audio decoding to catch up. We favour audio
// decoding over video. We increase this threshold if we're slow to
// 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
// increase this too appropriately (we don't want mLowAudioThresholdUsecs
// to be greater than ampleAudioThreshold, 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.
int64_t mAmpleAudioThresholdUsecs;