Bug 1480856 - Allow for another 10ms of silence when processing audio input. r=achronop
authorAndreas Pehrson <apehrson@mozilla.com>
Tue, 07 Aug 2018 21:02:41 +0000
changeset 430436 b118b720b2c7c94b634c86350b83014c2840e7bf
parent 430435 2ab02d99fe7e1733f20429d2228f261b97b34d85
child 430437 a7067dbdc7b5690d781490c80f5cd5212a00c7c5
push id34405
push userncsoregi@mozilla.com
push dateWed, 08 Aug 2018 09:57:26 +0000
treeherdermozilla-central@c65991f3fa10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersachronop
bugs1480856
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1480856 - Allow for another 10ms of silence when processing audio input. r=achronop Differential Revision: https://phabricator.services.mozilla.com/D2786
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -873,16 +873,31 @@ MediaEngineWebRTCMicrophoneSource::Pull(
     if (!mAllocations[i].mLiveFramesAppended ||
         !mAllocations[i].mLiveSilenceAppended) {
       // These are the iterations after starting or resuming audio capture.
       // Make sure there's at least one extra block buffered until audio
       // callbacks come in. We also allow appending silence one time after
       // audio callbacks have started, to cover the case where audio callbacks
       // start appending data immediately and there is no extra data buffered.
       delta += WEBAUDIO_BLOCK_SIZE;
+
+      // If we're supposed to be packetizing but there's no packetizer yet,
+      // there must not have been any live frames appended yet.
+      // If there were live frames appended and we haven't appended the
+      // right amount of silence, we'll have to append silence once more,
+      // failing the other assert below.
+      MOZ_ASSERT_IF(!PassThrough(aStream->GraphImpl()) && !mPacketizerInput,
+                    !mAllocations[i].mLiveFramesAppended);
+
+      if (!PassThrough(aStream->GraphImpl()) && mPacketizerInput) {
+        // Processing is active and is processed in chunks of 10ms through the
+        // input packetizer. We allow for 10ms of silence on the track to
+        // accomodate the buffering worst-case.
+        delta += mPacketizerInput->PacketSize();
+      }
     }
 
     LOG_FRAMES(("Pulling %" PRId64 " frames of silence for allocation %p",
                 delta, mAllocations[i].mHandle.get()));
 
     // This assertion fails when we append silence here in the same iteration
     // as there were real audio samples already appended by the audio callback.
     // Note that this is exempted until live samples and a subsequent chunk of