Bug 1078354 - Part 1 - Make sure we are not waking up an OfflineGraphDriver. r=jesup
authorPaul Adenot <paul@paul.cx>
Mon, 20 Oct 2014 18:06:10 +0200
changeset 211533 9601061181bd1c6d3082d1618c6e6b10d2eff10a
parent 211532 8d5390d3813b6910c8dea7e1ef33f78b6a0e1a34
child 211534 ad6146f9dfb007181fc2ea4753f8abd797e9bd35
push id27680
push userryanvm@gmail.com
push dateTue, 21 Oct 2014 19:21:13 +0000
treeherdermozilla-central@15099ba111e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1078354
milestone36.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 1078354 - Part 1 - Make sure we are not waking up an OfflineGraphDriver. r=jesup 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
@@ -62,16 +62,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.
@@ -149,16 +150,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
@@ -301,16 +306,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
@@ -2857,19 +2857,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.