# HG changeset patch # User Andreas Pehrson # Date 1512481031 -3600 # Tue Dec 05 14:37:11 2017 +0100 # Node ID 484ae7c12c96f6ef3687cd023a8b230c16079f0d # Parent 359484c0461ec0fecdcd81c1d4f3a14c96cedd71 Bug 1408294 - Make the SourceMediaStream used with AudioCapture produce silence. r=padenot This SourceMediaStream is an existing hack to fit AudioCapture into MediaManager's gUM flow. With the invariant that NotifyPull must produce data we need to produce silence here. Best of all would be if this SourceMediaStream was not needed at all, but let's look at that another time. MozReview-Commit-ID: J3EeIut1fgy diff --git a/dom/media/webrtc/MediaEngineWebRTC.h b/dom/media/webrtc/MediaEngineWebRTC.h --- a/dom/media/webrtc/MediaEngineWebRTC.h +++ b/dom/media/webrtc/MediaEngineWebRTC.h @@ -109,17 +109,27 @@ public: const AudioDataValue* aBuffer, size_t aFrames, TrackRate aRate, uint32_t aChannels) override {} void NotifyPull(MediaStreamGraph* aGraph, SourceMediaStream* aSource, TrackID aID, StreamTime aDesiredTime, const PrincipalHandle& aPrincipalHandle) override - {} + { + // The AudioCapture setup code in MediaManager creates a dummy + // SourceMediaStream that is not actually exposed to content. + // We append null data here just to keep the MediaStreamGraph happy. + StreamTime delta = aDesiredTime - aSource->GetEndOfAppendedData(aID); + if (delta > 0) { + AudioSegment segment; + segment.AppendNullData(delta); + aSource->AppendToTrack(aID, &segment); + } + } dom::MediaSourceEnum GetMediaSource() const override { return dom::MediaSourceEnum::AudioCapture; } bool IsFake() override { return false; }