Bug 1352319. P4 - move AudioPrerollUsecs/VideoPrerollFrames into DecodingState.
MozReview-Commit-ID: 3VuDj1TXZV2
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -832,28 +832,44 @@ private:
SLOG("Slow video decode, set "
"mLowAudioThreshold=%" PRId64
" mAmpleAudioThreshold=%" PRId64,
mMaster->mLowAudioThreshold.ToMicroseconds(),
mMaster->mAmpleAudioThreshold.ToMicroseconds());
}
}
+ // 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
+ {
+ return mMaster->mAmpleAudioThreshold.ToMicroseconds() / 2;
+ }
+
+ uint32_t VideoPrerollFrames() const
+ {
+ return mMaster->GetAmpleVideoFrames() / 2;
+ }
+
bool DonePrerollingAudio()
{
return !mMaster->IsAudioDecoding()
|| mMaster->GetDecodedAudioDuration()
- >= mMaster->AudioPrerollUsecs() * mMaster->mPlaybackRate;
+ >= AudioPrerollUsecs() * mMaster->mPlaybackRate;
}
bool DonePrerollingVideo()
{
return !mMaster->IsVideoDecoding()
|| static_cast<uint32_t>(mMaster->VideoQueue().GetSize())
- >= mMaster->VideoPrerollFrames() * mMaster->mPlaybackRate + 1;
+ >= VideoPrerollFrames() * mMaster->mPlaybackRate + 1;
}
void MaybeStopPrerolling()
{
if (mIsPrerolling
&& (DonePrerollingAudio() || mMaster->IsWaitingAudioData())
&& (DonePrerollingVideo() || mMaster->IsWaitingVideoData())) {
mIsPrerolling = false;
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -588,34 +588,16 @@ private:
// 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 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 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 mAmpleAudioThreshold.ToMicroseconds() / 2;
- }
-
- uint32_t VideoPrerollFrames() const
- {
- MOZ_ASSERT(OnTaskQueue());
- return GetAmpleVideoFrames() / 2;
- }
-
// Only one of a given pair of ({Audio,Video}DataPromise, WaitForDataPromise)
// should exist at any given moment.
using AudioDataPromise = MediaDecoderReader::AudioDataPromise;
using VideoDataPromise = MediaDecoderReader::VideoDataPromise;
using WaitForDataPromise = MediaDecoderReader::WaitForDataPromise;
MozPromiseRequestHolder<AudioDataPromise> mAudioDataRequest;
MozPromiseRequestHolder<VideoDataPromise> mVideoDataRequest;
MozPromiseRequestHolder<WaitForDataPromise> mAudioWaitRequest;