Bug 1447982 - Rename mLastPrefs to mNetPrefs and update comment for clarity. r?padenot draft
authorAndreas Pehrson <pehrsons@mozilla.com>
Mon, 26 Mar 2018 12:24:17 +0200
changeset 781072 8398b602bb1a0e95f9ba39fde591deb18249811d
parent 781071 d515517731a94cc7dfc42d5855d19df132f61a62
push id106197
push userbmo:apehrson@mozilla.com
push dateThu, 12 Apr 2018 13:32:52 +0000
reviewerspadenot
bugs1447982
milestone61.0a1
Bug 1447982 - Rename mLastPrefs to mNetPrefs and update comment for clarity. r?padenot MozReview-Commit-ID: CJPSDG5OHBs
dom/media/webrtc/MediaEngineWebRTC.h
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
--- a/dom/media/webrtc/MediaEngineWebRTC.h
+++ b/dom/media/webrtc/MediaEngineWebRTC.h
@@ -599,19 +599,21 @@ private:
   uint64_t mLastLogFrames;
 
   // mSkipProcessing is true if none of the processing passes are enabled,
   // because of prefs or constraints. This allows simply copying the audio into
   // the MSG, skipping resampling and the whole webrtc.org code.
   // This is read and written to only on the MSG thread.
   bool mSkipProcessing;
 
-  // To only update microphone when needed, we keep track of previous settings.
+  // To only update microphone when needed, we keep track of the prefs
+  // representing the currently applied settings for this source. This is the
+  // net result of the prefs across all allocations.
   // Owning thread only.
-  MediaEnginePrefs mLastPrefs;
+  MediaEnginePrefs mNetPrefs;
 
   // Stores the mixed audio output for the reverse-stream of the AEC.
   AlignedFloatBuffer mOutputBuffer;
 
   AlignedFloatBuffer mInputBuffer;
   AlignedFloatBuffer mDeinterleavedBuffer;
   AlignedFloatBuffer mInputDownmixBuffer;
 };
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -245,17 +245,17 @@ MediaEngineWebRTCMicrophoneSource::Recon
     LOG(("Mic source %p Reconfigure() failed unexpectedly. rv=%s",
          this, name.Data()));
     Stop(aHandle);
     return NS_ERROR_UNEXPECTED;
   }
 
   size_t i = mAllocations.IndexOf(aHandle, 0, AllocationHandleComparator());
   MOZ_DIAGNOSTIC_ASSERT(i != mAllocations.NoIndex);
-  ApplySettings(mLastPrefs, mAllocations[i].mStream->GraphImpl());
+  ApplySettings(mNetPrefs, mAllocations[i].mStream->GraphImpl());
 
   return NS_OK;
 }
 
 bool operator == (const MediaEnginePrefs& a, const MediaEnginePrefs& b)
 {
   return !memcmp(&a, &b, sizeof(MediaEnginePrefs));
 };
@@ -466,34 +466,34 @@ MediaEngineWebRTCMicrophoneSource::Updat
         mAudioInput->GetChannelCount(channelCount);
         MOZ_ASSERT(channelCount > 0);
         prefs.mChannels = channelCount;
       }
       break;
 
     case kStarted:
     case kStopped:
-      if (prefs.mChannels != mLastPrefs.mChannels) {
+      if (prefs.mChannels != mNetPrefs.mChannels) {
         // If the channel count changed, tell the MSG to open a new driver with
         // the correct channel count.
         MOZ_ASSERT(!mAllocations.IsEmpty());
         RefPtr<SourceMediaStream> stream;
         for (const Allocation& allocation : mAllocations) {
           if (allocation.mStream && allocation.mStream->GraphImpl()) {
             stream = allocation.mStream;
             break;
           }
         }
         MOZ_ASSERT(stream);
 
         mAudioInput->SetUserChannelCount(prefs.mChannels);
         // Get validated number of channel
         uint32_t channelCount = 0;
         mAudioInput->GetChannelCount(channelCount);
-        MOZ_ASSERT(channelCount > 0 && mLastPrefs.mChannels > 0);
+        MOZ_ASSERT(channelCount > 0 && mNetPrefs.mChannels > 0);
         if (!stream->OpenNewAudioCallbackDriver(mListener)) {
           MOZ_LOG(GetMediaManagerLog(), LogLevel::Error, ("Could not open a new AudioCallbackDriver for input"));
           return NS_ERROR_FAILURE;
         }
       }
       break;
 
     default:
@@ -514,17 +514,17 @@ MediaEngineWebRTCMicrophoneSource::Updat
     UpdateNSSettingsIfNeeded(prefs.mNoiseOn, static_cast<NsModes>(prefs.mNoise));
     UpdateAECSettingsIfNeeded(prefs.mAecOn, static_cast<EcModes>(prefs.mAec));
 
     webrtc::Config config;
     config.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(mExtendedFilter));
     config.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(mDelayAgnostic));
     mAudioProcessing->SetExtraOptions(config);
   }
-  mLastPrefs = prefs;
+  mNetPrefs = prefs;
   return NS_OK;
 }
 
 #undef HANDLE_APM_ERROR
 
 void
 MediaEngineWebRTCMicrophoneSource::ApplySettings(const MediaEnginePrefs& aPrefs,
                                                  RefPtr<MediaStreamGraphImpl> aGraph)