Restore AECM Coverity fix.

Add a test which would have caught the crash introduced by r1628.

BUG=274
TEST=audioproc_unittest

Review URL: https://webrtc-codereview.appspot.com/388002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1657 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2012-02-09 17:16:18 +00:00
parent aaa76f3ba8
commit 75f1948b0e
2 changed files with 17 additions and 3 deletions

View File

@ -339,8 +339,11 @@ WebRtc_Word32 WebRtcAecm_Process(void *aecmInst, const WebRtc_Word16 *nearendNoi
{
if (nearendClean == NULL)
{
memcpy(out, nearendNoisy, sizeof(short) * nrOfSamples);
} else
if (out != nearendNoisy)
{
memcpy(out, nearendNoisy, sizeof(short) * nrOfSamples);
}
} else if (out != nearendClean)
{
memcpy(out, nearendClean, sizeof(short) * nrOfSamples);
}

View File

@ -618,8 +618,8 @@ TEST_F(ApmTest, EchoControlMobile) {
// AECM won't use super-wideband.
EXPECT_EQ(apm_->kNoError, apm_->set_sample_rate_hz(32000));
EXPECT_EQ(apm_->kBadSampleRateError, apm_->echo_control_mobile()->Enable(true));
EXPECT_EQ(apm_->kNoError, apm_->set_sample_rate_hz(16000));
// Turn AECM on (and AEC off)
Init(16000, 2, 2, 2, false);
EXPECT_EQ(apm_->kNoError, apm_->echo_control_mobile()->Enable(true));
EXPECT_TRUE(apm_->echo_control_mobile()->is_enabled());
@ -672,6 +672,14 @@ TEST_F(ApmTest, EchoControlMobile) {
for (size_t i = 0; i < echo_path_size; i++) {
EXPECT_EQ(echo_path_in[i], echo_path_out[i]);
}
// Process a few frames with NS in the default disabled state. This exercises
// a different codepath than with it enabled.
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0));
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0));
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
// Turn AECM off
EXPECT_EQ(apm_->kNoError, apm_->echo_control_mobile()->Enable(false));
EXPECT_FALSE(apm_->echo_control_mobile()->is_enabled());
@ -1046,6 +1054,9 @@ TEST_F(ApmTest, DebugDump) {
#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
}
// TODO(andrew): Add a test to process a few frames with different combinations
// of enabled components.
// TODO(andrew): Make this test more robust such that it can be run on multiple
// platforms. It currently requires bit-exactness.
#ifdef WEBRTC_AUDIOPROC_BIT_EXACT