Bug 1125804 - Remove the mixer callback when failing to open an audio stream when switching to an audio driver. r=jesup
☠☠ backed out by 6260a7224a2d ☠ ☠
authorPaul Adenot <paul@paul.cx>
Mon, 09 Feb 2015 14:43:55 +0100
changeset 241785 0813db72fe3ea6f3d87cf9f9e6c699d7e27ab04f
parent 241784 47d0c95998a7d8bb3c0ece6a12df759e8fc273f2
child 241786 6260a7224a2d2b9214dcd1764b8e6e59e9e67f5f
child 241796 8090a0b684001c24f85b721182e4413b6dc5160e
push id619
push usercliu@mozilla.com
push dateMon, 09 Feb 2015 21:57:21 +0000
reviewersjesup
bugs1125804
milestone38.0a1
Bug 1125804 - Remove the mixer callback when failing to open an audio stream when switching to an audio driver. r=jesup
dom/media/GraphDriver.cpp
dom/media/MediaStreamGraphImpl.h
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -607,16 +607,18 @@ AudioCallbackDriver::Init()
     mAudioStream.own(stream);
   } else {
     NS_WARNING("Could not create a cubeb stream for MediaStreamGraph, falling back to a SystemClockDriver");
     // Fall back to a driver using a normal thread.
     mNextDriver = new SystemClockDriver(GraphImpl());
     mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd,
                                mStateComputedTime, mNextStateComputedTime);
     mGraphImpl->SetCurrentDriver(mNextDriver);
+    bool found = mGraphImpl->RemoveMixerCallback(this);
+    NS_WARN_IF_FALSE(!found, "Mixer callback not added when switching?");
     mNextDriver->Start();
     return;
   }
 
   cubeb_stream_register_device_changed_callback(mAudioStream,
                                                 AudioCallbackDriver::DeviceChangedCallback_s);
 
   StartStream();
--- a/dom/media/MediaStreamGraphImpl.h
+++ b/dom/media/MediaStreamGraphImpl.h
@@ -425,16 +425,21 @@ public:
   /**
    * Not safe to call off the MediaStreamGraph thread unless monitor is held!
    */
   GraphDriver* CurrentDriver() {
     AssertOnGraphThreadOrNotRunning();
     return mDriver;
   }
 
+  bool RemoveMixerCallback(MixerCallbackReceiver* aReceiver)
+  {
+    return mMixer.RemoveCallback(aReceiver);
+  }
+
   /**
    * Effectively set the new driver, while we are switching.
    * It is only safe to call this at the very end of an iteration, when there
    * has been a SwitchAtNextIteration call during the iteration. The driver
    * should return and pass the control to the new driver shortly after.
    * We can also switch from Revive() (on MainThread), in which case the
    * monitor is held
    */