Bug 1268861 - Insert the input data first and then run the graph iteration. r?jesup draft
authorPaul Adenot <paul@paul.cx>
Fri, 29 Apr 2016 14:17:50 +0200
changeset 357796 a3d85a2e5d310ad2cdd24f97c7ae90928753fcb2
parent 357794 e3b7c788a3a5aa887933a0530dfd934dca8e9d5d
child 519708 33b58099f9d0a1a7abb5b407feb9a6f0c9b90eb6
push id16848
push userpaul@paul.cx
push dateFri, 29 Apr 2016 12:18:13 +0000
reviewersjesup
bugs1268861
milestone49.0a1
Bug 1268861 - Insert the input data first and then run the graph iteration. r?jesup This allows the graph to immediately process the input data instead of waiting an iterationq MozReview-Commit-ID: Cx9laCjcQYf
dom/media/GraphDriver.cpp
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -838,16 +838,25 @@ AudioCallbackDriver::DataCallback(const 
   // duration so there is some damping against sudden changes.
   if (!mIterationDurationMS) {
     mIterationDurationMS = durationMS;
   } else {
     mIterationDurationMS = (mIterationDurationMS*3) + durationMS;
     mIterationDurationMS /= 4;
   }
 
+  // Process mic data if any/needed
+  if (aInputBuffer) {
+    if (mAudioInput) { // for this specific input-only or full-duplex stream
+      mAudioInput->NotifyInputData(mGraphImpl, aInputBuffer,
+                                   static_cast<size_t>(aFrames),
+                                   mSampleRate, mInputChannels);
+    }
+  }
+
   mBuffer.SetBuffer(aOutputBuffer, aFrames);
   // fill part or all with leftover data from last iteration (since we
   // align to Audio blocks)
   mScratchBuffer.Empty(mBuffer);
   // if we totally filled the buffer (and mScratchBuffer isn't empty),
   // we don't need to run an iteration and if we do so we may overflow.
   if (mBuffer.Available()) {
 
@@ -894,25 +903,16 @@ AudioCallbackDriver::DataCallback(const 
   // Callback any observers for the AEC speaker data.  Note that one
   // (maybe) of these will be full-duplex, the others will get their input
   // data off separate cubeb callbacks.  Take care with how stuff is
   // removed/added to this list and TSAN issues, but input and output will
   // use separate callback methods.
   mGraphImpl->NotifyOutputData(aOutputBuffer, static_cast<size_t>(aFrames),
                                mSampleRate, ChannelCount);
 
-  // Process mic data if any/needed -- after inserting far-end data for AEC!
-  if (aInputBuffer) {
-    if (mAudioInput) { // for this specific input-only or full-duplex stream
-      mAudioInput->NotifyInputData(mGraphImpl, aInputBuffer,
-                                   static_cast<size_t>(aFrames),
-                                   mSampleRate, mInputChannels);
-    }
-  }
-
   bool switching = false;
   {
     MonitorAutoLock mon(mGraphImpl->GetMonitor());
     switching = !!NextDriver();
   }
 
   if (switching && stillProcessing) {
     // If the audio stream has not been started by the previous driver or