Bug 1125804 - Remove the mixer callback when failing to open an audio stream when switching to an audio driver. r=jesup, a=sledru
authorPaul Adenot <paul@paul.cx>
Mon, 09 Feb 2015 14:43:55 +0100
changeset 243737 1584db7257a6
parent 243736 9a36ec122aa5
child 243738 cd43e5143e7f
child 243740 b84238ca8b98
child 243742 ff6bff2f5694
push id4456
push userryanvm@gmail.com
push date2015-02-09 21:51 +0000
treeherdermozilla-beta@1584db7257a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, sledru
bugs1125804
milestone36.0
Bug 1125804 - Remove the mixer callback when failing to open an audio stream when switching to an audio driver. r=jesup, a=sledru
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);
+    DebugOnly<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
    */