bug 1190291 don't process blocks beyond aTicksToProcess in an offline graph r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 31 Jul 2015 23:43:55 +1200
changeset 287887 def7ba7179be24f99dcc7d5730566b727df8c11d
parent 287886 ca7db7d4382b329b41968e503cc9aad30bf02b4d
child 287888 7cbc7f63aba7b931a473558244802f010bd77595
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1190291
milestone42.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 1190291 don't process blocks beyond aTicksToProcess in an offline graph r=padenot
dom/media/GraphDriver.cpp
dom/media/MediaStreamGraph.cpp
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -96,17 +96,17 @@ void GraphDriver::EnsureImmediateWakeUpL
   mGraphImpl->GetMonitor().AssertCurrentThreadOwns();
   mWaitState = WAITSTATE_WAKING_UP;
   mGraphImpl->mGraphDriverAsleep = false; // atomic
   mGraphImpl->GetMonitor().Notify();
 }
 
 void GraphDriver::UpdateStateComputedTime(GraphTime aStateComputedTime)
 {
-  MOZ_ASSERT(aStateComputedTime > mIterationEnd);
+  MOZ_ASSERT(aStateComputedTime >= mIterationEnd);
   // The next state computed time can be the same as the previous, here: it
   // means the driver would be have been blocking indefinitly, but the graph has
   // been woken up right after having been to sleep.
   if (aStateComputedTime < mStateComputedTime) {
     printf("State time can't go backward %ld < %ld.\n", static_cast<long>(aStateComputedTime), static_cast<long>(mStateComputedTime));
   }
 
   mStateComputedTime = aStateComputedTime;
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -1436,26 +1436,27 @@ MediaStreamGraphImpl::OneIteration(Graph
       }
 
       lock.Notify();
     }
   }
 
   UpdateCurrentTimeForStreams(aFrom, aTo);
 
-  UpdateGraph(aStateEnd);
-
-  Process(aStateFrom, aStateEnd);
+  GraphTime stateEnd = std::min(aStateEnd, mEndTime);
+  UpdateGraph(stateEnd);
+
+  Process(aStateFrom, stateEnd);
 
   // Send updates to the main thread and wait for the next control loop
   // iteration.
   {
     MonitorAutoLock lock(mMonitor);
     bool finalUpdate = mForceShutDown ||
-      (IterationEnd() >= mEndTime && AllFinishedStreamsNotified()) ||
+      (stateEnd >= mEndTime && AllFinishedStreamsNotified()) ||
       (IsEmpty() && mBackMessageQueue.IsEmpty());
     PrepareUpdatesToMainThreadState(finalUpdate);
     if (finalUpdate) {
       // Enter shutdown mode. The stable-state handler will detect this
       // and complete shutdown. Destroy any streams immediately.
       STREAM_LOG(LogLevel::Debug, ("MediaStreamGraph %p waiting for main thread cleanup", this));
       // We'll shut down this graph object if it does not get restarted.
       mLifecycleState = LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP;
@@ -3438,17 +3439,19 @@ MediaStreamGraph::StartNonRealtimeProces
   NS_ASSERTION(NS_IsMainThread(), "main thread only");
 
   MediaStreamGraphImpl* graph = static_cast<MediaStreamGraphImpl*>(this);
   NS_ASSERTION(!graph->mRealtime, "non-realtime only");
 
   if (graph->mNonRealtimeProcessing)
     return;
 
-  graph->mEndTime = graph->IterationEnd() + aTicksToProcess;
+  graph->mEndTime =
+    graph->RoundUpToNextAudioBlock(graph->CurrentDriver()->StateComputedTime() +
+                                   aTicksToProcess - 1);
   graph->mNonRealtimeProcessing = true;
   graph->EnsureRunInStableState();
 }
 
 void
 ProcessedMediaStream::AddInput(MediaInputPort* aPort)
 {
   mInputs.AppendElement(aPort);