Bug 1265315. Part 1 - remove use of MediaDecoderReader from SeekTask. r=kaku.
authorJW Wang <jwwang@mozilla.com>
Tue, 19 Apr 2016 16:14:44 +0800
changeset 331710 1ba90ff2774850a64bfaf5aceeca683bb09ac044
parent 331709 d5d46a4ad2be4af1b0d32886f3d492c1292a21ce
child 331711 0fcee6752011b2dbcab1c9622074ce4b13bfae21
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku
bugs1265315
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1265315. Part 1 - remove use of MediaDecoderReader from SeekTask. r=kaku. MozReview-Commit-ID: DlUZYcAVBMB
dom/media/MediaDecoderStateMachine.cpp
dom/media/SeekTask.cpp
dom/media/SeekTask.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1466,17 +1466,17 @@ MediaDecoderStateMachine::InitiateSeek(S
   // Discard the existing seek task.
   if (mSeekTask) {
     mSeekTask->Discard();
   }
 
   mSeekTaskRequest.DisconnectIfExists();
 
   // Create a new SeekTask instance for the incoming seek task.
-  mSeekTask = SeekTask::CreateSeekTask(mDecoderID, OwnerThread(), mReader.get(),
+  mSeekTask = SeekTask::CreateSeekTask(mDecoderID, OwnerThread(),
                                        mReaderWrapper.get(), Move(aSeekJob),
                                        mInfo, Duration(), GetMediaTime());
 
   // 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());
--- a/dom/media/SeekTask.cpp
+++ b/dom/media/SeekTask.cpp
@@ -33,41 +33,38 @@ extern LazyLogModule gMediaSampleLog;
 // when __VA_ARGS__ expands to nothing. This is a workaround for it.
 #define DECODER_WARN_HELPER(a, b) NS_WARNING b
 #define DECODER_WARN(x, ...) \
   DECODER_WARN_HELPER(0, (nsPrintfCString("Decoder=%p " x, mDecoderID, ##__VA_ARGS__).get()))
 
 /*static*/ already_AddRefed<SeekTask>
 SeekTask::CreateSeekTask(const void* aDecoderID,
                          AbstractThread* aThread,
-                         MediaDecoderReader* aReader,
                          MediaDecoderReaderWrapper* aReaderWrapper,
                          SeekJob&& aSeekJob,
                          const MediaInfo& aInfo,
                          const media::TimeUnit& aDuration,
                          int64_t aCurrentMediaTime)
 {
-  RefPtr<SeekTask> task(new SeekTask(aDecoderID, aThread, aReader,
+  RefPtr<SeekTask> task(new SeekTask(aDecoderID, aThread,
                                      aReaderWrapper, Move(aSeekJob), aInfo,
                                      aDuration, aCurrentMediaTime));
 
   return task.forget();
 }
 
 SeekTask::SeekTask(const void* aDecoderID,
                    AbstractThread* aThread,
-                   MediaDecoderReader* aReader,
                    MediaDecoderReaderWrapper* aReaderWrapper,
                    SeekJob&& aSeekJob,
                    const MediaInfo& aInfo,
                    const media::TimeUnit& aDuration,
                    int64_t aCurrentMediaTime)
   : mDecoderID(aDecoderID)
   , mOwnerThread(aThread)
-  , mReader(aReader)
   , mReaderWrapper(aReaderWrapper)
   , mSeekJob(Move(aSeekJob))
   , mCurrentTimeBeforeSeek(aCurrentMediaTime)
   , mAudioRate(aInfo.mAudio.mRate)
   , mHasAudio(aInfo.HasAudio())
   , mHasVideo(aInfo.HasVideo())
   , mDropAudioUntilNextDiscontinuity(false)
   , mDropVideoUntilNextDiscontinuity(false)
@@ -135,22 +132,16 @@ SeekTask::HasAudio() const
 }
 
 bool
 SeekTask::HasVideo() const
 {
   return mHasVideo;
 }
 
-TaskQueue*
-SeekTask::DecodeTaskQueue() const
-{
-  return mReader->OwnerThread();
-}
-
 AbstractThread*
 SeekTask::OwnerThread() const
 {
   return mOwnerThread;
 }
 
 void
 SeekTask::Discard()
@@ -281,33 +272,33 @@ SeekTask::VideoRequestStatus()
 }
 
 void
 SeekTask::RequestAudioData()
 {
   AssertOwnerThread();
 
   SAMPLE_LOG("Queueing audio task - queued=%i, decoder-queued=%o",
-             !!mSeekedAudioData, mReader->SizeOfAudioQueueInFrames());
+             !!mSeekedAudioData, mReaderWrapper->SizeOfAudioQueueInFrames());
 
   mAudioDataRequest.Begin(mReaderWrapper->RequestAudioData()
     ->Then(OwnerThread(), __func__, this,
            &SeekTask::OnAudioDecoded, &SeekTask::OnAudioNotDecoded));
 }
 
 void
 SeekTask::RequestVideoData()
 {
   AssertOwnerThread();
   //These two variables are not used in the SEEKING state.
   const bool skipToNextKeyFrame = false;
   const media::TimeUnit currentTime = media::TimeUnit::FromMicroseconds(0);
 
   SAMPLE_LOG("Queueing video task - queued=%i, decoder-queued=%o, skip=%i, time=%lld",
-               !!mSeekedVideoData, mReader->SizeOfVideoQueueInFrames(), skipToNextKeyFrame,
+               !!mSeekedVideoData, mReaderWrapper->SizeOfVideoQueueInFrames(), skipToNextKeyFrame,
                currentTime.ToMicroseconds());
 
   mVideoDataRequest.Begin(
     mReaderWrapper->RequestVideoData(skipToNextKeyFrame, currentTime)
     ->Then(OwnerThread(), __func__, this,
            &SeekTask::OnVideoDecoded, &SeekTask::OnVideoNotDecoded));
 }
 
@@ -568,22 +559,20 @@ SeekTask::OnAudioNotDecoded(MediaDecoder
     // If this is a decode error, delegate to the generic error path.
     RejectIfExist(__func__);
     return;
   }
 
   // If the decoder is waiting for data, we tell it to call us back when the
   // data arrives.
   if (aReason == MediaDecoderReader::WAITING_FOR_DATA) {
-    MOZ_ASSERT(mReader->IsWaitForDataSupported(),
+    MOZ_ASSERT(mReaderWrapper->IsWaitForDataSupported(),
                "Readers that send WAITING_FOR_DATA need to implement WaitForData");
     RefPtr<SeekTask> self = this;
-    mAudioWaitRequest.Begin(InvokeAsync(DecodeTaskQueue(), mReader.get(), __func__,
-                                        &MediaDecoderReader::WaitForData,
-                                        MediaData::AUDIO_DATA)
+    mAudioWaitRequest.Begin(mReaderWrapper->WaitForData(MediaData::AUDIO_DATA)
       ->Then(OwnerThread(), __func__,
              [self] (MediaData::Type aType) -> void {
                self->mAudioWaitRequest.Complete();
                self->EnsureAudioDecodeTaskQueued();
              },
              [self] (WaitForDataRejectValue aRejection) -> void {
                self->mAudioWaitRequest.Complete();
              }));
@@ -674,22 +663,20 @@ SeekTask::OnVideoNotDecoded(MediaDecoder
     // If this is a decode error, delegate to the generic error path.
     RejectIfExist(__func__);
     return;
   }
 
   // If the decoder is waiting for data, we tell it to call us back when the
   // data arrives.
   if (aReason == MediaDecoderReader::WAITING_FOR_DATA) {
-    MOZ_ASSERT(mReader->IsWaitForDataSupported(),
+    MOZ_ASSERT(mReaderWrapper->IsWaitForDataSupported(),
                "Readers that send WAITING_FOR_DATA need to implement WaitForData");
     RefPtr<SeekTask> self = this;
-    mVideoWaitRequest.Begin(InvokeAsync(DecodeTaskQueue(), mReader.get(), __func__,
-                                        &MediaDecoderReader::WaitForData,
-                                        MediaData::VIDEO_DATA)
+    mVideoWaitRequest.Begin(mReaderWrapper->WaitForData(MediaData::VIDEO_DATA)
       ->Then(OwnerThread(), __func__,
              [self] (MediaData::Type aType) -> void {
                self->mVideoWaitRequest.Complete();
                self->EnsureVideoDecodeTaskQueued();
              },
              [self] (WaitForDataRejectValue aRejection) -> void {
                self->mVideoWaitRequest.Complete();
              }));
--- a/dom/media/SeekTask.h
+++ b/dom/media/SeekTask.h
@@ -43,17 +43,16 @@ public:
   static const bool IsExclusive = true;
 
   using SeekTaskPromise =
     MozPromise<SeekTaskResolveValue, SeekTaskRejectValue, IsExclusive>;
 
   static already_AddRefed<SeekTask>
   CreateSeekTask(const void* aDecoderID,
                  AbstractThread* aThread,
-                 MediaDecoderReader* aReader,
                  MediaDecoderReaderWrapper* aReaderWrapper,
                  SeekJob&& aSeekJob,
                  const MediaInfo& aInfo,
                  const media::TimeUnit& aDuration,
                  int64_t aCurrentMediaTime);
 
   virtual void Discard();
 
@@ -63,17 +62,16 @@ public:
 
   SeekJob& GetSeekJob();
 
   bool Exists();
 
 protected:
   SeekTask(const void* aDecoderID,
            AbstractThread* aThread,
-           MediaDecoderReader* aReader,
            MediaDecoderReaderWrapper* aReaderWrapper,
            SeekJob&& aSeekJob,
            const MediaInfo& aInfo,
            const media::TimeUnit& aDuration,
            int64_t aCurrentMediaTime);
 
   virtual ~SeekTask();
 
@@ -129,17 +127,16 @@ protected:
 
   virtual void OnVideoNotDecoded(MediaDecoderReader::NotDecodedReason aReason);
 
   /*
    * Data shared with MDSM.
    */
   const void* mDecoderID; // For logging.
   const RefPtr<AbstractThread> mOwnerThread;
-  const RefPtr<MediaDecoderReader> mReader;
   const RefPtr<MediaDecoderReaderWrapper> mReaderWrapper;
 
   /*
    * Internal state.
    */
   SeekJob mSeekJob;
   MozPromiseHolder<SeekTaskPromise> mSeekTaskPromise;
   int64_t mCurrentTimeBeforeSeek;