Bug 1447982 - Pass GraphImpl into ApplySettings. r?padenot
MozReview-Commit-ID: GQlRUB3O1em
--- a/dom/media/webrtc/MediaEngineWebRTC.h
+++ b/dom/media/webrtc/MediaEngineWebRTC.h
@@ -528,17 +528,18 @@ private:
const nsString& aDeviceId,
const char** aOutBadConstraint);
void UpdateAECSettingsIfNeeded(bool aEnable, webrtc::EcModes aMode);
void UpdateAGCSettingsIfNeeded(bool aEnable, webrtc::AgcModes aMode);
void UpdateNSSettingsIfNeeded(bool aEnable, webrtc::NsModes aMode);
- void ApplySettings(const MediaEnginePrefs& aPrefs);
+ void ApplySettings(const MediaEnginePrefs& aPrefs,
+ RefPtr<MediaStreamGraphImpl> aGraph);
bool HasEnabledTrack() const;
template<typename T>
void InsertInGraph(const T* aBuffer,
size_t aFrames,
uint32_t aChannels);
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -243,17 +243,19 @@ MediaEngineWebRTCMicrophoneSource::Recon
nsAutoCString name;
GetErrorName(rv, name);
LOG(("Mic source %p Reconfigure() failed unexpectedly. rv=%s",
this, name.Data()));
Stop(aHandle);
return NS_ERROR_UNEXPECTED;
}
- ApplySettings(mLastPrefs);
+ size_t i = mAllocations.IndexOf(aHandle, 0, AllocationHandleComparator());
+ MOZ_DIAGNOSTIC_ASSERT(i != mAllocations.NoIndex);
+ ApplySettings(mLastPrefs, mAllocations[i].mStream->GraphImpl());
return NS_OK;
}
bool operator == (const MediaEnginePrefs& a, const MediaEnginePrefs& b)
{
return !memcmp(&a, &b, sizeof(MediaEnginePrefs));
};
@@ -523,30 +525,24 @@ MediaEngineWebRTCMicrophoneSource::Updat
}
mLastPrefs = prefs;
return NS_OK;
}
#undef HANDLE_APM_ERROR
void
-MediaEngineWebRTCMicrophoneSource::ApplySettings(const MediaEnginePrefs& aPrefs)
+MediaEngineWebRTCMicrophoneSource::ApplySettings(const MediaEnginePrefs& aPrefs,
+ RefPtr<MediaStreamGraphImpl> aGraph)
{
AssertIsOnOwningThread();
+ MOZ_DIAGNOSTIC_ASSERT(aGraph);
RefPtr<MediaEngineWebRTCMicrophoneSource> that = this;
- RefPtr<MediaStreamGraphImpl> graph;
- for (const Allocation& allocation : mAllocations) {
- if (allocation.mStream && allocation.mStream->GraphImpl()) {
- graph = allocation.mStream->GraphImpl();
- break;
- }
- }
- MOZ_DIAGNOSTIC_ASSERT(graph);
- NS_DispatchToMainThread(media::NewRunnableFrom([that, graph, aPrefs]() mutable {
+ NS_DispatchToMainThread(media::NewRunnableFrom([that, graph = Move(aGraph), aPrefs]() mutable {
that->mSettings->mEchoCancellation.Value() = aPrefs.mAecOn;
that->mSettings->mAutoGainControl.Value() = aPrefs.mAgcOn;
that->mSettings->mNoiseSuppression.Value() = aPrefs.mNoiseOn;
that->mSettings->mChannelCount.Value() = aPrefs.mChannels;
class Message : public ControlMessage {
public:
Message(MediaEngineWebRTCMicrophoneSource* aSource,
@@ -729,17 +725,17 @@ MediaEngineWebRTCMicrophoneSource::Start
// Must be *before* StartSend() so it will notice we selected external input (full_duplex)
mAudioInput->StartRecording(allocation.mStream, mListener);
MOZ_ASSERT(mState != kReleased);
mState = kStarted;
}
- ApplySettings(mLastPrefs);
+ ApplySettings(mNetPrefs, allocation.mStream->GraphImpl());
return NS_OK;
}
nsresult
MediaEngineWebRTCMicrophoneSource::Stop(const RefPtr<const AllocationHandle>& aHandle)
{
AssertIsOnOwningThread();