Bug 1307063. Move MDSM::MaybeFinishDecodeFirstFrame() into DecodingFirstFrameState.
MozReview-Commit-ID: LVLjImUQf26
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -423,32 +423,53 @@ public:
State GetState() const override
{
return DECODER_STATE_DECODING_FIRSTFRAME;
}
bool HandleAudioDecoded(MediaData* aAudio) override
{
mMaster->Push(aAudio, MediaData::AUDIO_DATA);
- mMaster->MaybeFinishDecodeFirstFrame();
+ MaybeFinishDecodeFirstFrame();
return true;
}
bool HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override
{
mMaster->Push(aVideo, MediaData::VIDEO_DATA);
- mMaster->MaybeFinishDecodeFirstFrame();
+ MaybeFinishDecodeFirstFrame();
return true;
}
bool HandleEndOfStream() override
{
- mMaster->MaybeFinishDecodeFirstFrame();
+ MaybeFinishDecodeFirstFrame();
return true;
}
+
+private:
+ // Notify FirstFrameLoaded if having decoded first frames and
+ // transition to SEEKING if there is any pending seek, or DECODING otherwise.
+ void MaybeFinishDecodeFirstFrame()
+ {
+ MOZ_ASSERT(!mMaster->mSentFirstFrameLoadedEvent);
+
+ if ((mMaster->IsAudioDecoding() && mMaster->AudioQueue().GetSize() == 0) ||
+ (mMaster->IsVideoDecoding() && mMaster->VideoQueue().GetSize() == 0)) {
+ return;
+ }
+
+ mMaster->FinishDecodeFirstFrame();
+
+ if (mMaster->mQueuedSeek.Exists()) {
+ mMaster->InitiateSeek(Move(mMaster->mQueuedSeek));
+ } else {
+ SetState(DECODER_STATE_DECODING);
+ }
+ }
};
class MediaDecoderStateMachine::DecodingState
: public MediaDecoderStateMachine::StateObject
{
public:
explicit DecodingState(Master* aPtr) : StateObject(aPtr) {}
@@ -1245,36 +1266,16 @@ MediaDecoderStateMachine::OnNotDecoded(M
}
MaybeStopPrerolling();
mStateObj->HandleEndOfStream();
}
void
-MediaDecoderStateMachine::MaybeFinishDecodeFirstFrame()
-{
- MOZ_ASSERT(OnTaskQueue());
- MOZ_ASSERT(!mSentFirstFrameLoadedEvent);
-
- if ((IsAudioDecoding() && AudioQueue().GetSize() == 0) ||
- (IsVideoDecoding() && VideoQueue().GetSize() == 0)) {
- return;
- }
-
- FinishDecodeFirstFrame();
-
- if (mQueuedSeek.Exists()) {
- InitiateSeek(Move(mQueuedSeek));
- } else {
- SetState(DECODER_STATE_DECODING);
- }
-}
-
-void
MediaDecoderStateMachine::OnVideoDecoded(MediaData* aVideo,
TimeStamp aDecodeStartTime)
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(aVideo);
// Handle abnormal or negative timestamps.
mDecodedVideoEndTime = std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -528,20 +528,16 @@ protected:
// decoded and playable. This is the sum of the number of usecs of audio which
// is decoded and in the reader's audio queue, and the usecs of unplayed audio
// which has been pushed to the audio hardware for playback. Note that after
// calling this, the audio hardware may play some of the audio pushed to
// hardware, so this can only be used as a upper bound. The decoder monitor
// must be held when calling this. Called on the decode thread.
int64_t GetDecodedAudioDuration();
- // Notify FirstFrameLoaded if having decoded first frames and
- // transition to SEEKING if there is any pending seek, or DECODING otherwise.
- void MaybeFinishDecodeFirstFrame();
-
void FinishDecodeFirstFrame();
// Completes the seek operation, moves onto the next appropriate state.
void SeekCompleted();
// Queries our state to see whether the decode has finished for all streams.
bool CheckIfDecodeComplete();