From 9279297f22cd8e90b369ca8051ee99890b3007a7 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 24 Apr 2015 23:13:20 -0700 Subject: [PATCH] Bug 1157797 - Be more disciplined about where we call UpdateNextFrameStatus. r=jww This value depends on mState and the audio/video queue states. Given that, we can just stick these calls in a few choke points. --- dom/media/MediaDecoderStateMachine.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 502b8bf6263..d682c35ecee 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -543,7 +543,6 @@ void MediaDecoderStateMachine::SendStreamData() // until all samples are drained. if (finished && AudioQueue().GetSize() == 0) { mAudioCompleted = true; - UpdateNextFrameStatus(); } } @@ -940,9 +939,6 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType, case DECODER_STATE_BUFFERING: case DECODER_STATE_DECODING: { CheckIfDecodeComplete(); - // The ready state can change when we've decoded data, so update the - // ready state, so that DOM events can fire. - UpdateNextFrameStatus(); mDecoder->GetReentrantMonitor().NotifyAll(); // Schedule the state machine to notify track ended as soon as possible. if (mAudioCaptured) { @@ -1325,6 +1321,8 @@ void MediaDecoderStateMachine::SetState(State aState) mState = aState; + UpdateNextFrameStatus(); + // Clear state-scoped state. mSentPlaybackEndedEvent = false; } @@ -1867,11 +1865,6 @@ MediaDecoderStateMachine::InitiateSeek() StopPlayback(); UpdatePlaybackPositionInternal(mCurrentSeek.mTarget.mTime); - - // Make sure the main thread decoder gets notified of the seek only after - // we've updated the mirrored NextFrameStatus, which has special behavior - // when we're in DECODER_STATE_SEEKING. - UpdateNextFrameStatus(); nsCOMPtr startEvent = NS_NewRunnableMethodWithArg( mDecoder, @@ -2677,7 +2670,6 @@ nsresult MediaDecoderStateMachine::RunStateMachine() // Notify to allow blocked decoder thread to continue mDecoder->GetReentrantMonitor().NotifyAll(); - UpdateNextFrameStatus(); MaybeStartPlayback(); NS_ASSERTION(IsStateMachineScheduled(), "Must have timer scheduled"); return NS_OK; @@ -3031,12 +3023,6 @@ void MediaDecoderStateMachine::AdvanceFrame() currentFrame = nullptr; } - // If the number of audio/video frames queued has changed, either by - // this function popping and playing a video frame, or by the audio - // thread popping and playing an audio frame, we may need to update our - // ready state. Post an update to do so. - UpdateNextFrameStatus(); - int64_t delay = remainingTime / mPlaybackRate; if (delay > 0) { ScheduleStateMachineIn(delay); @@ -3256,7 +3242,6 @@ void MediaDecoderStateMachine::StartBuffering() mBufferingStart = TimeStamp::Now(); SetState(DECODER_STATE_BUFFERING); - UpdateNextFrameStatus(); DECODER_LOG("Changed state from DECODING to BUFFERING, decoded for %.3lfs", decodeDuration.ToSeconds()); #ifdef PR_LOGGING