Bug 1307677. Part 4 - prepare to move most code of InitiateSeek() into the entry action of SeekingState.
Note we can't call SetState() because we might need to seek again in the SEEKING state.
MozReview-Commit-ID: 7KYhV5SLbXF
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1673,19 +1673,16 @@ MediaDecoderStateMachine::SetState(State
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_SEEKING:
- mStateObj = MakeUnique<SeekingState>(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);
@@ -2110,17 +2107,22 @@ MediaDecoderStateMachine::DispatchDecode
}
}
void
MediaDecoderStateMachine::InitiateSeek(SeekJob aSeekJob)
{
MOZ_ASSERT(OnTaskQueue());
- SetState(DECODER_STATE_SEEKING);
+ // Note we can't call SetState(DECODER_STATE_SEEKING) which does nothing
+ // if we are already in the SEEKING state.
+ mStateObj->Exit();
+ mState = DECODER_STATE_SEEKING;
+ mStateObj = MakeUnique<SeekingState>(this);
+ mStateObj->Enter();
// Discard the existing seek task.
DiscardSeekTaskIfExist();
mSeekTaskRequest.DisconnectIfExists();
// SeekTask will register its callbacks to MediaDecoderReaderWrapper.
CancelMediaDecoderReaderWrapperCallback();