Make the destructor of AudioCodingModule public.

This allows the type to be used with a scoped_ptr. Remove all calls to
the deprecated Destroy() from tests.

R=turaj@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4731 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org
2013-09-12 01:27:43 +00:00
parent 5eb997a2fd
commit 89df092807
24 changed files with 107 additions and 217 deletions

View File

@@ -76,7 +76,6 @@ class ACMVQMonCallback {
class AudioCodingModule: public Module { class AudioCodingModule: public Module {
protected: protected:
AudioCodingModule() {} AudioCodingModule() {}
virtual ~AudioCodingModule() {}
public: public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -88,7 +87,9 @@ class AudioCodingModule: public Module {
// //
static AudioCodingModule* Create(const int32_t id); static AudioCodingModule* Create(const int32_t id);
static AudioCodingModule* Create(const int32_t id, Clock* clock); static AudioCodingModule* Create(const int32_t id, Clock* clock);
virtual ~AudioCodingModule() {};
// TODO(ajm): Deprecated. Remove all calls to this unneeded method.
static void Destroy(AudioCodingModule* module); static void Destroy(AudioCodingModule* module);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@@ -55,8 +55,8 @@ void APITest::Wait(uint32_t waitLengthMs) {
} }
APITest::APITest() APITest::APITest()
: _acmA(NULL), : _acmA(AudioCodingModule::Create(1)),
_acmB(NULL), _acmB(AudioCodingModule::Create(2)),
_channel_A2B(NULL), _channel_A2B(NULL),
_channel_B2A(NULL), _channel_B2A(NULL),
_writeToFile(true), _writeToFile(true),
@@ -111,9 +111,6 @@ APITest::APITest()
} }
APITest::~APITest() { APITest::~APITest() {
DESTROY_ACM(_acmA);
DESTROY_ACM(_acmB);
DELETE_POINTER(_channel_A2B); DELETE_POINTER(_channel_A2B);
DELETE_POINTER(_channel_B2A); DELETE_POINTER(_channel_B2A);
@@ -141,9 +138,6 @@ APITest::~APITest() {
} }
int16_t APITest::SetUp() { int16_t APITest::SetUp() {
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
CodecInst dummyCodec; CodecInst dummyCodec;
int lastPayloadType = 0; int lastPayloadType = 0;

View File

@@ -22,6 +22,7 @@
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/test/utility.h" #include "webrtc/modules/audio_coding/main/test/utility.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/test/testsupport/fileutils.h" #include "webrtc/test/testsupport/fileutils.h"
@@ -269,7 +270,7 @@ void EncodeDecodeTest::Perform() {
codePars[1] = 0; codePars[1] = 0;
codePars[2] = 0; codePars[2] = 0;
AudioCodingModule* acm = AudioCodingModule::Create(0); scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(0));
struct CodecInst sendCodecTmp; struct CodecInst sendCodecTmp;
numCodecs = acm->NumberOfCodecs(); numCodecs = acm->NumberOfCodecs();
@@ -309,15 +310,13 @@ void EncodeDecodeTest::Perform() {
_receiver.codeId = codeId; _receiver.codeId = codeId;
rtpFile.ReadHeader(); rtpFile.ReadHeader();
_receiver.Setup(acm, &rtpFile); _receiver.Setup(acm.get(), &rtpFile);
_receiver.Run(); _receiver.Run();
_receiver.Teardown(); _receiver.Teardown();
rtpFile.Close(); rtpFile.Close();
} }
} }
AudioCodingModule::Destroy(acm);
// End tracing. // End tracing.
if (_testMode == 1) { if (_testMode == 1) {
Trace::ReturnTrace(); Trace::ReturnTrace();
@@ -326,7 +325,7 @@ void EncodeDecodeTest::Perform() {
void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars, void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
int testMode) { int testMode) {
AudioCodingModule* acm = AudioCodingModule::Create(1); scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(1));
RTPFile rtpFile; RTPFile rtpFile;
std::string fileName = webrtc::test::OutputPath() + "outFile.rtp"; std::string fileName = webrtc::test::OutputPath() + "outFile.rtp";
rtpFile.Open(fileName.c_str(), "wb+"); rtpFile.Open(fileName.c_str(), "wb+");
@@ -336,14 +335,13 @@ void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
_sender.testMode = testMode; _sender.testMode = testMode;
_sender.codeId = codeId; _sender.codeId = codeId;
_sender.Setup(acm, &rtpFile); _sender.Setup(acm.get(), &rtpFile);
struct CodecInst sendCodecInst; struct CodecInst sendCodecInst;
if (acm->SendCodec(&sendCodecInst) >= 0) { if (acm->SendCodec(&sendCodecInst) >= 0) {
_sender.Run(); _sender.Run();
} }
_sender.Teardown(); _sender.Teardown();
rtpFile.Close(); rtpFile.Close();
AudioCodingModule::Destroy(acm);
} }
} // namespace webrtc } // namespace webrtc

View File

@@ -23,31 +23,27 @@ namespace webrtc {
#define NUM_PANN_COEFFS 10 #define NUM_PANN_COEFFS 10
SpatialAudio::SpatialAudio(int testMode) { SpatialAudio::SpatialAudio(int testMode)
_testMode = testMode; : _acmLeft(AudioCodingModule::Create(1)),
_acmRight(AudioCodingModule::Create(2)),
_acmReceiver(AudioCodingModule::Create(3)),
_testMode(testMode) {
} }
SpatialAudio::~SpatialAudio() { SpatialAudio::~SpatialAudio() {
AudioCodingModule::Destroy(_acmLeft);
AudioCodingModule::Destroy(_acmRight);
AudioCodingModule::Destroy(_acmReceiver);
delete _channel; delete _channel;
_inFile.Close(); _inFile.Close();
_outFile.Close(); _outFile.Close();
} }
int16_t SpatialAudio::Setup() { int16_t SpatialAudio::Setup() {
// Create ACMs and the Channel;
_acmLeft = AudioCodingModule::Create(1);
_acmRight = AudioCodingModule::Create(2);
_acmReceiver = AudioCodingModule::Create(3);
_channel = new Channel; _channel = new Channel;
// Register callback for the sender side. // Register callback for the sender side.
CHECK_ERROR(_acmLeft->RegisterTransportCallback(_channel)); CHECK_ERROR(_acmLeft->RegisterTransportCallback(_channel));
CHECK_ERROR(_acmRight->RegisterTransportCallback(_channel)); CHECK_ERROR(_acmRight->RegisterTransportCallback(_channel));
// Register the receiver ACM in channel // Register the receiver ACM in channel
_channel->RegisterReceiverACM(_acmReceiver); _channel->RegisterReceiverACM(_acmReceiver.get());
uint16_t sampFreqHz = 32000; uint16_t sampFreqHz = 32000;

View File

@@ -11,6 +11,7 @@
#ifndef ACM_TEST_SPATIAL_AUDIO_H #ifndef ACM_TEST_SPATIAL_AUDIO_H
#define ACM_TEST_SPATIAL_AUDIO_H #define ACM_TEST_SPATIAL_AUDIO_H
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h" #include "ACMTest.h"
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
@@ -32,9 +33,9 @@ class SpatialAudio : public ACMTest {
void EncodeDecode(double leftPanning, double rightPanning); void EncodeDecode(double leftPanning, double rightPanning);
void EncodeDecode(); void EncodeDecode();
AudioCodingModule* _acmLeft; scoped_ptr<AudioCodingModule> _acmLeft;
AudioCodingModule* _acmRight; scoped_ptr<AudioCodingModule> _acmRight;
AudioCodingModule* _acmReceiver; scoped_ptr<AudioCodingModule> _acmReceiver;
Channel* _channel; Channel* _channel;
PCMFile _inFile; PCMFile _inFile;
PCMFile _outFile; PCMFile _outFile;

View File

@@ -100,8 +100,8 @@ void TestPack::reset_payload_size() {
} }
TestAllCodecs::TestAllCodecs(int test_mode) TestAllCodecs::TestAllCodecs(int test_mode)
: acm_a_(NULL), : acm_a_(AudioCodingModule::Create(0)),
acm_b_(NULL), acm_b_(AudioCodingModule::Create(1)),
channel_a_to_b_(NULL), channel_a_to_b_(NULL),
test_count_(0), test_count_(0),
packet_size_samples_(0), packet_size_samples_(0),
@@ -111,14 +111,6 @@ TestAllCodecs::TestAllCodecs(int test_mode)
} }
TestAllCodecs::~TestAllCodecs() { TestAllCodecs::~TestAllCodecs() {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if (channel_a_to_b_ != NULL) { if (channel_a_to_b_ != NULL) {
delete channel_a_to_b_; delete channel_a_to_b_;
channel_a_to_b_ = NULL; channel_a_to_b_ = NULL;
@@ -135,9 +127,6 @@ void TestAllCodecs::Perform() {
"---------- TestAllCodecs ----------"); "---------- TestAllCodecs ----------");
} }
acm_a_ = AudioCodingModule::Create(0);
acm_b_ = AudioCodingModule::Create(1);
acm_a_->InitializeReceiver(); acm_a_->InitializeReceiver();
acm_b_->InitializeReceiver(); acm_b_->InitializeReceiver();
@@ -154,7 +143,7 @@ void TestAllCodecs::Perform() {
// Create and connect the channel // Create and connect the channel
channel_a_to_b_ = new TestPack; channel_a_to_b_ = new TestPack;
acm_a_->RegisterTransportCallback(channel_a_to_b_); acm_a_->RegisterTransportCallback(channel_a_to_b_);
channel_a_to_b_->RegisterReceiverACM(acm_b_); channel_a_to_b_->RegisterReceiverACM(acm_b_.get());
// All codecs are tested for all allowed sampling frequencies, rates and // All codecs are tested for all allowed sampling frequencies, rates and
// packet sizes. // packet sizes.
@@ -736,11 +725,11 @@ void TestAllCodecs::RegisterSendCodec(char side, char* codec_name,
AudioCodingModule* my_acm = NULL; AudioCodingModule* my_acm = NULL;
switch (side) { switch (side) {
case 'A': { case 'A': {
my_acm = acm_a_; my_acm = acm_a_.get();
break; break;
} }
case 'B': { case 'B': {
my_acm = acm_b_; my_acm = acm_b_.get();
break; break;
} }
default: { default: {

View File

@@ -11,6 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_ #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h" #include "ACMTest.h"
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
@@ -64,8 +65,8 @@ class TestAllCodecs : public ACMTest {
void DisplaySendReceiveCodec(); void DisplaySendReceiveCodec();
int test_mode_; int test_mode_;
AudioCodingModule* acm_a_; scoped_ptr<AudioCodingModule> acm_a_;
AudioCodingModule* acm_b_; scoped_ptr<AudioCodingModule> acm_b_;
TestPack* channel_a_to_b_; TestPack* channel_a_to_b_;
PCMFile infile_a_; PCMFile infile_a_;
PCMFile outfile_b_; PCMFile outfile_b_;

View File

@@ -24,21 +24,13 @@
namespace webrtc { namespace webrtc {
TestFEC::TestFEC() TestFEC::TestFEC()
: _acmA(NULL), : _acmA(AudioCodingModule::Create(0)),
_acmB(NULL), _acmB(AudioCodingModule::Create(1)),
_channelA2B(NULL), _channelA2B(NULL),
_testCntr(0) { _testCntr(0) {
} }
TestFEC::~TestFEC() { TestFEC::~TestFEC() {
if (_acmA != NULL) {
AudioCodingModule::Destroy(_acmA);
_acmA = NULL;
}
if (_acmB != NULL) {
AudioCodingModule::Destroy(_acmB);
_acmB = NULL;
}
if (_channelA2B != NULL) { if (_channelA2B != NULL) {
delete _channelA2B; delete _channelA2B;
_channelA2B = NULL; _channelA2B = NULL;
@@ -50,9 +42,6 @@ void TestFEC::Perform() {
"audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb"); _inFileA.Open(file_name, 32000, "rb");
_acmA = AudioCodingModule::Create(0);
_acmB = AudioCodingModule::Create(1);
ASSERT_EQ(0, _acmA->InitializeReceiver()); ASSERT_EQ(0, _acmA->InitializeReceiver());
ASSERT_EQ(0, _acmB->InitializeReceiver()); ASSERT_EQ(0, _acmB->InitializeReceiver());
@@ -66,7 +55,7 @@ void TestFEC::Perform() {
// Create and connect the channel // Create and connect the channel
_channelA2B = new Channel; _channelA2B = new Channel;
_acmA->RegisterTransportCallback(_channelA2B); _acmA->RegisterTransportCallback(_channelA2B);
_channelA2B->RegisterReceiverACM(_acmB); _channelA2B->RegisterReceiverACM(_acmB.get());
#ifndef WEBRTC_CODEC_G722 #ifndef WEBRTC_CODEC_G722
EXPECT_TRUE(false); EXPECT_TRUE(false);
@@ -217,11 +206,11 @@ int16_t TestFEC::RegisterSendCodec(char side, char* codecName,
AudioCodingModule* myACM; AudioCodingModule* myACM;
switch (side) { switch (side) {
case 'A': { case 'A': {
myACM = _acmA; myACM = _acmA.get();
break; break;
} }
case 'B': { case 'B': {
myACM = _acmB; myACM = _acmB.get();
break; break;
} }
default: default:

View File

@@ -11,6 +11,7 @@
#ifndef TEST_FEC_H #ifndef TEST_FEC_H
#define TEST_FEC_H #define TEST_FEC_H
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h" #include "ACMTest.h"
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
@@ -32,8 +33,8 @@ class TestFEC : public ACMTest {
void Run(); void Run();
void OpenOutFile(int16_t testNumber); void OpenOutFile(int16_t testNumber);
int32_t SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode); int32_t SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode);
AudioCodingModule* _acmA; scoped_ptr<AudioCodingModule> _acmA;
AudioCodingModule* _acmB; scoped_ptr<AudioCodingModule> _acmB;
Channel* _channelA2B; Channel* _channelA2B;

View File

@@ -109,8 +109,8 @@ void TestPackStereo::set_lost_packet(bool lost) {
} }
TestStereo::TestStereo(int test_mode) TestStereo::TestStereo(int test_mode)
: acm_a_(NULL), : acm_a_(AudioCodingModule::Create(0)),
acm_b_(NULL), acm_b_(AudioCodingModule::Create(1)),
channel_a2b_(NULL), channel_a2b_(NULL),
test_cntr_(0), test_cntr_(0),
pack_size_samp_(0), pack_size_samp_(0),
@@ -132,14 +132,6 @@ TestStereo::TestStereo(int test_mode)
} }
TestStereo::~TestStereo() { TestStereo::~TestStereo() {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if (channel_a2b_ != NULL) { if (channel_a2b_ != NULL) {
delete channel_a2b_; delete channel_a2b_;
channel_a2b_ = NULL; channel_a2b_ = NULL;
@@ -168,9 +160,7 @@ void TestStereo::Perform() {
in_file_mono_->ReadStereo(false); in_file_mono_->ReadStereo(false);
// Create and initialize two ACMs, one for each side of a one-to-one call. // Create and initialize two ACMs, one for each side of a one-to-one call.
acm_a_ = AudioCodingModule::Create(0); ASSERT_TRUE((acm_a_.get() != NULL) && (acm_b_.get() != NULL));
acm_b_ = AudioCodingModule::Create(1);
ASSERT_TRUE((acm_a_ != NULL) && (acm_b_ != NULL));
EXPECT_EQ(0, acm_a_->InitializeReceiver()); EXPECT_EQ(0, acm_a_->InitializeReceiver());
EXPECT_EQ(0, acm_b_->InitializeReceiver()); EXPECT_EQ(0, acm_b_->InitializeReceiver());
@@ -197,7 +187,7 @@ void TestStereo::Perform() {
// Create and connect the channel. // Create and connect the channel.
channel_a2b_ = new TestPackStereo; channel_a2b_ = new TestPackStereo;
EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)); EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_));
channel_a2b_->RegisterReceiverACM(acm_b_); channel_a2b_->RegisterReceiverACM(acm_b_.get());
// Start with setting VAD/DTX, before we know we will send stereo. // Start with setting VAD/DTX, before we know we will send stereo.
// Continue with setting a stereo codec as send codec and verify that // Continue with setting a stereo codec as send codec and verify that
@@ -786,11 +776,11 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name,
AudioCodingModule* my_acm = NULL; AudioCodingModule* my_acm = NULL;
switch (side) { switch (side) {
case 'A': { case 'A': {
my_acm = acm_a_; my_acm = acm_a_.get();
break; break;
} }
case 'B': { case 'B': {
my_acm = acm_b_; my_acm = acm_b_.get();
break; break;
} }
default: default:

View File

@@ -13,6 +13,7 @@
#include <math.h> #include <math.h>
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h" #include "ACMTest.h"
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
@@ -83,8 +84,8 @@ class TestStereo : public ACMTest {
int test_mode_; int test_mode_;
AudioCodingModule* acm_a_; scoped_ptr<AudioCodingModule> acm_a_;
AudioCodingModule* acm_b_; scoped_ptr<AudioCodingModule> acm_b_;
TestPackStereo* channel_a2b_; TestPackStereo* channel_a2b_;

View File

@@ -23,20 +23,12 @@
namespace webrtc { namespace webrtc {
TestVADDTX::TestVADDTX() TestVADDTX::TestVADDTX()
: _acmA(NULL), : _acmA(AudioCodingModule::Create(0)),
_acmB(NULL), _acmB(AudioCodingModule::Create(1)),
_channelA2B(NULL) { _channelA2B(NULL) {
} }
TestVADDTX::~TestVADDTX() { TestVADDTX::~TestVADDTX() {
if (_acmA != NULL) {
AudioCodingModule::Destroy(_acmA);
_acmA = NULL;
}
if (_acmB != NULL) {
AudioCodingModule::Destroy(_acmB);
_acmB = NULL;
}
if (_channelA2B != NULL) { if (_channelA2B != NULL) {
delete _channelA2B; delete _channelA2B;
_channelA2B = NULL; _channelA2B = NULL;
@@ -48,9 +40,6 @@ void TestVADDTX::Perform() {
"audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb"); _inFileA.Open(file_name, 32000, "rb");
_acmA = AudioCodingModule::Create(0);
_acmB = AudioCodingModule::Create(1);
EXPECT_EQ(0, _acmA->InitializeReceiver()); EXPECT_EQ(0, _acmA->InitializeReceiver());
EXPECT_EQ(0, _acmB->InitializeReceiver()); EXPECT_EQ(0, _acmB->InitializeReceiver());
@@ -68,7 +57,7 @@ void TestVADDTX::Perform() {
// Create and connect the channel // Create and connect the channel
_channelA2B = new Channel; _channelA2B = new Channel;
_acmA->RegisterTransportCallback(_channelA2B); _acmA->RegisterTransportCallback(_channelA2B);
_channelA2B->RegisterReceiverACM(_acmB); _channelA2B->RegisterReceiverACM(_acmB.get());
_acmA->RegisterVADCallback(&_monitor); _acmA->RegisterVADCallback(&_monitor);
@@ -207,11 +196,11 @@ int16_t TestVADDTX::RegisterSendCodec(char side, char* codecName,
AudioCodingModule* myACM; AudioCodingModule* myACM;
switch (side) { switch (side) {
case 'A': { case 'A': {
myACM = _acmA; myACM = _acmA.get();
break; break;
} }
case 'B': { case 'B': {
myACM = _acmB; myACM = _acmB.get();
break; break;
} }
default: default:

View File

@@ -11,6 +11,7 @@
#ifndef TEST_VAD_DTX_H #ifndef TEST_VAD_DTX_H
#define TEST_VAD_DTX_H #define TEST_VAD_DTX_H
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h" #include "ACMTest.h"
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
@@ -64,8 +65,8 @@ class TestVADDTX : public ACMTest {
void SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode); void SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode);
VADDTXstruct GetVAD(); VADDTXstruct GetVAD();
int16_t VerifyTest(); int16_t VerifyTest();
AudioCodingModule* _acmA; scoped_ptr<AudioCodingModule> _acmA;
AudioCodingModule* _acmB; scoped_ptr<AudioCodingModule> _acmB;
Channel* _channelA2B; Channel* _channelA2B;

View File

@@ -30,16 +30,15 @@ namespace webrtc {
#define MAX_FILE_NAME_LENGTH_BYTE 500 #define MAX_FILE_NAME_LENGTH_BYTE 500
TwoWayCommunication::TwoWayCommunication(int testMode) { TwoWayCommunication::TwoWayCommunication(int testMode)
_testMode = testMode; : _acmA(AudioCodingModule::Create(1)),
_acmB(AudioCodingModule::Create(2)),
_acmRefA(AudioCodingModule::Create(3)),
_acmRefB(AudioCodingModule::Create(4)),
_testMode(testMode) {
} }
TwoWayCommunication::~TwoWayCommunication() { TwoWayCommunication::~TwoWayCommunication() {
AudioCodingModule::Destroy(_acmA);
AudioCodingModule::Destroy(_acmB);
AudioCodingModule::Destroy(_acmRefA);
AudioCodingModule::Destroy(_acmRefB);
delete _channel_A2B; delete _channel_A2B;
delete _channel_B2A; delete _channel_B2A;
delete _channelRef_A2B; delete _channelRef_A2B;
@@ -62,7 +61,7 @@ TwoWayCommunication::~TwoWayCommunication() {
void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A, void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
uint8_t* codecID_B) { uint8_t* codecID_B) {
AudioCodingModule* tmpACM = AudioCodingModule::Create(0); scoped_ptr<AudioCodingModule> tmpACM(AudioCodingModule::Create(0));
uint8_t noCodec = tmpACM->NumberOfCodecs(); uint8_t noCodec = tmpACM->NumberOfCodecs();
CodecInst codecInst; CodecInst codecInst;
printf("List of Supported Codecs\n"); printf("List of Supported Codecs\n");
@@ -80,17 +79,10 @@ void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL); EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
*codecID_B = (uint8_t) atoi(myStr); *codecID_B = (uint8_t) atoi(myStr);
AudioCodingModule::Destroy(tmpACM);
printf("\n"); printf("\n");
} }
void TwoWayCommunication::SetUp() { void TwoWayCommunication::SetUp() {
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
_acmRefA = AudioCodingModule::Create(3);
_acmRefB = AudioCodingModule::Create(4);
uint8_t codecID_A; uint8_t codecID_A;
uint8_t codecID_B; uint8_t codecID_B;
@@ -164,20 +156,20 @@ void TwoWayCommunication::SetUp() {
//--- Set A-to-B channel //--- Set A-to-B channel
_channel_A2B = new Channel; _channel_A2B = new Channel;
_acmA->RegisterTransportCallback(_channel_A2B); _acmA->RegisterTransportCallback(_channel_A2B);
_channel_A2B->RegisterReceiverACM(_acmB); _channel_A2B->RegisterReceiverACM(_acmB.get());
//--- Do the same for the reference //--- Do the same for the reference
_channelRef_A2B = new Channel; _channelRef_A2B = new Channel;
_acmRefA->RegisterTransportCallback(_channelRef_A2B); _acmRefA->RegisterTransportCallback(_channelRef_A2B);
_channelRef_A2B->RegisterReceiverACM(_acmRefB); _channelRef_A2B->RegisterReceiverACM(_acmRefB.get());
//--- Set B-to-A channel //--- Set B-to-A channel
_channel_B2A = new Channel; _channel_B2A = new Channel;
_acmB->RegisterTransportCallback(_channel_B2A); _acmB->RegisterTransportCallback(_channel_B2A);
_channel_B2A->RegisterReceiverACM(_acmA); _channel_B2A->RegisterReceiverACM(_acmA.get());
//--- Do the same for reference //--- Do the same for reference
_channelRef_B2A = new Channel; _channelRef_B2A = new Channel;
_acmRefB->RegisterTransportCallback(_channelRef_B2A); _acmRefB->RegisterTransportCallback(_channelRef_B2A);
_channelRef_B2A->RegisterReceiverACM(_acmRefA); _channelRef_B2A->RegisterReceiverACM(_acmRefA.get());
// The clicks will be more obvious when we // The clicks will be more obvious when we
// are in FAX mode. // are in FAX mode.
@@ -186,12 +178,6 @@ void TwoWayCommunication::SetUp() {
} }
void TwoWayCommunication::SetUpAutotest() { void TwoWayCommunication::SetUpAutotest() {
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
_acmRefA = AudioCodingModule::Create(3);
_acmRefB = AudioCodingModule::Create(4);
CodecInst codecInst_A; CodecInst codecInst_A;
CodecInst codecInst_B; CodecInst codecInst_B;
CodecInst dummyCodec; CodecInst dummyCodec;
@@ -252,20 +238,20 @@ void TwoWayCommunication::SetUpAutotest() {
//--- Set A-to-B channel //--- Set A-to-B channel
_channel_A2B = new Channel; _channel_A2B = new Channel;
_acmA->RegisterTransportCallback(_channel_A2B); _acmA->RegisterTransportCallback(_channel_A2B);
_channel_A2B->RegisterReceiverACM(_acmB); _channel_A2B->RegisterReceiverACM(_acmB.get());
//--- Do the same for the reference //--- Do the same for the reference
_channelRef_A2B = new Channel; _channelRef_A2B = new Channel;
_acmRefA->RegisterTransportCallback(_channelRef_A2B); _acmRefA->RegisterTransportCallback(_channelRef_A2B);
_channelRef_A2B->RegisterReceiverACM(_acmRefB); _channelRef_A2B->RegisterReceiverACM(_acmRefB.get());
//--- Set B-to-A channel //--- Set B-to-A channel
_channel_B2A = new Channel; _channel_B2A = new Channel;
_acmB->RegisterTransportCallback(_channel_B2A); _acmB->RegisterTransportCallback(_channel_B2A);
_channel_B2A->RegisterReceiverACM(_acmA); _channel_B2A->RegisterReceiverACM(_acmA.get());
//--- Do the same for reference //--- Do the same for reference
_channelRef_B2A = new Channel; _channelRef_B2A = new Channel;
_acmRefB->RegisterTransportCallback(_channelRef_B2A); _acmRefB->RegisterTransportCallback(_channelRef_B2A);
_channelRef_B2A->RegisterReceiverACM(_acmRefA); _channelRef_B2A->RegisterReceiverACM(_acmRefA.get());
// The clicks will be more obvious when we // The clicks will be more obvious when we
// are in FAX mode. // are in FAX mode.

View File

@@ -11,6 +11,7 @@
#ifndef TWO_WAY_COMMUNICATION_H #ifndef TWO_WAY_COMMUNICATION_H
#define TWO_WAY_COMMUNICATION_H #define TWO_WAY_COMMUNICATION_H
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h" #include "ACMTest.h"
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
@@ -30,11 +31,11 @@ class TwoWayCommunication : public ACMTest {
void SetUp(); void SetUp();
void SetUpAutotest(); void SetUpAutotest();
AudioCodingModule* _acmA; scoped_ptr<AudioCodingModule> _acmA;
AudioCodingModule* _acmB; scoped_ptr<AudioCodingModule> _acmB;
AudioCodingModule* _acmRefA; scoped_ptr<AudioCodingModule> _acmRefA;
AudioCodingModule* _acmRefB; scoped_ptr<AudioCodingModule> _acmRefB;
Channel* _channel_A2B; Channel* _channel_A2B;
Channel* _channel_B2A; Channel* _channel_B2A;

View File

@@ -61,8 +61,8 @@ class DelayTest {
public: public:
DelayTest() DelayTest()
: acm_a_(NULL), : acm_a_(AudioCodingModule::Create(0)),
acm_b_(NULL), acm_b_(AudioCodingModule::Create(1)),
channel_a2b_(NULL), channel_a2b_(NULL),
test_cntr_(0), test_cntr_(0),
encoding_sample_rate_hz_(8000) {} encoding_sample_rate_hz_(8000) {}
@@ -70,14 +70,6 @@ class DelayTest {
~DelayTest() {} ~DelayTest() {}
void TearDown() { void TearDown() {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if (channel_a2b_ != NULL) { if (channel_a2b_ != NULL) {
delete channel_a2b_; delete channel_a2b_;
channel_a2b_ = NULL; channel_a2b_ = NULL;
@@ -91,8 +83,6 @@ class DelayTest {
if (FLAGS_input_file.size() > 0) if (FLAGS_input_file.size() > 0)
file_name = FLAGS_input_file; file_name = FLAGS_input_file;
in_file_a_.Open(file_name, 32000, "rb"); in_file_a_.Open(file_name, 32000, "rb");
acm_a_ = AudioCodingModule::Create(0);
acm_b_ = AudioCodingModule::Create(1);
acm_a_->InitializeReceiver(); acm_a_->InitializeReceiver();
acm_b_->InitializeReceiver(); acm_b_->InitializeReceiver();
if (FLAGS_init_delay > 0) { if (FLAGS_init_delay > 0) {
@@ -122,7 +112,7 @@ class DelayTest {
// Create and connect the channel // Create and connect the channel
channel_a2b_ = new Channel; channel_a2b_ = new Channel;
acm_a_->RegisterTransportCallback(channel_a2b_); acm_a_->RegisterTransportCallback(channel_a2b_);
channel_a2b_->RegisterReceiverACM(acm_b_); channel_a2b_->RegisterReceiverACM(acm_b_.get());
} }
void Perform(const Config* config, size_t num_tests, int duration_sec, void Perform(const Config* config, size_t num_tests, int duration_sec,
@@ -229,8 +219,8 @@ class DelayTest {
out_file_b_.Close(); out_file_b_.Close();
} }
AudioCodingModule* acm_a_; scoped_ptr<AudioCodingModule> acm_a_;
AudioCodingModule* acm_b_; scoped_ptr<AudioCodingModule> acm_b_;
Channel* channel_a2b_; Channel* channel_a2b_;
@@ -256,9 +246,3 @@ void RunTest() {
} }
} // namespace } // namespace
} // namespace webrtc } // namespace webrtc
int main(int argc, char* argv[]) {
using namespace webrtc;
google::ParseCommandLineFlags(&argc, &argv, true);
RunTest();
}

View File

@@ -53,9 +53,9 @@ class DualStreamTest :
kMaxNumStreams kMaxNumStreams
}; };
AudioCodingModule* acm_dual_stream_; scoped_ptr<AudioCodingModule> acm_dual_stream_;
AudioCodingModule* acm_ref_primary_; scoped_ptr<AudioCodingModule> acm_ref_primary_;
AudioCodingModule* acm_ref_secondary_; scoped_ptr<AudioCodingModule> acm_ref_secondary_;
CodecInst primary_encoder_; CodecInst primary_encoder_;
CodecInst secondary_encoder_; CodecInst secondary_encoder_;
@@ -98,9 +98,6 @@ DualStreamTest::DualStreamTest()
} }
DualStreamTest::~DualStreamTest() { DualStreamTest::~DualStreamTest() {
AudioCodingModule::Destroy(acm_dual_stream_);
AudioCodingModule::Destroy(acm_ref_primary_);
AudioCodingModule::Destroy(acm_ref_secondary_);
} }
void DualStreamTest::PopulateCodecInstances(int frame_size_primary_ms, void DualStreamTest::PopulateCodecInstances(int frame_size_primary_ms,
@@ -138,9 +135,9 @@ void DualStreamTest::PopulateCodecInstances(int frame_size_primary_ms,
void DualStreamTest::InitializeSender(int frame_size_primary_samples, void DualStreamTest::InitializeSender(int frame_size_primary_samples,
int num_channels_primary, int num_channels_primary,
int sampling_rate) { int sampling_rate) {
ASSERT_TRUE(acm_dual_stream_ != NULL); ASSERT_TRUE(acm_dual_stream_.get() != NULL);
ASSERT_TRUE(acm_ref_primary_ != NULL); ASSERT_TRUE(acm_ref_primary_.get() != NULL);
ASSERT_TRUE(acm_ref_secondary_ != NULL); ASSERT_TRUE(acm_ref_secondary_.get() != NULL);
ASSERT_EQ(0, acm_dual_stream_->InitializeSender()); ASSERT_EQ(0, acm_dual_stream_->InitializeSender());
ASSERT_EQ(0, acm_ref_primary_->InitializeSender()); ASSERT_EQ(0, acm_ref_primary_->InitializeSender());

View File

@@ -86,14 +86,13 @@ int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
return 0; return 0;
} }
ISACTest::ISACTest(int testMode) { ISACTest::ISACTest(int testMode)
_testMode = testMode; : _acmA(AudioCodingModule::Create(1)),
_acmB(AudioCodingModule::Create(2)),
_testMode(testMode) {
} }
ISACTest::~ISACTest() { ISACTest::~ISACTest() {
AudioCodingModule::Destroy(_acmA);
AudioCodingModule::Destroy(_acmB);
delete _channel_A2B; delete _channel_A2B;
delete _channel_B2A; delete _channel_B2A;
} }
@@ -102,9 +101,6 @@ void ISACTest::Setup() {
int codecCntr; int codecCntr;
CodecInst codecParam; CodecInst codecParam;
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs(); for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
codecCntr++) { codecCntr++) {
EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam)); EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam));

View File

@@ -46,8 +46,8 @@ class InitialPlayoutDelayTest : public ::testing::Test {
protected: protected:
InitialPlayoutDelayTest() InitialPlayoutDelayTest()
: acm_a_(NULL), : acm_a_(AudioCodingModule::Create(0)),
acm_b_(NULL), acm_b_(AudioCodingModule::Create(1)),
channel_a2b_(NULL) { channel_a2b_(NULL) {
} }
@@ -55,14 +55,6 @@ class InitialPlayoutDelayTest : public ::testing::Test {
} }
void TearDown() { void TearDown() {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if (channel_a2b_ != NULL) { if (channel_a2b_ != NULL) {
delete channel_a2b_; delete channel_a2b_;
channel_a2b_ = NULL; channel_a2b_ = NULL;
@@ -70,9 +62,6 @@ class InitialPlayoutDelayTest : public ::testing::Test {
} }
void SetUp() { void SetUp() {
acm_a_ = AudioCodingModule::Create(0);
acm_b_ = AudioCodingModule::Create(1);
acm_b_->InitializeReceiver(); acm_b_->InitializeReceiver();
acm_a_->InitializeReceiver(); acm_a_->InitializeReceiver();
@@ -90,7 +79,7 @@ class InitialPlayoutDelayTest : public ::testing::Test {
// Create and connect the channel // Create and connect the channel
channel_a2b_ = new Channel; channel_a2b_ = new Channel;
acm_a_->RegisterTransportCallback(channel_a2b_); acm_a_->RegisterTransportCallback(channel_a2b_);
channel_a2b_->RegisterReceiverACM(acm_b_); channel_a2b_->RegisterReceiverACM(acm_b_.get());
} }
void Run(CodecInst codec, int initial_delay_ms) { void Run(CodecInst codec, int initial_delay_ms) {
@@ -125,8 +114,8 @@ class InitialPlayoutDelayTest : public ::testing::Test {
ASSERT_LE(num_frames * 10, initial_delay_ms + 100); ASSERT_LE(num_frames * 10, initial_delay_ms + 100);
} }
AudioCodingModule* acm_a_; scoped_ptr<AudioCodingModule> acm_a_;
AudioCodingModule* acm_b_; scoped_ptr<AudioCodingModule> acm_b_;
Channel* channel_a2b_; Channel* channel_a2b_;
}; };

View File

@@ -18,6 +18,7 @@
#include "webrtc/modules/audio_coding/main/test/PCMFile.h" #include "webrtc/modules/audio_coding/main/test/PCMFile.h"
#include "webrtc/modules/interface/module_common_types.h" #include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/system_wrappers/interface/clock.h" #include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/test/testsupport/fileutils.h" #include "webrtc/test/testsupport/fileutils.h"
// Codec. // Codec.
@@ -75,8 +76,8 @@ class InsertPacketWithTiming {
ASSERT_TRUE(sender_clock_ != NULL); ASSERT_TRUE(sender_clock_ != NULL);
ASSERT_TRUE(receiver_clock_ != NULL); ASSERT_TRUE(receiver_clock_ != NULL);
ASSERT_TRUE(send_acm_ != NULL); ASSERT_TRUE(send_acm_.get() != NULL);
ASSERT_TRUE(receive_acm_ != NULL); ASSERT_TRUE(receive_acm_.get() != NULL);
ASSERT_TRUE(channel_ != NULL); ASSERT_TRUE(channel_ != NULL);
ASSERT_TRUE(seq_num_fid_ != NULL); ASSERT_TRUE(seq_num_fid_ != NULL);
@@ -99,7 +100,7 @@ class InsertPacketWithTiming {
samples_in_1ms_ = codec.plfreq / 1000; samples_in_1ms_ = codec.plfreq / 1000;
num_10ms_in_codec_frame_ = codec.pacsize / (codec.plfreq / 100); num_10ms_in_codec_frame_ = codec.pacsize / (codec.plfreq / 100);
channel_->RegisterReceiverACM(receive_acm_); channel_->RegisterReceiverACM(receive_acm_.get());
send_acm_->RegisterTransportCallback(channel_); send_acm_->RegisterTransportCallback(channel_);
if (FLAGS_input.size() == 0) { if (FLAGS_input.size() == 0) {
@@ -195,8 +196,6 @@ class InsertPacketWithTiming {
} }
void TearDown() { void TearDown() {
AudioCodingModule::Destroy(send_acm_);
AudioCodingModule::Destroy(receive_acm_);
delete channel_; delete channel_;
fclose(seq_num_fid_); fclose(seq_num_fid_);
@@ -250,8 +249,8 @@ class InsertPacketWithTiming {
SimulatedClock* sender_clock_; SimulatedClock* sender_clock_;
SimulatedClock* receiver_clock_; SimulatedClock* receiver_clock_;
AudioCodingModule* send_acm_; scoped_ptr<AudioCodingModule> send_acm_;
AudioCodingModule* receive_acm_; scoped_ptr<AudioCodingModule> receive_acm_;
Channel* channel_; Channel* channel_;
FILE* seq_num_fid_; // Input (text), one sequence number per line. FILE* seq_num_fid_; // Input (text), one sequence number per line.

View File

@@ -29,7 +29,7 @@
namespace webrtc { namespace webrtc {
OpusTest::OpusTest() OpusTest::OpusTest()
: acm_receiver_(NULL), : acm_receiver_(AudioCodingModule::Create(0)),
channel_a2b_(NULL), channel_a2b_(NULL),
counter_(0), counter_(0),
payload_type_(255), payload_type_(255),
@@ -37,10 +37,6 @@ OpusTest::OpusTest()
} }
OpusTest::~OpusTest() { OpusTest::~OpusTest() {
if (acm_receiver_ != NULL) {
AudioCodingModule::Destroy(acm_receiver_);
acm_receiver_ = NULL;
}
if (channel_a2b_ != NULL) { if (channel_a2b_ != NULL) {
delete channel_a2b_; delete channel_a2b_;
channel_a2b_ = NULL; channel_a2b_ = NULL;
@@ -93,9 +89,7 @@ void OpusTest::Perform() {
ASSERT_GT(WebRtcOpus_DecoderInitNew(opus_mono_decoder_), -1); ASSERT_GT(WebRtcOpus_DecoderInitNew(opus_mono_decoder_), -1);
ASSERT_GT(WebRtcOpus_DecoderInitNew(opus_stereo_decoder_), -1); ASSERT_GT(WebRtcOpus_DecoderInitNew(opus_stereo_decoder_), -1);
// Create and initialize one ACM, to be used as receiver. ASSERT_TRUE(acm_receiver_.get() != NULL);
acm_receiver_ = AudioCodingModule::Create(0);
ASSERT_TRUE(acm_receiver_ != NULL);
EXPECT_EQ(0, acm_receiver_->InitializeReceiver()); EXPECT_EQ(0, acm_receiver_->InitializeReceiver());
// Register Opus stereo as receiving codec. // Register Opus stereo as receiving codec.
@@ -107,7 +101,7 @@ void OpusTest::Perform() {
// Create and connect the channel. // Create and connect the channel.
channel_a2b_ = new TestPackStereo; channel_a2b_ = new TestPackStereo;
channel_a2b_->RegisterReceiverACM(acm_receiver_); channel_a2b_->RegisterReceiverACM(acm_receiver_.get());
// //
// Test Stereo. // Test Stereo.

View File

@@ -19,6 +19,7 @@
#include "webrtc/modules/audio_coding/main/test/Channel.h" #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/PCMFile.h"
#include "webrtc/modules/audio_coding/main/test/TestStereo.h" #include "webrtc/modules/audio_coding/main/test/TestStereo.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
namespace webrtc { namespace webrtc {
@@ -34,7 +35,7 @@ class OpusTest : public ACMTest {
void OpenOutFile(int test_number); void OpenOutFile(int test_number);
AudioCodingModule* acm_receiver_; scoped_ptr<AudioCodingModule> acm_receiver_;
TestPackStereo* channel_a2b_; TestPackStereo* channel_a2b_;
PCMFile in_file_stereo_; PCMFile in_file_stereo_;
PCMFile in_file_mono_; PCMFile in_file_mono_;

View File

@@ -12,6 +12,7 @@
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/modules/interface/module_common_types.h" #include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/sleep.h" #include "webrtc/system_wrappers/interface/sleep.h"
#include "webrtc/test/testsupport/fileutils.h" #include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/test/testsupport/gtest_disable.h" #include "webrtc/test/testsupport/gtest_disable.h"
@@ -32,11 +33,10 @@ class TargetDelayTest : public ::testing::Test {
: acm_(AudioCodingModule::Create(0)) {} : acm_(AudioCodingModule::Create(0)) {}
~TargetDelayTest() { ~TargetDelayTest() {
AudioCodingModule::Destroy(acm_);
} }
void SetUp() { void SetUp() {
EXPECT_TRUE(acm_ != NULL); EXPECT_TRUE(acm_.get() != NULL);
CodecInst codec; CodecInst codec;
ASSERT_EQ(0, AudioCodingModule::Codec("L16", &codec, kSampleRateHz, 1)); ASSERT_EQ(0, AudioCodingModule::Codec("L16", &codec, kSampleRateHz, 1));
@@ -108,7 +108,7 @@ class TargetDelayTest : public ::testing::Test {
return acm_->LeastRequiredDelayMs(); return acm_->LeastRequiredDelayMs();
} }
AudioCodingModule* acm_; scoped_ptr<AudioCodingModule> acm_;
WebRtcRTPHeader rtp_info_; WebRtcRTPHeader rtp_info_;
}; };

View File

@@ -52,14 +52,6 @@ namespace webrtc {
} \ } \
} while(0) } while(0)
#define DESTROY_ACM(acm) \
do { \
if (acm != NULL) { \
AudioCodingModule::Destroy(acm); \
acm = NULL; \
} \
} while(0)
#define DELETE_POINTER(p) \ #define DELETE_POINTER(p) \
do { \ do { \
if (p != NULL) { \ if (p != NULL) { \