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 489358 22f5c9171d258adadc703aca664bbca476fa441a
parent 489357 f7c32e7abf7293b99c6d1941af6e15ebc3119d5c
child 489359 3ee73bef9537d1d2f09d397150238523be4f6891
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersachronop
bugs1497751
milestone64.0a1
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;
 }