Bug 1415556 - P7. Remove unecessary locking. r?padenot. draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 10 Nov 2017 18:53:23 +0100
changeset 696815 8ceb1d63acc90cc4a6d67abddf8716ad4c1ea8e5
parent 696753 79db6cec9548275d14012ba7d112a72ba44a5756
child 696816 716e2b13ddfa852b5f5bad1d2f6cfd4bca1bdd93
push id88795
push userbmo:jyavenard@mozilla.com
push dateSat, 11 Nov 2017 15:24:04 +0000
reviewerspadenot
bugs1415556
milestone58.0a1
Bug 1415556 - P7. Remove unecessary locking. r?padenot. mForceShutdownTicket and mShutdownTimer are only ever accessed on the main thread. We don't need the use of the monitor to reset them. MozReview-Commit-ID: 1DL8bLmzEH5
dom/media/MediaStreamGraph.cpp
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -1526,45 +1526,44 @@ MediaStreamGraphImpl::ApplyStreamUpdate(
 }
 
 void
 MediaStreamGraphImpl::ForceShutDown(media::ShutdownTicket* aShutdownTicket)
 {
   NS_ASSERTION(NS_IsMainThread(), "Must be called on main thread");
   LOG(LogLevel::Debug, ("MediaStreamGraph %p ForceShutdown", this));
 
-  MonitorAutoLock lock(mMonitor);
   if (aShutdownTicket) {
     MOZ_ASSERT(!mForceShutdownTicket);
     // Avoid waiting forever for a graph to shut down
     // synchronously.  Reports are that some 3rd-party audio drivers
     // occasionally hang in shutdown (both for us and Chrome).
     NS_NewTimerWithCallback(getter_AddRefs(mShutdownTimer),
                             this,
                             MediaStreamGraph::AUDIO_CALLBACK_DRIVER_SHUTDOWN_TIMEOUT,
                             nsITimer::TYPE_ONE_SHOT);
   }
+  mForceShutdownTicket = aShutdownTicket;
+  MonitorAutoLock lock(mMonitor);
   mForceShutDown = true;
-  mForceShutdownTicket = aShutdownTicket;
   if (LifecycleStateRef() == 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();
 }
 
 NS_IMETHODIMP
 MediaStreamGraphImpl::Notify(nsITimer* aTimer)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MonitorAutoLock lock(mMonitor);
   NS_ASSERTION(!mForceShutdownTicket, "MediaStreamGraph took too long to shut down!");
   // Sigh, graph took too long to shut down.  Stop blocking system
   // shutdown and hope all is well.
   mForceShutdownTicket = nullptr;
   return NS_OK;
 }
 
 NS_IMETHODIMP