diff --git a/content/media/AudioNodeExternalInputStream.cpp b/content/media/AudioNodeExternalInputStream.cpp index c2ff882a40489c5cab60fa498a2689f388f76e1d..50d61dba0eb5aff72c8b642fa923c308fbd0e7d1 100644 --- a/content/media/AudioNodeExternalInputStream.cpp +++ b/content/media/AudioNodeExternalInputStream.cpp @@ -437,17 +437,22 @@ AudioNodeExternalInputStream::ProcessInput(GraphTime aFrom, GraphTime aTo, } } + uint32_t accumulateIndex = 0; if (inputChannels) { - AllocateAudioBlock(inputChannels, &mLastChunks[0]); nsAutoTArray<float,GUESS_AUDIO_CHANNELS*WEBAUDIO_BLOCK_SIZE> downmixBuffer; for (uint32_t i = 0; i < audioSegments.Length(); ++i) { AudioChunk tmpChunk; ConvertSegmentToAudioBlock(&audioSegments[i], &tmpChunk); if (!tmpChunk.IsNull()) { - AccumulateInputChunk(i, tmpChunk, &mLastChunks[0], &downmixBuffer); + if (accumulateIndex == 0) { + AllocateAudioBlock(inputChannels, &mLastChunks[0]); + } + AccumulateInputChunk(accumulateIndex, tmpChunk, &mLastChunks[0], &downmixBuffer); + accumulateIndex++; } } - } else { + } + if (accumulateIndex == 0) { mLastChunks[0].SetNull(WEBAUDIO_BLOCK_SIZE); } mCurrentOutputPosition += WEBAUDIO_BLOCK_SIZE;