Bug 1250934: Don't reopen input AudioCallbackDrivers on a second use r?padenot
MozReview-Commit-ID: A8Xibvg484X
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -975,29 +975,35 @@ MediaStreamGraphImpl::OpenAudioInputImpl
// XXX Since we can't rely on IDs staying valid (ugh), use the listener as
// a stand-in for the ID. Fix as part of support for multiple-captures
// (Bug 1238038)
uint32_t count = 0;
mInputDeviceUsers.Get(aListener, &count); // ok if this fails
count++;
mInputDeviceUsers.Put(aListener, count); // creates a new entry in the hash if needed
- // aID is a cubeb_devid, and we assume that opaque ptr is valid until
- // we close cubeb.
- mInputDeviceID = aID;
if (count == 1) { // first open for this listener
+ // aID is a cubeb_devid, and we assume that opaque ptr is valid until
+ // we close cubeb.
+ mInputDeviceID = aID;
mAudioInputs.AppendElement(aListener); // always monitor speaker data
- }
-
- // Switch Drivers since we're adding input (to input-only or full-duplex)
- MonitorAutoLock mon(mMonitor);
- if (mLifecycleState == LIFECYCLE_RUNNING) {
- AudioCallbackDriver* driver = new AudioCallbackDriver(this);
- driver->SetInputListener(aListener);
- CurrentDriver()->SwitchAtNextIteration(driver);
+
+ // Switch Drivers since we're adding input (to input-only or full-duplex)
+ MonitorAutoLock mon(mMonitor);
+ if (mLifecycleState == LIFECYCLE_RUNNING) {
+ AudioCallbackDriver* driver = new AudioCallbackDriver(this);
+ STREAM_LOG(LogLevel::Debug, ("OpenAudioInput: starting new AudioCallbackDriver(input) %p", driver));
+ LIFECYCLE_LOG("OpenAudioInput: starting new AudioCallbackDriver(input) %p", driver);
+ driver->SetInputListener(aListener);
+ CurrentDriver()->SwitchAtNextIteration(driver);
+ } else {
+ STREAM_LOG(LogLevel::Error, ("OpenAudioInput in shutdown!"));
+ LIFECYCLE_LOG("OpenAudioInput in shutdown!");
+ NS_ASSERTION(false, "Can't open cubeb inputs in shutdown");
+ }
}
}
nsresult
MediaStreamGraphImpl::OpenAudioInput(CubebUtils::AudioDeviceID aID,
AudioDataListener *aListener)
{
// So, so, so annoying. Can't AppendMessage except on Mainthread