Bug 1309116. Part 4 - fix remaining calls to MDSM::SetState() and remove unused functions.
MozReview-Commit-ID: EytZ8qrQJRn
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1964,17 +1964,17 @@ MediaDecoderStateMachine::MaybeStartBuff
if (mReader->UseBufferingHeuristics()) {
shouldBuffer = HasLowDecodedData() && HasLowBufferedData();
} else {
MOZ_ASSERT(mReader->IsWaitForDataSupported());
shouldBuffer = (OutOfDecodedAudio() && mReader->IsWaitingAudioData()) ||
(OutOfDecodedVideo() && mReader->IsWaitingVideoData());
}
if (shouldBuffer) {
- SetState(DECODER_STATE_BUFFERING);
+ mStateObj->SetState<BufferingState>();
}
}
void MediaDecoderStateMachine::UpdatePlaybackPositionInternal(int64_t aTime)
{
MOZ_ASSERT(OnTaskQueue());
SAMPLE_LOG("UpdatePlaybackPositionInternal(%lld)", aTime);
@@ -2017,64 +2017,16 @@ MediaDecoderStateMachine::ToStateStr(Sta
const char*
MediaDecoderStateMachine::ToStateStr()
{
MOZ_ASSERT(OnTaskQueue());
return ToStateStr(mState);
}
-void
-MediaDecoderStateMachine::SetState(State aState)
-{
- MOZ_ASSERT(OnTaskQueue());
- if (mState == aState) {
- return;
- }
-
- DECODER_LOG("MDSM state: %s -> %s", ToStateStr(), ToStateStr(aState));
-
- MOZ_ASSERT(mState == mStateObj->GetState());
- mStateObj->Exit();
- mState = aState;
-
- switch (mState) {
- case DECODER_STATE_DECODING_METADATA:
- mStateObj = MakeUnique<DecodeMetadataState>(this);
- break;
- case DECODER_STATE_WAIT_FOR_CDM:
- mStateObj = MakeUnique<WaitForCDMState>(this);
- break;
- case DECODER_STATE_DORMANT:
- mStateObj = MakeUnique<DormantState>(this);
- break;
- case DECODER_STATE_DECODING_FIRSTFRAME:
- mStateObj = MakeUnique<DecodingFirstFrameState>(this);
- break;
- case DECODER_STATE_DECODING:
- mStateObj = MakeUnique<DecodingState>(this);
- break;
- case DECODER_STATE_BUFFERING:
- mStateObj = MakeUnique<BufferingState>(this);
- break;
- case DECODER_STATE_COMPLETED:
- mStateObj = MakeUnique<CompletedState>(this);
- break;
- case DECODER_STATE_SHUTDOWN:
- mStateObj = MakeUnique<ShutdownState>(this);
- break;
- default:
- MOZ_ASSERT_UNREACHABLE("Invalid state.");
- break;
- }
-
- MOZ_ASSERT(mState == mStateObj->GetState());
- mStateObj->Enter();
-}
-
void MediaDecoderStateMachine::VolumeChanged()
{
MOZ_ASSERT(OnTaskQueue());
mMediaSink->SetVolume(mVolume);
}
void MediaDecoderStateMachine::RecomputeDuration()
{
@@ -2127,17 +2079,17 @@ MediaDecoderStateMachine::SetDormant(boo
mStateObj->HandleDormant(aDormant);
}
RefPtr<ShutdownPromise>
MediaDecoderStateMachine::Shutdown()
{
MOZ_ASSERT(OnTaskQueue());
- SetState(DECODER_STATE_SHUTDOWN);
+ mStateObj->SetState<ShutdownState>();
mDelayedScheduler.Reset();
mBufferedUpdateRequest.DisconnectIfExists();
mQueuedSeek.RejectIfExists(__func__);
// Shutdown happens will decode timer is active, we need to disconnect and
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -342,18 +342,16 @@ private:
// Resets all state related to decoding and playback, emptying all buffers
// and aborting all pending operations on the decode task queue.
void Reset(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
TrackInfo::kVideoTrack));
protected:
virtual ~MediaDecoderStateMachine();
- void SetState(State aState);
-
void BufferedRangeUpdated();
void ReaderSuspendedChanged();
// Inserts MediaData* samples into their respective MediaQueues.
// aSample must not be null.
void Push(MediaData* aSample, MediaData::Type aSampleType);