From d35691b86051694a45fe3196a6b5039b57009822 Mon Sep 17 00:00:00 2001 From: Shelly Lin Date: Wed, 14 Aug 2013 11:04:52 +0800 Subject: [PATCH] Bug 903023 - memset with 0 if the buffer of audio chunk is null. r=roc --- content/media/encoder/OpusTrackEncoder.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/content/media/encoder/OpusTrackEncoder.cpp b/content/media/encoder/OpusTrackEncoder.cpp index 760578e6054..d397a876481 100644 --- a/content/media/encoder/OpusTrackEncoder.cpp +++ b/content/media/encoder/OpusTrackEncoder.cpp @@ -274,9 +274,8 @@ OpusTrackEncoder::GetEncodedTrack(nsTArray* aOutput, InterleaveTrackData(chunk, frameToCopy, mChannels, pcm.Elements() + frameCopied * mChannels); } else { - for (int i = 0; i < frameToCopy * mChannels; i++) { - pcm.AppendElement(0); - } + memset(pcm.Elements() + frameCopied * mChannels, 0, + frameToCopy * mChannels * sizeof(AudioDataValue)); } frameCopied += frameToCopy; @@ -301,9 +300,8 @@ OpusTrackEncoder::GetEncodedTrack(nsTArray* aOutput, // Append null data to pcm buffer if the leftover data is not enough for // opus encoder. if (frameCopied < GetPacketDuration() && mEndOfStream) { - for (int i = frameCopied * mChannels; i < GetPacketDuration() * mChannels; i++) { - pcm.AppendElement(0); - } + memset(pcm.Elements() + frameCopied * mChannels, 0, + (GetPacketDuration()-frameCopied)*mChannels*sizeof(AudioDataValue)); } // Encode the data with Opus Encoder.