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 249661 13bf0a02fa62c68c7c19dbd90b1f6e1ce748fcfe
parent 249660 d5d2d9c8e4f39392864baea78632bcee0f4a449d
child 249662 b316d3771537ddf413b47a17c1ec606614a0125f
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, sledru
bugs1125804
milestone37.0a2
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
    */