From e182c000289e32f7a42d0b7c570a45839c887c84 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Wed, 9 Sep 2015 08:52:39 +1200 Subject: [PATCH] bug 1205540 don't send more null chunks than necessary to AnalyserNode r=padenot --HG-- extra : rebase_source : f758d172fbbdba3288c71f690411175a41a822cc --- dom/media/webaudio/AnalyserNode.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dom/media/webaudio/AnalyserNode.cpp b/dom/media/webaudio/AnalyserNode.cpp index cf8ce8c47836..35d6c9b35161 100644 --- a/dom/media/webaudio/AnalyserNode.cpp +++ b/dom/media/webaudio/AnalyserNode.cpp @@ -65,6 +65,19 @@ public: { *aOutput = aInput; + if (aInput.IsNull()) { + // If AnalyserNode::mChunks has only null chunks, then there is no need + // to send further null chunks. + if (mChunksToProcess == 0) { + return; + } + + --mChunksToProcess; + } else { + // This many null chunks will be required to empty AnalyserNode::mChunks. + mChunksToProcess = CHUNK_COUNT; + } + nsRefPtr transfer = new TransferBuffer(aStream, aInput.AsAudioChunk()); NS_DispatchToMainThread(transfer); @@ -74,6 +87,8 @@ public: { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } + + size_t mChunksToProcess = 0; }; AnalyserNode::AnalyserNode(AudioContext* aContext)