Bug 1189506. Inline RecomputeBlocking. r=karlt
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 04 Sep 2015 19:42:11 +1200
changeset 295506 3311210c41e5693e1f174009b8c4b8a622426e5d
parent 295505 7fd85ebb56de0f67fa36843f4d360f94276b0b8c
child 295507 b791ed14fbe4900ab9c3e188acb77e6d02f56301
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1189506
milestone43.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 1189506. Inline RecomputeBlocking. r=karlt
dom/media/MediaStreamGraph.cpp
dom/media/MediaStreamGraphImpl.h
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -642,37 +642,16 @@ MediaStreamGraphImpl::UpdateStreamOrder(
         ++orderedStreamCount;
       }
     }
   }
 
   MOZ_ASSERT(orderedStreamCount == mFirstCycleBreaker);
 }
 
-void
-MediaStreamGraphImpl::RecomputeBlocking(GraphTime aEndBlockingDecisions)
-{
-  STREAM_LOG(LogLevel::Verbose, ("Media graph %p computing blocking for time %f",
-                              this, MediaTimeToSeconds(mStateComputedTime)));
-  for (MediaStream* stream : AllStreams()) {
-    stream->mStartBlocking =
-      ComputeStreamBlockTime(stream, mStateComputedTime, aEndBlockingDecisions);
-  }
-  STREAM_LOG(LogLevel::Verbose, ("Media graph %p computed blocking for interval %f to %f",
-                              this, MediaTimeToSeconds(mStateComputedTime),
-                              MediaTimeToSeconds(aEndBlockingDecisions)));
-
-  MOZ_ASSERT(aEndBlockingDecisions >= mProcessedTime);
-  // The next state computed time can be the same as the previous: it
-  // means the driver would be have been blocking indefinitly, but the graph has
-  // been woken up right after having been to sleep.
-  MOZ_ASSERT(aEndBlockingDecisions >= mStateComputedTime);
-  mStateComputedTime = aEndBlockingDecisions;
-}
-
 GraphTime
 MediaStreamGraphImpl::ComputeStreamBlockTime(MediaStream* aStream,
                                              GraphTime aTime,
                                              GraphTime aEndBlockingDecisions)
 {
   if (aStream->IsSuspended()) {
     STREAM_LOG(LogLevel::Verbose, ("MediaStream %p is blocked due to being suspended", aStream));
     return aTime;
@@ -1133,56 +1112,68 @@ MediaStreamGraphImpl::AllFinishedStreams
     if (stream->mFinished && !stream->mNotifiedFinished) {
       return false;
     }
   }
   return true;
 }
 
 void
-MediaStreamGraphImpl::UpdateGraph(GraphTime aEndBlockingDecision)
+MediaStreamGraphImpl::UpdateGraph(GraphTime aEndBlockingDecisions)
 {
   // Calculate independent action times for each batch of messages (each
   // batch corresponding to an event loop task). This isolates the performance
   // of different scripts to some extent.
   for (uint32_t i = 0; i < mFrontMessageQueue.Length(); ++i) {
     nsTArray<nsAutoPtr<ControlMessage> >& messages = mFrontMessageQueue[i].mMessages;
 
     for (uint32_t j = 0; j < messages.Length(); ++j) {
       messages[j]->Run();
     }
   }
   mFrontMessageQueue.Clear();
 
+  MOZ_ASSERT(aEndBlockingDecisions >= mProcessedTime);
+  // The next state computed time can be the same as the previous: it
+  // means the driver would be have been blocking indefinitly, but the graph has
+  // been woken up right after having been to sleep.
+  MOZ_ASSERT(aEndBlockingDecisions >= mStateComputedTime);
+
   UpdateStreamOrder();
 
   bool ensureNextIteration = false;
 
-  // Grab pending stream input.
-  for (uint32_t i = 0; i < mStreams.Length(); ++i) {
-    SourceMediaStream* is = mStreams[i]->AsSourceStream();
+  // Grab pending stream input and compute blocking time
+  for (MediaStream* stream : mStreams) {
+    SourceMediaStream* is = stream->AsSourceStream();
     if (is) {
       UpdateConsumptionState(is);
-      ExtractPendingInput(is, aEndBlockingDecision, &ensureNextIteration);
+      ExtractPendingInput(is, aEndBlockingDecisions, &ensureNextIteration);
     }
+
+    stream->mStartBlocking =
+      ComputeStreamBlockTime(stream, mStateComputedTime, aEndBlockingDecisions);
+  }
+  for (MediaStream* stream : mSuspendedStreams) {
+    stream->mStartBlocking =
+      ComputeStreamBlockTime(stream, mStateComputedTime, aEndBlockingDecisions);
   }
 
   // The loop is woken up so soon that IterationEnd() barely advances and we
   // end up having aEndBlockingDecision == mStateComputedTime.
   // Since stream blocking is computed in the interval of
   // [mStateComputedTime, aEndBlockingDecision), it won't be computed at all.
   // We should ensure next iteration so that pending blocking changes will be
   // computed in next loop.
   if (ensureNextIteration ||
-      aEndBlockingDecision == mStateComputedTime) {
+      aEndBlockingDecisions == mStateComputedTime) {
     EnsureNextIteration();
   }
 
-  // Figure out which streams are blocked and when.
-  RecomputeBlocking(aEndBlockingDecision);
+  mStateComputedTime = aEndBlockingDecisions;
 }
 
 void
 MediaStreamGraphImpl::Process(GraphTime aFrom, GraphTime aTo)
 {
   // Play stream contents.
   bool allBlockedForever = true;
   // True when we've done ProcessInput for all processed streams.
--- a/dom/media/MediaStreamGraphImpl.h
+++ b/dom/media/MediaStreamGraphImpl.h
@@ -291,23 +291,16 @@ public:
                               const nsTArray<MediaStream*>& aStreamSet);
 
   /**
    * Sort mStreams so that every stream not in a cycle is after any streams
    * it depends on, and every stream in a cycle is marked as being in a cycle.
    * Also sets mIsConsumed on every stream.
    */
   void UpdateStreamOrder();
-  /**
-   * Compute the blocking states of streams from mStateComputedTime
-   * until the desired future time aEndBlockingDecisions.
-   * Updates mStateComputedTime and sets MediaStream::mBlocked
-   * for all streams.
-   */
-  void RecomputeBlocking(GraphTime aEndBlockingDecisions);
 
   /**
    * Recompute blocking for the streams in aStreams for the interval starting at aTime.
    * If this results in decisions that need to be revisited at some point
    * in the future, *aEnd will be reduced to the first time in the future to
    * recompute those decisions.
    */
   GraphTime ComputeStreamBlockTime(MediaStream* aStream,