Bug 1408294 - Append null audio data when audio input underruns. r=padenot
authorAndreas Pehrson <pehrsons@mozilla.com>
Thu, 21 Dec 2017 19:01:17 +0100
changeset 456723 0fdd4ce7e10eb7d31fd0497012ba6ce622a8ad42
parent 456722 d0172a1b5d25894c3b56f5efc13a76919a3a54db
child 456724 c7bd57a9d7ef2010fe408ffab503077bc15f3e01
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1408294
milestone60.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 1408294 - Append null audio data when audio input underruns. r=padenot MozReview-Commit-ID: KEP3J41BEmJ
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
dom/media/webrtc/moz.build
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -548,18 +548,29 @@ MediaEngineWebRTCMicrophoneSource::Stop(
 
 void
 MediaEngineWebRTCMicrophoneSource::NotifyPull(MediaStreamGraph *aGraph,
                                               SourceMediaStream *aSource,
                                               TrackID aID,
                                               StreamTime aDesiredTime,
                                               const PrincipalHandle& aPrincipalHandle)
 {
-  // Ignore - we push audio data
   LOG_FRAMES(("NotifyPull, desired = %" PRId64, (int64_t) aDesiredTime));
+
+  StreamTime delta = aDesiredTime - aSource->GetEndOfAppendedData(aID);
+  if (delta <= 0) {
+    return;
+  }
+
+  // Not enough data has been pushed so we fill it with silence.
+  // This could be due to underruns or because we have been stopped.
+
+  AudioSegment audio;
+  audio.AppendNullData(delta);
+  aSource->AppendToTrack(aID, &audio);
 }
 
 void
 MediaEngineWebRTCMicrophoneSource::NotifyOutputData(MediaStreamGraph* aGraph,
                                                     AudioDataValue* aBuffer,
                                                     size_t aFrames,
                                                     TrackRate aRate,
                                                     uint32_t aChannels)
--- a/dom/media/webrtc/moz.build
+++ b/dom/media/webrtc/moz.build
@@ -35,16 +35,17 @@ if CONFIG['MOZ_WEBRTC']:
     ]
     # MediaEngineWebRTC.cpp needs to be built separately.
     SOURCES += [
         'MediaEngineWebRTC.cpp',
     ]
     LOCAL_INCLUDES += [
         '..',
         '/dom/base',
+        '/dom/media',
         '/media/libyuv/libyuv/include',
         '/media/webrtc/signaling/src/common',
         '/media/webrtc/signaling/src/common/browser_logging',
         '/media/webrtc/trunk'
     ]
 
 XPIDL_SOURCES += [
     'nsITabSource.idl'