From 36344a0c9b6ea00c733854294e98960138c11cff Mon Sep 17 00:00:00 2001 From: Jonathan Yu Date: Sun, 30 Jul 2017 01:55:34 -0700 Subject: [PATCH] Fix incorrect memset on muted frames. Broken by https://codereview.webrtc.org/2750783004/. Since samples are two bytes each, only half of the buffer was being zeroed, leading to garbage noise. BUG=webrtc:7885,webrtc:7343 Change-Id: I46ecf90258b681ccdebbcfadd2e84ac6abadc9fe Reviewed-on: https://chromium-review.googlesource.com/593092 Reviewed-by: Karl Wiberg Commit-Queue: Jonathan Yu Cr-Commit-Position: refs/heads/master@{#19194} --- webrtc/modules/audio_coding/acm2/audio_coding_module.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc index be8b1d91d8..1495818185 100644 --- a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc +++ b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc @@ -10,6 +10,8 @@ #include "webrtc/modules/audio_coding/include/audio_coding_module.h" +#include + #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" #include "webrtc/modules/audio_coding/acm2/acm_receiver.h" #include "webrtc/modules/audio_coding/acm2/acm_resampler.h" @@ -335,7 +337,7 @@ int DownMix(const AudioFrame& frame, static_cast(frame_data[2 * n + 1])) >> 1); } } else { - memset(out_buff, 0, frame.samples_per_channel_); + std::fill(out_buff, out_buff + frame.samples_per_channel_, 0); } return 0; } @@ -354,7 +356,7 @@ int UpMix(const AudioFrame& frame, size_t length_out_buff, int16_t* out_buff) { out_buff[2 * i] = sample; } } else { - memset(out_buff, 0, 2 * frame.samples_per_channel_); + std::fill(out_buff, out_buff + frame.samples_per_channel_ * 2, 0); } return 0; }