Bug 1136827 - Stop proxying DecodeError to the decode thread. r=mattwoodrow
authorBobby Holley <bobbyholley@gmail.com>
Mon, 23 Mar 2015 16:15:54 -0700
changeset 264332 69699566f38561eb54109e6576793744d423b166
parent 264331 7b0077c342f5d3a8bb927aed3137e3f626b9eee6
child 264333 7e1f549793005a18d8f71345b1e293d6e8c8d78a
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1136827
milestone39.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 1136827 - Stop proxying DecodeError to the decode thread. r=mattwoodrow At this point, all the callers actually call it on the state machine thread, where it belongs.
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -926,23 +926,16 @@ MediaDecoderStateMachine::OnNotDecoded(M
     }
     default: {
       return;
     }
   }
 }
 
 void
-MediaDecoderStateMachine::AcquireMonitorAndInvokeDecodeError()
-{
-  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-  DecodeError();
-}
-
-void
 MediaDecoderStateMachine::MaybeFinishDecodeFirstFrame()
 {
   MOZ_ASSERT(OnStateMachineThread());
   AssertCurrentThreadInMonitor();
   if ((IsAudioDecoding() && AudioQueue().GetSize() == 0) ||
       (IsVideoDecoding() && VideoQueue().GetSize() == 0)) {
     return;
   }
@@ -2091,35 +2084,23 @@ bool MediaDecoderStateMachine::HasLowUnd
   return endOfDecodedData != INT64_MAX &&
          !buffered->Contains(static_cast<double>(endOfDecodedData) / USECS_PER_S,
                              static_cast<double>(std::min(endOfDecodedData + aUsecs, GetDuration())) / USECS_PER_S);
 }
 
 void
 MediaDecoderStateMachine::DecodeError()
 {
-  AssertCurrentThreadInMonitor();
+  MOZ_ASSERT(OnStateMachineThread());
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   if (mState == DECODER_STATE_SHUTDOWN) {
     // Already shutdown.
     return;
   }
 
-  // DecodeError should probably be redesigned so that it doesn't need to run
-  // on the Decode Task Queue, but this does the trick for now.
-  if (!OnDecodeThread()) {
-    RefPtr<nsIRunnable> task(
-      NS_NewRunnableMethod(this, &MediaDecoderStateMachine::AcquireMonitorAndInvokeDecodeError));
-    nsresult rv = DecodeTaskQueue()->Dispatch(task);
-
-    if (NS_FAILED(rv)) {
-      DECODER_WARN("Failed to dispatch AcquireMonitorAndInvokeDecodeError");
-    }
-    return;
-  }
-
   // Change state to shutdown before sending error report to MediaDecoder
   // and the HTMLMediaElement, so that our pipeline can start exiting
   // cleanly during the sync dispatch below.
   ScheduleStateMachine();
   SetState(DECODER_STATE_SHUTDOWN);
   DECODER_WARN("Decode error, changed state to SHUTDOWN due to error");
   mDecoder->GetReentrantMonitor().NotifyAll();
 
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -405,19 +405,16 @@ public:
     ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     WaitRequestRef(aRejection.mType).Complete();
   }
 
   // Resets all state related to decoding and playback, emptying all buffers
   // and aborting all pending operations on the decode task queue.
   void Reset();
 
-private:
-  void AcquireMonitorAndInvokeDecodeError();
-
 protected:
   virtual ~MediaDecoderStateMachine();
 
   void AssertCurrentThreadInMonitor() const { mDecoder->GetReentrantMonitor().AssertCurrentThreadIn(); }
 
   void SetState(State aState);
 
   // Inserts MediaData* samples into their respective MediaQueues.