Bug 1497751 update driver state before handing control to another thread r=achronop
authorKarl Tomlinson <karlt+@karlt.net>
Sat, 13 Oct 2018 12:45:18 +1300
changeset 499548 22f5c9171d258adadc703aca664bbca476fa441a
parent 499547 f7c32e7abf7293b99c6d1941af6e15ebc3119d5c
child 499549 3ee73bef9537d1d2f09d397150238523be4f6891
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersachronop
bugs1497751
milestone64.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 1497751 update driver state before handing control to another thread r=achronop Differential Revision: https://phabricator.services.mozilla.com/D8180
dom/media/GraphDriver.cpp
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -1032,22 +1032,22 @@ AudioCallbackDriver::DataCallback(const 
   GraphImpl()->NotifyOutputData(aOutputBuffer, static_cast<size_t>(aFrames),
                                 mSampleRate, mOutputChannels);
 
   if (!stillProcessing) {
     // About to hand over control of the graph.  Do not start a new driver if
     // StateCallback() receives an error for this stream while the main thread
     // or another driver has control of the graph.
     mShouldFallbackIfError = false;
+    RemoveMixerCallback();
+    // Update the flag before handing over the graph and going to drain.
+    mAudioThreadRunning = false;
     // Enter shutdown mode. The stable-state handler will detect this
     // and complete shutdown if the graph does not get restarted.
     mGraphImpl->SignalMainThreadCleanup();
-    RemoveMixerCallback();
-    // Update the flag before go to drain
-    mAudioThreadRunning = false;
     return aFrames - 1;
   }
 
   bool switching = false;
   {
     MonitorAutoLock mon(GraphImpl()->GetMonitor());
     switching = !!NextDriver();
   }
@@ -1057,18 +1057,18 @@ AudioCallbackDriver::DataCallback(const 
     // If the audio stream has not been started by the previous driver or
     // the graph itself, keep it alive.
     MonitorAutoLock mon(GraphImpl()->GetMonitor());
     if (!IsStarted()) {
       return aFrames;
     }
     LOG(LogLevel::Debug, ("%p: Switching to system driver.", GraphImpl()));
     RemoveMixerCallback();
+    mAudioThreadRunning = false;
     SwitchToNextDriver();
-    mAudioThreadRunning = false;
     // Returning less than aFrames starts the draining and eventually stops the
     // audio thread. This function will never get called again.
     return aFrames - 1;
   }
 
   return aFrames;
 }