Bug 1125804 - Remove the mixer callback when failing to open an audio stream when switching to an audio driver. r=jesup
--- 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
*/