Bug 903023 - memset with 0 if the buffer of audio chunk is null. r=roc

This commit is contained in:
Shelly Lin 2013-08-14 11:04:52 +08:00
parent 880433f3e1
commit d35691b860

View File

@ -274,9 +274,8 @@ OpusTrackEncoder::GetEncodedTrack(nsTArray<uint8_t>* 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<uint8_t>* 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.