Fix Valgrind warnings in audio_processing.

Review URL: http://webrtc-codereview.appspot.com/119001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@408 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2011-08-19 21:22:08 +00:00
parent f53055d60e
commit 6423509efc
5 changed files with 32 additions and 8 deletions

View File

@ -420,7 +420,10 @@ WebRtc_Word32 WebRtcAec_Process(void *aecInst, const WebRtc_Word16 *nearend,
nBlocks10ms = nFrames / aecpc->aec->mult;
if (aecpc->ECstartup) {
memcpy(out, nearend, sizeof(short) * nrOfSamples);
if (nearend != out) {
// Only needed if they don't already point to the same place.
memcpy(out, nearend, sizeof(short) * nrOfSamples);
}
nmbrOfFilledBuffers = WebRtcApm_get_buffer_size(aecpc->farendBuf) / FRAME_LEN;
// The AEC is in the start up mode

View File

@ -1317,10 +1317,19 @@ int WebRtcAgc_Process(void *agcInst, const WebRtc_Word16 *in_near,
*outMicLevel = inMicLevel;
inMicLevelTmp = inMicLevel;
memcpy(out, in_near, samples * sizeof(WebRtc_Word16));
// TODO(andrew): clearly we don't need input and output pointers...
// Change the interface to take a shared input/output.
if (in_near != out)
{
// Only needed if they don't already point to the same place.
memcpy(out, in_near, samples * sizeof(WebRtc_Word16));
}
if (stt->fs == 32000)
{
memcpy(out_H, in_near_H, samples * sizeof(WebRtc_Word16));
if (in_near_H != out_H)
{
memcpy(out_H, in_near_H, samples * sizeof(WebRtc_Word16));
}
}
#ifdef AGC_DEBUG//test log

View File

@ -327,10 +327,18 @@ WebRtc_Word32 WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const WebRtc_Word16 *i
return -1;
}
memcpy(out, in_near, 10 * L * sizeof(WebRtc_Word16));
// TODO(andrew): again, we don't need input and output pointers...
if (in_near != out)
{
// Only needed if they don't already point to the same place.
memcpy(out, in_near, 10 * L * sizeof(WebRtc_Word16));
}
if (FS == 32000)
{
memcpy(out_H, in_near_H, 10 * L * sizeof(WebRtc_Word16));
if (in_near_H != out_H)
{
memcpy(out_H, in_near_H, 10 * L * sizeof(WebRtc_Word16));
}
}
// VAD for near end
logratio = WebRtcAgc_ProcessVad(&stt->vadNearend, out, L * 10);

View File

@ -891,5 +891,7 @@ int main(int argc, char* argv[])
{
void_main(argc, argv);
// Optional, but removes memory leak noise from Valgrind.
google::protobuf::ShutdownProtobufLibrary();
return 0;
}

View File

@ -638,8 +638,6 @@ TEST_F(ApmTest, Process) {
if (write_output_data) {
WriteMessageLiteToFile(kOutputFileName, output_data);
}
google::protobuf::ShutdownProtobufLibrary();
}
TEST_F(ApmTest, EchoCancellation) {
@ -1002,5 +1000,9 @@ int main(int argc, char** argv) {
}
}
return RUN_ALL_TESTS();
int err = RUN_ALL_TESTS();
// Optional, but removes memory leak noise from Valgrind.
google::protobuf::ShutdownProtobufLibrary();
return err;
}