Bug 1258144: Don't start a thread for SystemClockDriver if already started r=padenot
authorRandell Jesup <rjesup@jesup.org>
Tue, 22 Mar 2016 11:30:06 +0100
changeset 289852 39cfff135061a1754c5e475a3b918c5c535304cf
parent 289851 c7c047192403fc82f9576895136f133a7613e01d
child 289853 f8c07a51e7ce426f17f3998ed646d9f0300d331c
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1258144
milestone48.0a1
Bug 1258144: Don't start a thread for SystemClockDriver if already started r=padenot
dom/media/GraphDriver.cpp
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -222,21 +222,24 @@ public:
 private:
   ThreadedDriver* mDriver;
 };
 
 void
 ThreadedDriver::Start()
 {
   LIFECYCLE_LOG("Starting thread for a SystemClockDriver  %p\n", mGraphImpl);
-  nsCOMPtr<nsIRunnable> event = new MediaStreamGraphInitThreadRunnable(this);
-  // Note: mThread may be null during event->Run() if we pass to NewNamedThread!  See AudioInitTask
-  nsresult rv = NS_NewNamedThread("MediaStreamGrph", getter_AddRefs(mThread));
-  if (NS_SUCCEEDED(rv)) {
-    mThread->Dispatch(event, NS_DISPATCH_NORMAL);
+  NS_WARN_IF(!mThread);
+  if (!mThread) { // Ensure we haven't already started it
+    nsCOMPtr<nsIRunnable> event = new MediaStreamGraphInitThreadRunnable(this);
+    // Note: mThread may be null during event->Run() if we pass to NewNamedThread!  See AudioInitTask
+    nsresult rv = NS_NewNamedThread("MediaStreamGrph", getter_AddRefs(mThread));
+    if (NS_SUCCEEDED(rv)) {
+      mThread->Dispatch(event, NS_DISPATCH_NORMAL);
+    }
   }
 }
 
 void
 ThreadedDriver::Resume()
 {
   Start();
 }