Bug 1078354 - Part 1: Make sure we are not waking up an OfflineGraphDriver. r=jesup, a=lmandel
authorPaul Adenot <paul@paul.cx>
Mon, 20 Oct 2014 18:06:10 +0200
changeset 225800 9d0a16097623
parent 225799 eed6613c5568
child 225801 b185e7a13e18
push id4021
push userryanvm@gmail.com
push date2014-10-24 13:05 +0000
treeherdermozilla-beta@b185e7a13e18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, lmandel
bugs1078354
milestone34.0
Bug 1078354 - Part 1: Make sure we are not waking up an OfflineGraphDriver. r=jesup, a=lmandel I still want to assert in the method instead of making it a no-op because I'm going to work on AudioContext sleep and wakeup soon, and this will catch errors.
content/media/GraphDriver.h
content/media/MediaStreamGraph.cpp
--- a/content/media/GraphDriver.h
+++ b/content/media/GraphDriver.h
@@ -56,16 +56,17 @@ class MessageBlock;
 
 /**
  * Microseconds relative to the start of the graph timeline.
  */
 typedef int64_t GraphTime;
 const GraphTime GRAPH_TIME_MAX = MEDIA_TIME_MAX;
 
 class AudioCallbackDriver;
+class OfflineClockDriver;
 
 /**
  * A driver is responsible for the scheduling of the processing, the thread
  * management, and give the different clocks to a MediaStreamGraph. This is an
  * abstract base class. A MediaStreamGraph can be driven by an
  * OfflineClockDriver, if the graph is offline, or a SystemClockDriver, if the
  * graph is real time.
  * A MediaStreamGraph holds an owning reference to its driver.
@@ -143,16 +144,20 @@ public:
   virtual void GetAudioBuffer(float** aBuffer, long& aFrames) {
     MOZ_CRASH("This is not an Audio GraphDriver!");
   }
 
   virtual AudioCallbackDriver* AsAudioCallbackDriver() {
     return nullptr;
   }
 
+  virtual OfflineClockDriver* AsOfflineClockDriver() {
+    return nullptr;
+  }
+
   /**
    * Tell the driver it has to stop and return the current time of the graph, so
    * another driver can start from the right point in time.
    */
   virtual void SwitchAtNextIteration(GraphDriver* aDriver);
 
   /**
    * Set the time for a graph, on a driver. This is used so a new driver just
@@ -295,16 +300,19 @@ public:
   OfflineClockDriver(MediaStreamGraphImpl* aGraphImpl, GraphTime aSlice);
   virtual ~OfflineClockDriver();
   virtual void GetIntervalForIteration(GraphTime& aFrom,
                                        GraphTime& aTo) MOZ_OVERRIDE;
   virtual GraphTime GetCurrentTime() MOZ_OVERRIDE;
   virtual void WaitForNextIteration() MOZ_OVERRIDE;
   virtual void WakeUp() MOZ_OVERRIDE;
   virtual TimeStamp GetCurrentTimeStamp() MOZ_OVERRIDE;
+  virtual OfflineClockDriver* AsOfflineClockDriver() {
+    return this;
+  }
 
 private:
   // Time, in GraphTime, for each iteration
   GraphTime mSlice;
 };
 
 /**
  * This is a graph driver that is based on callback functions called by the
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -2855,19 +2855,22 @@ MediaStreamGraphImpl::CollectReports(nsI
   // Clears out the report array after we're done with it.
   ArrayClearer reportCleanup(mAudioStreamSizes);
 
   {
     MonitorAutoLock memoryReportLock(mMemoryReportMonitor);
     mNeedsMemoryReport = true;
 
     {
-      // Wake up the MSG thread.
+      // Wake up the MSG thread if it's real time (Offline graphs can't be
+      // sleeping).
       MonitorAutoLock monitorLock(mMonitor);
-      CurrentDriver()->WakeUp();
+      if (!CurrentDriver()->AsOfflineClockDriver()) {
+        CurrentDriver()->WakeUp();
+      }
     }
 
     if (mLifecycleState >= LIFECYCLE_WAITING_FOR_THREAD_SHUTDOWN) {
       // Shutting down, nothing to report.
       return NS_OK;
     }
 
     // Wait for up to one second for the report to complete.