Bug 1408294 - Append null audio data when audio input underruns. r?padenot
MozReview-Commit-ID: KEP3J41BEmJ
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -681,18 +681,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
@@ -36,16 +36,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'