Avoid a leak in AudioCodingModuleTest.TestIsac. The leak was caught by LSAN.
BUG=2515
TEST=reproduced locally on linux and verified the fix resolves the issue.
R=henrik.lundin@webrtc.org, kjellander@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/2499004
git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@5048 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/modules/audio_coding/main/test/iSACTest.cc b/modules/audio_coding/main/test/iSACTest.cc
index 08a9d27..f7fef4a 100644
--- a/modules/audio_coding/main/test/iSACTest.cc
+++ b/modules/audio_coding/main/test/iSACTest.cc
@@ -92,10 +92,7 @@
_testMode(testMode) {
}
-ISACTest::~ISACTest() {
- delete _channel_A2B;
- delete _channel_B2A;
-}
+ISACTest::~ISACTest() {}
void ISACTest::Setup() {
int codecCntr;
@@ -123,14 +120,14 @@
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(_paramISAC32kHz));
//--- Set A-to-B channel
- _channel_A2B = new Channel;
- EXPECT_EQ(0, _acmA->RegisterTransportCallback(_channel_A2B));
- _channel_A2B->RegisterReceiverACM(_acmB);
+ _channel_A2B.reset(new Channel);
+ EXPECT_EQ(0, _acmA->RegisterTransportCallback(_channel_A2B.get()));
+ _channel_A2B->RegisterReceiverACM(_acmB.get());
//--- Set B-to-A channel
- _channel_B2A = new Channel;
- EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A));
- _channel_B2A->RegisterReceiverACM(_acmA);
+ _channel_B2A.reset(new Channel);
+ EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get()));
+ _channel_B2A->RegisterReceiverACM(_acmA.get());
file_name_swb_ = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
"pcm");
@@ -284,8 +281,8 @@
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
// Side A is sending super-wideband, and side B is sending wideband.
- SetISAConfig(swbISACConfig, _acmA, _testMode);
- SetISAConfig(wbISACConfig, _acmB, _testMode);
+ SetISAConfig(swbISACConfig, _acmA.get(), _testMode);
+ SetISAConfig(wbISACConfig, _acmB.get(), _testMode);
bool adaptiveMode = false;
if ((swbISACConfig.currentRateBitPerSec == -1)
diff --git a/modules/audio_coding/main/test/iSACTest.h b/modules/audio_coding/main/test/iSACTest.h
index 69a7ac2..d9563db 100644
--- a/modules/audio_coding/main/test/iSACTest.h
+++ b/modules/audio_coding/main/test/iSACTest.h
@@ -20,6 +20,7 @@
#include "webrtc/modules/audio_coding/main/test/Channel.h"
#include "webrtc/modules/audio_coding/main/test/PCMFile.h"
#include "webrtc/modules/audio_coding/main/test/utility.h"
+#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#define MAX_FILE_NAME_LENGTH_BYTE 500
#define NO_OF_CLIENTS 15
@@ -55,11 +56,11 @@
void SwitchingSamplingRate(int testNr, int maxSampRateChange);
- AudioCodingModule* _acmA;
- AudioCodingModule* _acmB;
+ scoped_ptr<AudioCodingModule> _acmA;
+ scoped_ptr<AudioCodingModule> _acmB;
- Channel* _channel_A2B;
- Channel* _channel_B2A;
+ scoped_ptr<Channel> _channel_A2B;
+ scoped_ptr<Channel> _channel_B2A;
PCMFile _inFileA;
PCMFile _inFileB;