Bug 1307677. Part 4 - prepare to move most code of InitiateSeek() into the entry action of SeekingState. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 04 Oct 2016 17:05:39 +0800
changeset 421050 900361c6eee21f595d156e5283ee42fef2f730d4
parent 421049 ad2212940c6cd0627ccd784516345b8463b9372e
child 421051 1ef255743df1cfa2662fccf0cca1985fcf3b5fbd
push id31369
push userjwwang@mozilla.com
push dateWed, 05 Oct 2016 07:51:53 +0000
bugs1307677
milestone52.0a1
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
dom/media/MediaDecoderStateMachine.cpp
--- 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();