Bug 1295901 - Change the semantics/naming of MediaDecoderReader::ReleaseMediaResources(). r=jya
authorJW Wang <jwwang@mozilla.com>
Wed, 17 Aug 2016 15:03:30 +0800
changeset 309824 4030666f6c50c963645afab80caf373eb7ee1d06
parent 309823 da03fe82ba9de1fdd59294fad5e74aa24bce3dd9
child 309866 f04d86773cb31d586d825fff6c36b90f4c02f78f
push id20333
push userkwierso@gmail.com
push dateThu, 18 Aug 2016 00:26:40 +0000
treeherderfx-team@11c94ec980d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1295901
milestone51.0a1
Bug 1295901 - Change the semantics/naming of MediaDecoderReader::ReleaseMediaResources(). r=jya MozReview-Commit-ID: DyOwNcC2JK5
dom/media/MediaDecoderReader.cpp
dom/media/MediaDecoderReader.h
dom/media/MediaDecoderReaderWrapper.cpp
dom/media/MediaDecoderReaderWrapper.h
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
dom/media/omx/MediaOmxReader.cpp
dom/media/omx/MediaOmxReader.h
--- a/dom/media/MediaDecoderReader.cpp
+++ b/dom/media/MediaDecoderReader.cpp
@@ -158,17 +158,17 @@ private:
 
   static void Suspend(MediaDecoderReader* aReader)
   {
     if (aReader->IsSuspended()) {
       return;
     }
     aReader->SetIsSuspended(true);
 
-    aReader->ReleaseMediaResources();
+    aReader->ReleaseResources();
   }
 
   static void DispatchResume(MediaDecoderReader* aReader)
   {
     RefPtr<MediaDecoderReader> reader = aReader;
 
     nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction(
       [reader]() {
@@ -515,17 +515,17 @@ MediaDecoderReader::Shutdown()
   MOZ_ASSERT(OnTaskQueue());
   mShutdown = true;
 
   mBaseAudioPromise.RejectIfExists(END_OF_STREAM, __func__);
   mBaseVideoPromise.RejectIfExists(END_OF_STREAM, __func__);
 
   mDataArrivedListener.DisconnectIfExists();
 
-  ReleaseMediaResources();
+  ReleaseResources();
   mDuration.DisconnectIfConnected();
   mBuffered.DisconnectAll();
   mIsSuspended.DisconnectAll();
 
   // Shut down the watch manager before shutting down our task queue.
   mWatchManager.Shutdown();
 
   RefPtr<ShutdownPromise> p;
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -97,19 +97,20 @@ public:
   // The caller must ensure that Shutdown() is called before aDecoder is
   // destroyed.
   explicit MediaDecoderReader(AbstractMediaDecoder* aDecoder);
 
   // Initializes the reader, returns NS_OK on success, or NS_ERROR_FAILURE
   // on failure.
   virtual nsresult Init() { return NS_OK; }
 
-  // Release media resources they should be released in dormant state
-  // The reader can be made usable again by calling ReadMetadata().
-  virtual void ReleaseMediaResources() {}
+  // Called by MDSM in dormant state to release resources allocated by this
+  // reader. The reader can resume decoding by calling Seek() to a specific
+  // position.
+  virtual void ReleaseResources() {}
 
   // Destroys the decoding state. The reader cannot be made usable again.
   // This is different from ReleaseMediaResources() as it is irreversable,
   // whereas ReleaseMediaResources() is.  Must be called on the decode
   // thread.
   virtual RefPtr<ShutdownPromise> Shutdown();
 
   virtual bool OnTaskQueue() const
--- a/dom/media/MediaDecoderReaderWrapper.cpp
+++ b/dom/media/MediaDecoderReaderWrapper.cpp
@@ -323,21 +323,21 @@ RefPtr<MediaDecoderReaderWrapper::Buffer
 MediaDecoderReaderWrapper::UpdateBufferedWithPromise()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                      &MediaDecoderReader::UpdateBufferedWithPromise);
 }
 
 void
-MediaDecoderReaderWrapper::ReleaseMediaResources()
+MediaDecoderReaderWrapper::ReleaseResources()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   nsCOMPtr<nsIRunnable> r =
-    NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources);
+    NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseResources);
   mReader->OwnerThread()->Dispatch(r.forget());
 }
 
 void
 MediaDecoderReaderWrapper::SetIdle()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   nsCOMPtr<nsIRunnable> r =
--- a/dom/media/MediaDecoderReaderWrapper.h
+++ b/dom/media/MediaDecoderReaderWrapper.h
@@ -71,17 +71,17 @@ public:
   bool IsRequestingVideoData() const;
   bool IsWaitingAudioData() const;
   bool IsWaitingVideoData() const;
 
   RefPtr<SeekPromise> Seek(SeekTarget aTarget, media::TimeUnit aEndTime);
   RefPtr<BufferedUpdatePromise> UpdateBufferedWithPromise();
   RefPtr<ShutdownPromise> Shutdown();
 
-  void ReleaseMediaResources();
+  void ReleaseResources();
   void SetIdle();
   void ResetDecode(TrackSet aTracks);
 
   nsresult Init() { return mReader->Init(); }
   bool IsWaitForDataSupported() const { return mReader->IsWaitForDataSupported(); }
   bool IsAsync() const { return mReader->IsAsync(); }
   bool UseBufferingHeuristics() const { return mReader->UseBufferingHeuristics(); }
   bool ForceZeroStartTime() const { return mReader->ForceZeroStartTime(); }
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1181,22 +1181,22 @@ MediaDecoderStateMachine::SetDormant(boo
 
     if (IsPlaying()) {
       StopPlayback();
     }
 
     Reset();
 
     // Note that we do not wait for the decode task queue to go idle before
-    // queuing the ReleaseMediaResources task - instead, we disconnect promises,
+    // queuing the ReleaseResources task - instead, we disconnect promises,
     // reset state, and put a ResetDecode in the decode task queue. Any tasks
     // that run after ResetDecode are supposed to run with a clean slate. We
     // rely on that in other places (i.e. seeking), so it seems reasonable to
     // rely on it here as well.
-    mReader->ReleaseMediaResources();
+    mReader->ReleaseResources();
 
     return;
   }
 
   // Exit dormant state.
   SetState(DECODER_STATE_DECODING_METADATA);
   mDecodingFirstFrame = true;
   ReadMetadata();
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1957,17 +1957,17 @@ MediaFormatReader::UpdateBufferedWithPro
   // ranges. UpdateBuffered alone will not force a recalculation, so we
   // use NotifyDataArrived which sets flags to force this recalculation.
   // See MediaFormatReader::UpdateReceivedNewData for an example of where
   // the new data flag is used.
   NotifyDataArrived();
   return BufferedUpdatePromise::CreateAndResolve(true, __func__);
 }
 
-void MediaFormatReader::ReleaseMediaResources()
+void MediaFormatReader::ReleaseResources()
 {
   // Before freeing a video codec, all video buffers needed to be released
   // even from graphics pipeline.
   if (mVideoFrameContainer) {
     mVideoFrameContainer->ClearCurrentFrame();
   }
   mVideo.ShutdownDecoder();
   mAudio.ShutdownDecoder();
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -57,17 +57,17 @@ protected:
 public:
   media::TimeIntervals GetBuffered() override;
 
   RefPtr<BufferedUpdatePromise> UpdateBufferedWithPromise() override;
 
   bool ForceZeroStartTime() const override;
 
   // For Media Resource Management
-  void ReleaseMediaResources() override;
+  void ReleaseResources() override;
 
   nsresult ResetDecode(TrackSet aTracks) override;
 
   RefPtr<ShutdownPromise> Shutdown() override;
 
   bool IsAsync() const override { return true; }
 
   bool VideoIsHardwareAccelerated() const override;
@@ -209,17 +209,17 @@ private:
     }
     void Error(MediaDataDecoderError aError) override {
       mReader->Error(mType, aError);
     }
     void DrainComplete() override {
       mReader->DrainComplete(mType);
     }
     void ReleaseMediaResources() override {
-      mReader->ReleaseMediaResources();
+      mReader->ReleaseResources();
     }
     bool OnReaderTaskQueue() override {
       return mReader->OnTaskQueue();
     }
 
   private:
     MediaFormatReader* mReader;
     TrackType mType;
--- a/dom/media/omx/MediaOmxReader.cpp
+++ b/dom/media/omx/MediaOmxReader.cpp
@@ -167,17 +167,17 @@ MediaOmxReader::Shutdown()
 
   // Wait for the superclass to finish tearing things down before releasing
   // the decoder on the main thread.
   p->Then(AbstractThread::MainThread(), __func__, this, &MediaOmxReader::ReleaseDecoder, &MediaOmxReader::ReleaseDecoder);
 
   return p;
 }
 
-void MediaOmxReader::ReleaseMediaResources()
+void MediaOmxReader::ReleaseResources()
 {
   mMediaResourceRequest.DisconnectIfExists();
   mMetadataPromise.RejectIfExists(ReadMetadataFailureReason::METADATA_ERROR, __func__);
 
   ResetDecode();
   // Before freeing a video codec, all video buffers needed to be released
   // even from graphics pipeline.
   VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
--- a/dom/media/omx/MediaOmxReader.h
+++ b/dom/media/omx/MediaOmxReader.h
@@ -81,17 +81,17 @@ public:
     mSeekRequest.DisconnectIfExists();
     mSeekPromise.RejectIfExists(NS_OK, __func__);
     return MediaDecoderReader::ResetDecode(aTracks);
   }
 
   bool DecodeAudioData() override;
   bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override;
 
-  void ReleaseMediaResources() override;
+  void ReleaseResources() override;
 
   RefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata() override;
 
   RefPtr<SeekPromise>
   Seek(SeekTarget aTarget, int64_t aEndTime) override;
 
   void SetIdle() override;