Bug 1503536 - Call ApplySettings in MediaEngineWebRTCMicrophoneSource::Start. r=pehrsons, a=jcristau
authorPaul Adenot <paul@paul.cx>
Wed, 31 Oct 2018 12:57:38 +0100
changeset 501214 929f848d3a54977c8b6ea468fff80954cafa6bf0
parent 501213 d525167ebef78d9c2ef8a863618d9410159ecfd4
child 501215 b9bddcf6d4659e0c6b764de1dc6fdcc7727db3e0
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons, jcristau
bugs1503536
milestone64.0
Bug 1503536 - Call ApplySettings in MediaEngineWebRTCMicrophoneSource::Start. r=pehrsons, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D10347
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
dom/media/webrtc/MediaEngineWebRTCAudio.h
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -198,16 +198,18 @@ MediaEngineWebRTCMicrophoneSource::Recon
          this,
          name.Data()));
     Stop(nullptr);
     return NS_ERROR_UNEXPECTED;
   }
 
   ApplySettings(outputPrefs);
 
+  mCurrentPrefs = outputPrefs;
+
   return NS_OK;
 }
 
 void
 MediaEngineWebRTCMicrophoneSource::Pull(
   const RefPtr<const AllocationHandle>&,
   const RefPtr<SourceMediaStream>& aStream,
   TrackID aTrackID,
@@ -491,16 +493,18 @@ MediaEngineWebRTCMicrophoneSource::Alloc
     media::NewRunnableFrom([that, prefs = outputPrefs]() mutable {
       that->mSettings->mEchoCancellation.Value() = prefs.mAecOn;
       that->mSettings->mAutoGainControl.Value() = prefs.mAgcOn;
       that->mSettings->mNoiseSuppression.Value() = prefs.mNoiseOn;
       that->mSettings->mChannelCount.Value() = prefs.mChannels;
       return NS_OK;
     }));
 
+  mCurrentPrefs = outputPrefs;
+
   return rv;
 }
 
 nsresult
 MediaEngineWebRTCMicrophoneSource::Deallocate(
   const RefPtr<const AllocationHandle>&)
 {
   AssertIsOnOwningThread();
@@ -649,35 +653,35 @@ MediaEngineWebRTCMicrophoneSource::Start
       mStream->GraphImpl()->InputDeviceID() != deviceID) {
     // For now, we only allow opening a single audio input device per document,
     // because we can only have one MSG per document.
     return NS_ERROR_FAILURE;
   }
 
 
 
-  if (!mInputProcessing) {
-    mInputProcessing = new AudioInputProcessing(
-      mDeviceMaxChannelCount, mStream, mTrackID, mPrincipal);
-  }
+  mInputProcessing = new AudioInputProcessing(
+    mDeviceMaxChannelCount, mStream, mTrackID, mPrincipal);
 
   RefPtr<MediaEngineWebRTCMicrophoneSource> that = this;
   RefPtr<MediaStreamGraphImpl> gripGraph = mStream->GraphImpl();
   NS_DispatchToMainThread(media::NewRunnableFrom(
     [that, graph = std::move(gripGraph), deviceID]() mutable {
       if (graph) {
         graph->AppendMessage(MakeUnique<StartStopMessage>(
           that->mInputProcessing, StartStopMessage::Start));
       }
 
       that->mStream->OpenAudioInput(deviceID, that->mInputProcessing);
 
       return NS_OK;
     }));
 
+  ApplySettings(mCurrentPrefs);
+
   MOZ_ASSERT(mState != kReleased);
   mState = kStarted;
 
   return NS_OK;
 }
 
 nsresult
 MediaEngineWebRTCMicrophoneSource::Stop(const RefPtr<const AllocationHandle>&)
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.h
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.h
@@ -131,16 +131,19 @@ private:
   // Constructed on the MediaManager thread, and then only ever accessed on the
   // main thread.
   const nsMainThreadPtrHandle<media::Refcountable<dom::MediaTrackSettings>>
     mSettings;
 
   // Current state of the resource for this source.
   MediaEngineSourceState mState;
 
+  // The current preferences for the APM's various processing stages.
+  MediaEnginePrefs mCurrentPrefs;
+
   // The SourecMediaStream on which to append data for this microphone. Set in
   // SetTrack as part of the initialization, and nulled in ::Deallocate.
   RefPtr<SourceMediaStream> mStream;
 
   // See note at the top of this class.
   RefPtr<AudioInputProcessing> mInputProcessing;
 };