Bug 1256510 - When shutting down MediaStreamGraphs, if the graph hasn't started, let it start and shut down r=padenot, a=ritu
authorRandell Jesup <rjesup@jesup.org>
Tue, 15 Mar 2016 11:46:01 -0400
changeset 317485 9ed563fd0535f772a6daf1d2a067c589d48b744a
parent 317484 9a0e8f871937b1de6a9ee0d3658097a8ae50480f
child 317486 9136c8ca8be3e2f0bebee3e08807f32d58565845
push id5761
push usercbook@mozilla.com
push dateThu, 17 Mar 2016 15:22:44 +0000
treeherdermozilla-beta@980a7149520b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, ritu
bugs1256510
milestone46.0
Bug 1256510 - When shutting down MediaStreamGraphs, if the graph hasn't started, let it start and shut down r=padenot, a=ritu MozReview-Commit-ID: 64WjTbaduvu
dom/media/GraphDriver.cpp
dom/media/MediaStreamGraph.cpp
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -204,17 +204,18 @@ public:
           new AsyncCubebTask(previousDriver->AsAudioCallbackDriver(), AsyncCubebOperation::SHUTDOWN);
         releaseEvent->Dispatch();
 
         MonitorAutoLock mon(mDriver->mGraphImpl->GetMonitor());
         mDriver->SetPreviousDriver(nullptr);
       }
     } else {
       MonitorAutoLock mon(mDriver->mGraphImpl->GetMonitor());
-      MOZ_ASSERT(mDriver->mGraphImpl->MessagesQueued(), "Don't start a graph without messages queued.");
+      MOZ_ASSERT(mDriver->mGraphImpl->MessagesQueued() ||
+                 mDriver->mGraphImpl->mForceShutDown, "Don't start a graph without messages queued.");
       mDriver->mGraphImpl->SwapMessageQueues();
     }
     mDriver->RunThread();
     return NS_OK;
   }
 private:
   ThreadedDriver* mDriver;
 };
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -1409,16 +1409,24 @@ void
 MediaStreamGraphImpl::ForceShutDown(ShutdownTicket* aShutdownTicket)
 {
   NS_ASSERTION(NS_IsMainThread(), "Must be called on main thread");
   STREAM_LOG(LogLevel::Debug, ("MediaStreamGraph %p ForceShutdown", this));
   {
     MonitorAutoLock lock(mMonitor);
     mForceShutDown = true;
     mForceShutdownTicket = aShutdownTicket;
+    if (mLifecycleState == LIFECYCLE_THREAD_NOT_STARTED) {
+      // We *could* have just sent this a message to start up, so don't
+      // yank the rug out from under it.  Tell it to startup and let it
+      // shut down.
+      RefPtr<GraphDriver> driver = CurrentDriver();
+      MonitorAutoUnlock unlock(mMonitor);
+      driver->Start();
+    }
     EnsureNextIterationLocked();
   }
 }
 
 /* static */ StaticRefPtr<nsIAsyncShutdownBlocker> gMediaStreamGraphShutdownBlocker;
 
 namespace {