Bug 1278228 - handle VideoOnly seek as an accurate seek; r?jwwang draft
authorKaku Kuo <tkuo@mozilla.com>
Tue, 21 Jun 2016 10:33:32 +0800
changeset 380229 46a529949b2f3c0070ba2c7007bce3da160a3f64
parent 379985 3c5025f98e561a20e24d97c91a9e4e0ec28015ea
child 523679 c0229be44cf57e80e3a0a3275db6da31aee7ba94
push id21172
push usertkuo@mozilla.com
push dateTue, 21 Jun 2016 08:31:19 +0000
reviewersjwwang
bugs1278228
milestone50.0a1
Bug 1278228 - handle VideoOnly seek as an accurate seek; r?jwwang MozReview-Commit-ID: DsQQB8YX2jm
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1162,16 +1162,23 @@ MediaDecoderStateMachine::SetDormant(boo
 
   DECODER_LOG("SetDormant=%d", aDormant);
 
   if (aDormant) {
     if (mState == DECODER_STATE_SEEKING) {
       if (mQueuedSeek.Exists()) {
         // Keep latest seek target
       } else if (mSeekTask && mSeekTask->Exists()) {
+        // Because both audio and video decoders are going to be reset in this
+        // method later, we treat a VideoOnly seek task as a normal Accurate
+        // seek task so that while it is resumed, both audio and video playback
+        // are handled.
+        if (mSeekTask->GetSeekJob().mTarget.IsVideoOnly()) {
+          mSeekTask->GetSeekJob().mTarget.SetType(SeekTarget::Accurate);
+        }
         mQueuedSeek = Move(mSeekTask->GetSeekJob());
         mSeekTaskRequest.DisconnectIfExists();
       } else {
         mQueuedSeek.mTarget = SeekTarget(mCurrentPosition,
                                          SeekTarget::Accurate,
                                          MediaDecoderEventVisibility::Suppressed);
         // XXXbholley - Nobody is listening to this promise. Do we need to pass it
         // back to MediaDecoder when we come out of dormant?
@@ -1639,19 +1646,16 @@ MediaDecoderStateMachine::InitiateSeek(S
     mSeekTask = new AccurateSeekTask(mDecoderID, OwnerThread(),
                                      mReader.get(), Move(aSeekJob),
                                      mInfo, Duration(), GetMediaTime());
   } else if (aSeekJob.mTarget.IsNextFrame()) {
     mSeekTask = new NextFrameSeekTask(mDecoderID, OwnerThread(), mReader.get(),
                                       Move(aSeekJob), mInfo, Duration(),
                                       GetMediaTime(), AudioQueue(), VideoQueue());
   } else {
-    // Use MOZ_DIAGNOSTIC_ASSERT here to test if a "VideoOnly" seek task could
-    // reach here, may come from a dormant state. Once we confirm it, we could
-    // than handle it.
     MOZ_DIAGNOSTIC_ASSERT(false, "Cannot handle this seek task.");
   }
 
   // Stop playback now to ensure that while we're outside the monitor
   // dispatching SeekingStarted, playback doesn't advance and mess with
   // mCurrentPosition that we've setting to seekTime here.
   StopPlayback();
   UpdatePlaybackPositionInternal(mSeekTask->GetSeekJob().mTarget.GetTime().ToMicroseconds());