Bug 1216850. Part 2 - backout bug 1214498. r=me.
authorJW Wang <jwwang@mozilla.com>
Wed, 21 Oct 2015 11:45:53 +0800
changeset 303896 0a956a76fcfc2daf13cbfd669eb602575665b73a
parent 303895 41bfa6144994a773f86404061a58d6dd1fde2e79
child 303897 a2e952efafc09ee625ef5bc3d736cd5be1471788
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1216850, 1214498
milestone44.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 1216850. Part 2 - backout bug 1214498. r=me.
dom/media/MediaDecoderReader.h
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -101,28 +101,16 @@ public:
     if (OnTaskQueue()) {
       ReleaseMediaResourcesInternal();
       return;
     }
     nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(
       this, &MediaDecoderReader::ReleaseMediaResourcesInternal);
     OwnerThread()->Dispatch(r.forget());
   }
-
-  void DisableHardwareAcceleration()
-  {
-    if (OnTaskQueue()) {
-      DisableHardwareAccelerationInternal();
-      return;
-    }
-    nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(
-      this, &MediaDecoderReader::DisableHardwareAccelerationInternal);
-    OwnerThread()->Dispatch(r.forget());
-  }
-
   // Breaks reference-counted cycles. Called during shutdown.
   // WARNING: If you override this, you must call the base implementation
   // in your override.
   virtual void BreakCycles();
 
   // 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
@@ -261,17 +249,16 @@ public:
   // the audio queue.
   size_t SizeOfAudioQueueInBytes() const;
 
   virtual size_t SizeOfVideoQueueInFrames();
   virtual size_t SizeOfAudioQueueInFrames();
 
 private:
   virtual void ReleaseMediaResourcesInternal() {}
-  virtual void DisableHardwareAccelerationInternal() {}
 
 protected:
   friend class TrackBuffer;
   virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) { }
 
   void NotifyDataArrived(const media::Interval<int64_t>& aInfo)
   {
     MOZ_ASSERT(OnTaskQueue());
@@ -342,16 +329,18 @@ public:
   // implementation in this class to adapt the old synchronous to
   // the newer async model.
   virtual bool IsAsync() const { return false; }
 
   // Returns true if this decoder reader uses hardware accelerated video
   // decoding.
   virtual bool VideoIsHardwareAccelerated() const { return false; }
 
+  virtual void DisableHardwareAcceleration() {}
+
   TimedMetadataEventSource& TimedMetadataEvent() {
     return mTimedMetadataEvent;
   }
 
 protected:
   virtual ~MediaDecoderReader();
 
   // Overrides of this function should decodes an unspecified amount of
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2478,17 +2478,19 @@ MediaDecoderStateMachine::CheckFrameVali
     frameStats.NotifyCorruptFrame();
     // If more than 10% of the last 30 frames have been corrupted, then try disabling
     // hardware acceleration. We use 10 as the corrupt value because RollingMean<>
     // only supports integer types.
     mCorruptFrames.insert(10);
     if (mReader->VideoIsHardwareAccelerated() &&
         frameStats.GetPresentedFrames() > 60 &&
         mCorruptFrames.mean() >= 2 /* 20% */) {
-        mReader->DisableHardwareAcceleration();
+        nsCOMPtr<nsIRunnable> task =
+          NS_NewRunnableMethod(mReader, &MediaDecoderReader::DisableHardwareAcceleration);
+        DecodeTaskQueue()->Dispatch(task.forget());
         mCorruptFrames.clear();
       gfxCriticalNote << "Too many dropped/corrupted frames, disabling DXVA";
     }
   } else {
     mCorruptFrames.insert(0);
   }
 }
 
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -534,17 +534,17 @@ MediaFormatReader::GetDecoderData(TrackT
              aTrack == TrackInfo::kVideoTrack);
   if (aTrack == TrackInfo::kAudioTrack) {
     return mAudio;
   }
   return mVideo;
 }
 
 void
-MediaFormatReader::DisableHardwareAccelerationInternal()
+MediaFormatReader::DisableHardwareAcceleration()
 {
   MOZ_ASSERT(OnTaskQueue());
   if (HasVideo() && !mHardwareAccelerationDisabled) {
     mHardwareAccelerationDisabled = true;
     Flush(TrackInfo::kVideoTrack);
     mVideo.mDecoder->Shutdown();
     mVideo.mDecoder = nullptr;
     if (!EnsureDecodersCreated()) {
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -76,16 +76,18 @@ public:
   nsresult ResetDecode() override;
 
   RefPtr<ShutdownPromise> Shutdown() override;
 
   bool IsAsync() const override { return true; }
 
   bool VideoIsHardwareAccelerated() const override;
 
+  void DisableHardwareAcceleration() override;
+
   bool IsWaitForDataSupported() override { return true; }
   RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType) override;
 
   bool UseBufferingHeuristics() override
   {
     return mTrackDemuxersMayBlock;
   }
 
@@ -436,14 +438,13 @@ private:
 
 #if defined(READER_DORMANT_HEURISTIC)
   const bool mDormantEnabled;
 #endif
 
 private:
   // For Media Resource Management
   void ReleaseMediaResourcesInternal() override;
-  void DisableHardwareAccelerationInternal() override;
 };
 
 } // namespace mozilla
 
 #endif