--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -437,33 +437,31 @@ public:
if (mMaster->CheckIfDecodeComplete()) {
SetState(DECODER_STATE_COMPLETED);
return;
}
mDecodeStartTime = TimeStamp::Now();
- mMaster->mIsAudioPrerolling = true;
- mMaster->mIsVideoPrerolling = true;
+ mMaster->mIsPrerolling = true;
// Ensure that we've got tasks enqueued to decode data if we need to.
mMaster->DispatchDecodeTasksIfNeeded();
mMaster->ScheduleStateMachine();
}
void Exit() override
{
if (!mDecodeStartTime.IsNull()) {
TimeDuration decodeDuration = TimeStamp::Now() - mDecodeStartTime;
SLOG("Exiting DECODING, decoded for %.3lfs", decodeDuration.ToSeconds());
}
- mMaster->mIsAudioPrerolling = false;
- mMaster->mIsVideoPrerolling = false;
+ mMaster->mIsPrerolling = false;
}
void Step() override
{
if (mMaster->mPlayState != MediaDecoder::PLAY_STATE_PLAYING &&
mMaster->IsPlaying()) {
// We're playing, but the element/decoder is in paused state. Stop
// playing!
@@ -717,18 +715,16 @@ MediaDecoderStateMachine::MediaDecoderSt
INIT_WATCHABLE(mObservedDuration, TimeUnit()),
mFragmentEndTime(-1),
mReader(new MediaDecoderReaderWrapper(mTaskQueue, aReader)),
mDecodedAudioEndTime(0),
mDecodedVideoEndTime(0),
mPlaybackRate(1.0),
mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS),
mAmpleAudioThresholdUsecs(detail::AMPLE_AUDIO_USECS),
- mIsAudioPrerolling(false),
- mIsVideoPrerolling(false),
mAudioCaptured(false),
INIT_WATCHABLE(mAudioCompleted, false),
INIT_WATCHABLE(mVideoCompleted, false),
mNotifyMetadataBeforeFirstFrame(false),
mMinimizePreroll(false),
mDecodeThreadWaiting(false),
mSentLoadedMetadataEvent(false),
mSentFirstFrameLoadedEvent(false),
@@ -1048,17 +1044,17 @@ MediaDecoderStateMachine::OnAudioDecoded
case DECODER_STATE_DECODING_FIRSTFRAME: {
Push(audio, MediaData::AUDIO_DATA);
MaybeFinishDecodeFirstFrame();
return;
}
case DECODER_STATE_DECODING: {
Push(audio, MediaData::AUDIO_DATA);
- if (mIsAudioPrerolling) {
+ if (mIsPrerolling) {
// Schedule next cycle to check if we can stop prerolling.
ScheduleStateMachine();
}
return;
}
default: {
// Ignore other cases.
@@ -1128,17 +1124,17 @@ MediaDecoderStateMachine::OnNotDecoded(M
// If the decoder is waiting for data, we tell it to call us back when the
// data arrives.
if (aError == NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA) {
MOZ_ASSERT(mReader->IsWaitForDataSupported(),
"Readers that send WAITING_FOR_DATA need to implement WaitForData");
mReader->WaitForData(aType);
- if ((isAudio && mIsAudioPrerolling) || (!isAudio && mIsVideoPrerolling)) {
+ if (mIsPrerolling) {
// Schedule next cycle to stop prerolling so we can play the frames we've
// decoded so far.
ScheduleStateMachine();
}
return;
}
if (aError == NS_ERROR_DOM_MEDIA_CANCELED) {
@@ -1159,17 +1155,17 @@ MediaDecoderStateMachine::OnNotDecoded(M
// This is an EOS. Finish off the queue, and then handle things based on our
// state.
if (isAudio) {
AudioQueue().Finish();
} else {
VideoQueue().Finish();
}
- if ((isAudio && mIsAudioPrerolling) || (!isAudio && mIsVideoPrerolling)) {
+ if (mIsPrerolling) {
// No more data to decode. Schedule next cycle to stop prerolling
// and start playback.
ScheduleStateMachine();
}
switch (mState) {
case DECODER_STATE_DECODING_FIRSTFRAME:
MaybeFinishDecodeFirstFrame();
@@ -1239,17 +1235,17 @@ MediaDecoderStateMachine::OnVideoDecoded
case DECODER_STATE_DECODING_FIRSTFRAME: {
Push(video, MediaData::VIDEO_DATA);
MaybeFinishDecodeFirstFrame();
return;
}
case DECODER_STATE_DECODING: {
Push(video, MediaData::VIDEO_DATA);
- if (mIsVideoPrerolling) {
+ if (mIsPrerolling) {
// Schedule next cycle to check if we can stop prerolling.
ScheduleStateMachine();
}
// For non async readers, if the requested video sample was slow to
// arrive, increase the amount of audio we buffer to ensure that we
// don't run out of audio. This is unnecessary for async readers,
// since they decode audio and video on different threads so they
@@ -1417,34 +1413,27 @@ void MediaDecoderStateMachine::MaybeStar
MOZ_ASSERT(mState == DECODER_STATE_DECODING ||
mState == DECODER_STATE_COMPLETED);
if (IsPlaying()) {
// Logging this case is really spammy - don't do it.
return;
}
- if (mIsAudioPrerolling &&
- (DonePrerollingAudio() || mReader->IsWaitingAudioData())) {
- mIsAudioPrerolling = false;
- }
-
- if (mIsVideoPrerolling &&
+ if (mIsPrerolling &&
+ (DonePrerollingAudio() || mReader->IsWaitingAudioData()) &&
(DonePrerollingVideo() || mReader->IsWaitingVideoData())) {
- mIsVideoPrerolling = false;
+ mIsPrerolling = false;
}
bool playStatePermits = mPlayState == MediaDecoder::PLAY_STATE_PLAYING;
- if (!playStatePermits || mIsAudioPrerolling ||
- mIsVideoPrerolling || mAudioOffloading) {
+ if (!playStatePermits || mIsPrerolling || mAudioOffloading) {
DECODER_LOG("Not starting playback [playStatePermits: %d, "
- "mIsAudioPrerolling: %d, mIsVideoPrerolling: %d, "
- "mAudioOffloading: %d]",
- (int)playStatePermits, (int)mIsAudioPrerolling,
- (int)mIsVideoPrerolling, (int)mAudioOffloading);
+ "mIsPrerolling: %d, mAudioOffloading: %d]",
+ playStatePermits, mIsPrerolling, mAudioOffloading);
return;
}
DECODER_LOG("MaybeStartPlayback() starting playback");
mOnPlaybackEvent.Notify(MediaEventType::PlaybackStarted);
StartMediaSink();
if (!IsPlaying()) {
@@ -2938,17 +2927,17 @@ MediaDecoderStateMachine::SetAudioCaptur
ScheduleStateMachine();
// Don't buffer as much when audio is captured because we don't need to worry
// about high latency audio devices.
mAmpleAudioThresholdUsecs = mAudioCaptured ?
detail::AMPLE_AUDIO_USECS / 2 :
detail::AMPLE_AUDIO_USECS;
- if (mIsAudioPrerolling) {
+ if (mIsPrerolling) {
// Schedule next cycle to check if we can stop prerolling.
ScheduleStateMachine();
}
}
uint32_t MediaDecoderStateMachine::GetAmpleVideoFrames() const
{
MOZ_ASSERT(OnTaskQueue());
@@ -2965,22 +2954,21 @@ MediaDecoderStateMachine::DumpDebugInfo(
// It is fine to capture a raw pointer here because MediaDecoder only call
// this function before shutdown begins.
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([this] () {
mMediaSink->DumpDebugInfo();
DUMP_LOG(
"GetMediaTime=%lld GetClock=%lld mMediaSink=%p "
"mState=%s mPlayState=%d mSentFirstFrameLoadedEvent=%d IsPlaying=%d "
"mAudioStatus=%s mVideoStatus=%s mDecodedAudioEndTime=%lld mDecodedVideoEndTime=%lld "
- "mIsAudioPrerolling=%d mIsVideoPrerolling=%d "
- "mAudioCompleted=%d mVideoCompleted=%d",
+ "mIsPrerolling=%d mAudioCompleted=%d mVideoCompleted=%d",
GetMediaTime(), mMediaSink->IsStarted() ? GetClock() : -1, mMediaSink.get(),
ToStateStr(), mPlayState.Ref(), mSentFirstFrameLoadedEvent, IsPlaying(),
AudioRequestStatus(), VideoRequestStatus(), mDecodedAudioEndTime, mDecodedVideoEndTime,
- mIsAudioPrerolling, mIsVideoPrerolling, mAudioCompleted.Ref(), mVideoCompleted.Ref());
+ mIsPrerolling, mAudioCompleted.Ref(), mVideoCompleted.Ref());
});
OwnerThread()->DispatchStateChange(r.forget());
}
void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream,
bool aFinishWhenEnded)
{