Bug 1294345 - Remove the TrackSet parameter from MediaDecoderStateMachine::InitiateDecodeRecoverySeek(). draft
authorJW Wang <jwwang@mozilla.com>
Thu, 11 Aug 2016 15:03:15 +0800
changeset 399484 87bc894e1ba0f0f655ca8a3022c1f314a22d8c78
parent 399447 c6ec7ed381d4125e5879f77e163acf171811ef66
child 399490 72457716e9b8347299700b9a4837ffb46b8e0a78
push id25849
push userjwwang@mozilla.com
push dateThu, 11 Aug 2016 07:09:14 +0000
bugs1294345
milestone51.0a1
Bug 1294345 - Remove the TrackSet parameter from MediaDecoderStateMachine::InitiateDecodeRecoverySeek(). MozReview-Commit-ID: 7iXecyVAIXq
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1362,41 +1362,35 @@ void MediaDecoderStateMachine::Visibilit
 
     // If an existing seek is in flight don't bother creating a new
     // one to catch up.
     if (mSeekTask || mQueuedSeek.Exists()) {
       return;
     }
 
     // Start video-only seek to the current time...
-    InitiateDecodeRecoverySeek(TrackSet(TrackInfo::kVideoTrack));
+    InitiateDecodeRecoverySeek();
   }
 }
 
-// InitiateDecodeRecoverySeek is responsible for setting up a seek using the
-// seek task for the following situations:
-// 1. When suspension of decoding for videos that are in
+// InitiateVideoDecodeRecoverySeek is responsible for setting up a video-only
+// seek using the seek task. When suspension of decoding for videos that are in
 // background tabs (ie. invisible) is enabled, the audio keeps playing and when
 // switching back to decoding video, it is highly desirable to not cause the
 // audio to pause as the video is seeked else there be a noticeable audio glitch
 // as the tab becomes visible.
-// 2. When there is a decoder limit set, suspended videos may be resumed and
-// require the seek to recover the original seek position for both audio and
-// video.
-void MediaDecoderStateMachine::InitiateDecodeRecoverySeek(TrackSet aTracks)
+void
+MediaDecoderStateMachine::InitiateDecodeRecoverySeek()
 {
   MOZ_ASSERT(OnTaskQueue());
-
   DECODER_LOG("InitiateDecodeRecoverySeek");
 
   SeekJob seekJob;
-  SeekTarget::Type seekTargetType = aTracks.contains(TrackInfo::kAudioTrack)
-                                    ? SeekTarget::Type::Accurate
-                                    : SeekTarget::Type::AccurateVideoOnly;
-  seekJob.mTarget = SeekTarget(GetMediaTime(), seekTargetType,
+  seekJob.mTarget = SeekTarget(GetMediaTime(),
+                               SeekTarget::Type::AccurateVideoOnly,
                                MediaDecoderEventVisibility::Suppressed);
 
   SetState(DECODER_STATE_SEEKING);
 
   // Discard the existing seek task.
   DiscardSeekTaskIfExist();
 
   mSeekTaskRequest.DisconnectIfExists();
@@ -1408,17 +1402,17 @@ void MediaDecoderStateMachine::InitiateD
   mCurrentSeek = Move(seekJob);
   // Create a new SeekTask instance for the incoming seek task.
   mSeekTask = new AccurateSeekTask(mDecoderID, OwnerThread(),
                                    mReader.get(), mCurrentSeek.mTarget,
                                    mInfo, Duration(), GetMediaTime());
 
   // Reset our state machine and decoding pipeline before seeking.
   if (mSeekTask->NeedToResetMDSM()) {
-    Reset(aTracks);
+    Reset(TrackInfo::kVideoTrack);
   }
 
   // Do the seek.
   mSeekTaskRequest.Begin(
     mSeekTask->Seek(Duration())->Then(OwnerThread(), __func__, this,
                                       &MediaDecoderStateMachine::OnSeekTaskResolved,
                                       &MediaDecoderStateMachine::OnSeekTaskRejected));
   // Nobody is listening to this as OnSeekTaskResolved handles what is
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -503,21 +503,20 @@ protected:
   // The decoder monitor must be held.
   void EnqueueLoadedMetadataEvent();
 
   void EnqueueFirstFrameLoadedEvent();
 
   // Clears any previous seeking state and initiates a new seek on the decoder.
   RefPtr<MediaDecoder::SeekPromise> InitiateSeek(SeekJob aSeekJob);
 
-  // Clears any previous seeking state and initiates a seek on the decoder to
-  // resync the video and audio positions, when recovering from video decoding
-  // being suspended in background or from audio and video decoding being
-  // suspended due to the decoder limit.
-  void InitiateDecodeRecoverySeek(TrackSet aTracks);
+  // Clears any previous seeking state and initiates a video-only seek on the
+  // decoder to catch up the video to the current audio position, when recovering
+  // from video decoding being suspended in background.
+  void InitiateDecodeRecoverySeek();
 
   nsresult DispatchAudioDecodeTaskIfNeeded();
 
   // Ensures a task to decode audio has been dispatched to the decode task queue.
   // If a task to decode has already been dispatched, this does nothing,
   // otherwise this dispatches a task to do the decode.
   // This is called on the state machine or decode threads.
   // The decoder monitor must be held.