* Change the reference counting implementation for VoE to be per object and

not per interface. This simplifies things a bit, reduces code and makes it
  possible to implement reference counting (if we ever want) without the
  static Delete() method.  (Reference counted objects are traditionally
  implicitly deleted via the last Release())

* Since the reference counting code is now simpler, there's no need for the
  RefCount class so I'm removing it.

* Also removing the optional |ignoreRefCounters| variable from the VoiceEngine::Delete
  method.  The justification is that it's no longer used and the reason it was there
  in the first place was to avoid bugs in third party code, so it's an indication that
  something is wrong elsewhere.

* Fix a crash in voe_network_impl and voe_extended_test that would happen on machines with IPv6 support.

* Fix an assert (handle the case) in the extended audio tests when SetCNAME is called with a NULL pointer.

* As a side effect of this change, hopefully the footprint of VoE will be slightly smaller :)

BUG=10445 (Coverity)
Review URL: https://webrtc-codereview.appspot.com/521003

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2127 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org 2012-04-26 15:28:22 +00:00
parent 497fb4fda9
commit a990e122c4
38 changed files with 154 additions and 844 deletions

View File

@ -360,7 +360,9 @@ WebRtc_Word32 RTCPSender::CNAME(char cName[RTCP_CNAME_SIZE]) {
}
WebRtc_Word32 RTCPSender::SetCNAME(const char cName[RTCP_CNAME_SIZE]) {
assert(cName);
if (!cName)
return -1;
CriticalSectionScoped lock(_criticalSectionRTCPSender);
_CNAME[RTCP_CNAME_SIZE - 1] = 0;
strncpy(_CNAME, cName, RTCP_CNAME_SIZE - 1);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -65,12 +65,10 @@ public:
static VoiceEngine* Create();
// Deletes a created VoiceEngine object and releases the utilized resources.
// If |ignoreRefCounters| is set to false, all reference counters must be
// zero to enable a valid release of the allocated resources. When set to
// true, a release of all resources allocated by the VoE is performed
// without checking the reference counter state.
static bool Delete(VoiceEngine*& voiceEngine,
bool ignoreRefCounters = false);
// Note that if there are outstanding references held via other interfaces,
// the voice engine instance will not actually be deleted until those
// references have been released.
static bool Delete(VoiceEngine*& voiceEngine);
// Specifies the amount and type of trace information which will be
// created by the VoiceEngine.

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "critical_section_wrapper.h"
#include "ref_count.h"
namespace webrtc {
namespace voe {
RefCount::RefCount() :
_count(0),
_crit(*CriticalSectionWrapper::CreateCriticalSection())
{
}
RefCount::~RefCount()
{
delete &_crit;
}
RefCount&
RefCount::operator++(int)
{
CriticalSectionScoped lock(&_crit);
_count++;
return *this;
}
RefCount&
RefCount::operator--(int)
{
CriticalSectionScoped lock(&_crit);
_count--;
return *this;
}
void
RefCount::Reset()
{
CriticalSectionScoped lock(&_crit);
_count = 0;
}
int
RefCount::GetCount() const
{
return _count;
}
} // namespace voe
} // namespace webrtc

View File

@ -1,36 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_VOICE_ENGINE_REF_COUNT_H
#define WEBRTC_VOICE_ENGINE_REF_COUNT_H
namespace webrtc {
class CriticalSectionWrapper;
namespace voe {
class RefCount
{
public:
RefCount();
~RefCount();
RefCount& operator++(int);
RefCount& operator--(int);
void Reset();
int GetCount() const;
private:
volatile int _count;
CriticalSectionWrapper& _crit;
};
} // namespace voe
} // namespace webrtc
#endif // #ifndef WEBRTC_VOICE_ENGINE_REF_COUNT_H

View File

@ -41,9 +41,8 @@ VoEAudioProcessing* VoEAudioProcessing::GetInterface(VoiceEngine* voiceEngine) {
return NULL;
}
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
VoEAudioProcessingImpl* d = s;
(*d)++;
return (d);
s->AddRef();
return s;
#endif
}
@ -59,21 +58,6 @@ VoEAudioProcessingImpl::~VoEAudioProcessingImpl() {
"VoEAudioProcessingImpl::~VoEAudioProcessingImpl() - dtor");
}
int VoEAudioProcessingImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEAudioProcessing::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0) {
Reset(); // reset reference counter to zero => OK to delete VE
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEAudioProcessing reference counter = %d", refCount);
return (refCount);
}
int VoEAudioProcessingImpl::SetNsStatus(bool enable, NsModes mode) {
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetNsStatus(enable=%d, mode=%d)", enable, mode);

View File

@ -13,17 +13,12 @@
#include "voe_audio_processing.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc {
class VoEAudioProcessingImpl
: public VoEAudioProcessing,
public voe::RefCount {
class VoEAudioProcessingImpl : public VoEAudioProcessing {
public:
virtual int Release();
virtual int SetNsStatus(bool enable, NsModes mode = kNsUnchanged);
virtual int GetNsStatus(bool& enabled, NsModes& mode);

View File

@ -40,10 +40,9 @@ VoEBase* VoEBase::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEBaseImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
}
VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared) :
@ -66,24 +65,6 @@ VoEBaseImpl::~VoEBaseImpl()
delete &_callbackCritSect;
}
int VoEBaseImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEBaseImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEBaseImpl reference counter = %d", refCount);
return (refCount);
}
void VoEBaseImpl::OnErrorIsReported(const ErrorCode error)
{
CriticalSectionScoped cs(&_callbackCritSect);

View File

@ -14,7 +14,6 @@
#include "voe_base.h"
#include "module_common_types.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc
@ -23,13 +22,10 @@ namespace webrtc
class ProcessThread;
class VoEBaseImpl: public VoEBase,
public voe::RefCount,
public AudioTransport,
public AudioDeviceObserver
{
public:
virtual int Release();
virtual int RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
virtual int DeRegisterVoiceEngineObserver();

View File

@ -30,11 +30,9 @@ VoECallReport* VoECallReport::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoECallReportImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -54,24 +52,6 @@ VoECallReportImpl::~VoECallReportImpl()
delete &_file;
}
int VoECallReportImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoECallReportImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoECallReportImpl reference counter = %d", refCount);
return (refCount);
}
int VoECallReportImpl::ResetCallReportStatistics(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),

View File

@ -13,7 +13,6 @@
#include "voe_call_report.h"
#include "ref_count.h"
#include "shared_data.h"
@ -21,12 +20,9 @@ namespace webrtc
{
class FileWrapper;
class VoECallReportImpl: public VoECallReport,
public voe::RefCount
class VoECallReportImpl: public VoECallReport
{
public:
virtual int Release();
virtual int ResetCallReportStatistics(int channel);
virtual int GetEchoMetricSummary(EchoStatistics& stats);

View File

@ -29,11 +29,9 @@ VoECodec* VoECodec::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoECodecImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -51,24 +49,6 @@ VoECodecImpl::~VoECodecImpl()
"~VoECodecImpl() - dtor");
}
int VoECodecImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoECodecImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoECodecImpl reference counter = %d", refCount);
return (refCount);
}
int VoECodecImpl::NumOfCodecs()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),

View File

@ -13,18 +13,14 @@
#include "voe_codec.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc
{
class VoECodecImpl: public VoECodec,
public voe::RefCount
class VoECodecImpl: public VoECodec
{
public:
virtual int Release();
virtual int NumOfCodecs();
virtual int GetCodec(int index, CodecInst& codec);

View File

@ -29,11 +29,9 @@ VoEDtmf* VoEDtmf::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEDtmfImpl* d = s;
( *d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -54,24 +52,6 @@ VoEDtmfImpl::~VoEDtmfImpl()
"VoEDtmfImpl::~VoEDtmfImpl() - dtor");
}
int VoEDtmfImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEDtmf::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEDtmf reference counter = %d", refCount);
return (refCount);
}
int VoEDtmfImpl::SendTelephoneEvent(int channel,
int eventCode,
bool outOfBand,

View File

@ -13,18 +13,14 @@
#include "voe_dtmf.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc
{
class VoEDtmfImpl : public VoEDtmf,
public voe::RefCount
class VoEDtmfImpl : public VoEDtmf
{
public:
virtual int Release();
virtual int SendTelephoneEvent(
int channel,
int eventCode,

View File

@ -28,11 +28,9 @@ VoEEncryption* VoEEncryption::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEEncryptionImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -50,25 +48,6 @@ VoEEncryptionImpl::~VoEEncryptionImpl()
"VoEEncryptionImpl::~VoEEncryptionImpl() - dtor");
}
int VoEEncryptionImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEEncryption::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
// reset reference counter to zero => OK to delete VE
Reset();
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEEncryption reference counter = %d", refCount);
return (refCount);
}
int VoEEncryptionImpl::EnableSRTPSend(
int channel,
CipherTypes cipherType,

View File

@ -13,18 +13,13 @@
#include "voe_encryption.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc {
class VoEEncryptionImpl : public VoEEncryption,
public voe::RefCount
class VoEEncryptionImpl : public VoEEncryption
{
public:
virtual int Release();
// SRTP
virtual int EnableSRTPSend(
int channel,

View File

@ -29,10 +29,9 @@ VoEExternalMedia* VoEExternalMedia::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEExternalMediaImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -51,24 +50,6 @@ VoEExternalMediaImpl::~VoEExternalMediaImpl()
"~VoEExternalMediaImpl() - dtor");
}
int VoEExternalMediaImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(shared_->instance_id(), -1),
"VoEExternalMedia::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
shared_->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(shared_->instance_id(), -1),
"VoEExternalMedia reference counter = %d", refCount);
return (refCount);
}
int VoEExternalMediaImpl::RegisterExternalMediaProcessing(
int channel,
ProcessingTypes type,

View File

@ -13,17 +13,13 @@
#include "voe_external_media.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc {
class VoEExternalMediaImpl : public VoEExternalMedia,
public voe::RefCount
class VoEExternalMediaImpl : public VoEExternalMedia
{
public:
virtual int Release();
virtual int RegisterExternalMediaProcessing(
int channel,
ProcessingTypes type,

View File

@ -31,11 +31,9 @@ VoEFile* VoEFile::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEFileImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -53,24 +51,6 @@ VoEFileImpl::~VoEFileImpl()
"VoEFileImpl::~VoEFileImpl() - dtor");
}
int VoEFileImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEFile::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEFile reference counter = %d", refCount);
return (refCount);
}
int VoEFileImpl::StartPlayingFileLocally(
int channel,
const char fileNameUTF8[1024],

View File

@ -13,16 +13,12 @@
#include "voe_file.h"
#include "shared_data.h"
#include "ref_count.h"
namespace webrtc {
class VoEFileImpl : public VoEFile,
public voe::RefCount
class VoEFileImpl : public VoEFile
{
public:
virtual int Release();
// Playout file locally
virtual int StartPlayingFileLocally(

View File

@ -30,11 +30,9 @@ VoEHardware* VoEHardware::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEHardwareImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -65,24 +63,6 @@ VoEHardwareImpl::~VoEHardwareImpl()
}
}
int VoEHardwareImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEHardwareImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEHardwareImpl reference counter = %d", refCount);
return (refCount);
}
int VoEHardwareImpl::SetAudioDeviceLayer(AudioLayers audioLayer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),

View File

@ -13,19 +13,15 @@
#include "voe_hardware.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc
{
class CpuWrapper;
class VoEHardwareImpl: public VoEHardware,
public voe::RefCount
class VoEHardwareImpl: public VoEHardware
{
public:
virtual int Release();
virtual int GetNumOfRecordingDevices(int& devices);
virtual int GetNumOfPlayoutDevices(int& devices);

View File

@ -29,11 +29,9 @@ VoENetEqStats* VoENetEqStats::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoENetEqStatsImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -51,24 +49,6 @@ VoENetEqStatsImpl::~VoENetEqStatsImpl()
"VoENetEqStatsImpl::~VoENetEqStatsImpl() - dtor");
}
int VoENetEqStatsImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoENetEqStats::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoENetEqStats reference counter = %d", refCount);
return (refCount);
}
int VoENetEqStatsImpl::GetNetworkStatistics(int channel,
NetworkStatistics& stats)
{

View File

@ -13,17 +13,13 @@
#include "voe_neteq_stats.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc {
class VoENetEqStatsImpl : public VoENetEqStats,
public voe::RefCount
class VoENetEqStatsImpl : public VoENetEqStats
{
public:
virtual int Release();
virtual int GetNetworkStatistics(int channel,
NetworkStatistics& stats);

View File

@ -28,11 +28,9 @@ VoENetwork* VoENetwork::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoENetworkImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -50,24 +48,6 @@ VoENetworkImpl::~VoENetworkImpl()
"~VoENetworkImpl() - dtor");
}
int VoENetworkImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoENetworkImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoENetworkImpl reference counter = %d", refCount);
return (refCount);
}
int VoENetworkImpl::RegisterExternalTransport(int channel,
Transport& transport)
{
@ -264,7 +244,8 @@ int VoENetworkImpl::GetLocalIP(char ipAddr[64], bool ipv6)
return -1;
}
char localIPAddr[64];
// Use a buffer big enough for IPv6 addresses and initialize it with zeros.
char localIPAddr[256] = {0};
if (ipv6)
{

View File

@ -13,19 +13,15 @@
#include "voe_network.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc
{
class VoENetworkImpl: public VoENetwork,
public voe::RefCount
class VoENetworkImpl: public VoENetwork
{
public:
virtual int Release();
virtual int RegisterExternalTransport(int channel, Transport& transport);
virtual int DeRegisterExternalTransport(int channel);

View File

@ -29,10 +29,9 @@ VoERTP_RTCP* VoERTP_RTCP::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoERTP_RTCPImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -50,24 +49,6 @@ VoERTP_RTCPImpl::~VoERTP_RTCPImpl()
"VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor");
}
int VoERTP_RTCPImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoERTP_RTCP::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoERTP_RTCP reference counter = %d", refCount);
return (refCount);
}
int VoERTP_RTCPImpl::RegisterRTPObserver(int channel, VoERTPObserver& observer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),

View File

@ -13,17 +13,13 @@
#include "voe_rtp_rtcp.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc {
class VoERTP_RTCPImpl : public VoERTP_RTCP,
public voe::RefCount
class VoERTP_RTCPImpl : public VoERTP_RTCP
{
public:
virtual int Release();
// Registration of observers for RTP and RTCP callbacks
virtual int RegisterRTPObserver(int channel, VoERTPObserver& observer);

View File

@ -27,11 +27,9 @@ VoEVideoSync* VoEVideoSync::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEVideoSyncImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -49,24 +47,6 @@ VoEVideoSyncImpl::~VoEVideoSyncImpl()
"VoEVideoSyncImpl::~VoEVideoSyncImpl() - dtor");
}
int VoEVideoSyncImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEVideoSync::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEVideoSync reference counter = %d", refCount);
return (refCount);
}
int VoEVideoSyncImpl::GetPlayoutTimestamp(int channel, unsigned int& timestamp)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),

View File

@ -13,17 +13,13 @@
#include "voe_video_sync.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc {
class VoEVideoSyncImpl : public VoEVideoSync,
public voe::RefCount
class VoEVideoSyncImpl : public VoEVideoSync
{
public:
virtual int Release();
virtual int GetPlayoutBufferSize(int& bufferMs);
virtual int SetMinimumPlayoutDelay(int channel, int delayMs);

View File

@ -29,11 +29,9 @@ VoEVolumeControl* VoEVolumeControl::GetInterface(VoiceEngine* voiceEngine)
{
return NULL;
}
VoiceEngineImpl* s =
reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEVolumeControlImpl* d = s;
(*d)++;
return (d);
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef();
return s;
#endif
}
@ -52,24 +50,6 @@ VoEVolumeControlImpl::~VoEVolumeControlImpl()
"VoEVolumeControlImpl::~VoEVolumeControlImpl() - dtor");
}
int VoEVolumeControlImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEVolumeControl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEVolumeControl reference counter = %d", refCount);
return (refCount);
}
int VoEVolumeControlImpl::SetSpeakerVolume(unsigned int volume)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),

View File

@ -13,17 +13,13 @@
#include "voe_volume_control.h"
#include "ref_count.h"
#include "shared_data.h"
namespace webrtc {
class VoEVolumeControlImpl : public VoEVolumeControl,
public voe::RefCount
class VoEVolumeControlImpl : public VoEVolumeControl
{
public:
virtual int Release();
virtual int SetSpeakerVolume(unsigned int volume);
virtual int GetSpeakerVolume(unsigned int& volume);

View File

@ -72,8 +72,6 @@
'monitor_module.h',
'output_mixer.cc',
'output_mixer.h',
'ref_count.cc',
'ref_count.h',
'shared_data.cc',
'shared_data.h',
'statistics.cc',

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -35,15 +35,35 @@ WEBRTC_DLLEXPORT VoiceEngine* GetVoiceEngine();
VoiceEngine* GetVoiceEngine()
{
VoiceEngineImpl* self = new VoiceEngineImpl();
VoiceEngine* ve = reinterpret_cast<VoiceEngine*> (self);
VoiceEngine* ve = reinterpret_cast<VoiceEngine*>(self);
if (ve != NULL)
{
self->AddRef(); // First reference. Released in VoiceEngine::Delete.
gVoiceEngineInstanceCounter++;
}
return ve;
}
} // extern "C"
int VoiceEngineImpl::AddRef() {
return ++_ref_count;
}
// This implements the Release() method for all the inherited interfaces.
int VoiceEngineImpl::Release() {
int new_ref = --_ref_count;
assert(new_ref >= 0);
if (new_ref == 0) {
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, -1,
"VoiceEngineImpl self deleting (voiceEngine=0x%p)",
this);
delete this;
}
return new_ref;
}
VoiceEngine* VoiceEngine::Create()
{
#if (defined _WIN32)
@ -107,199 +127,22 @@ int VoiceEngine::SetTraceCallback(TraceCallback* callback)
return (Trace::SetTraceCallback(callback));
}
bool VoiceEngine::Delete(VoiceEngine*& voiceEngine, bool ignoreRefCounters)
bool VoiceEngine::Delete(VoiceEngine*& voiceEngine)
{
if (voiceEngine == NULL)
{
return false;
}
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*> (voiceEngine);
VoEBaseImpl* base = s;
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, -1,
"VoiceEngine::Delete(voiceEngine=0x%p, ignoreRefCounters=%d)",
voiceEngine, ignoreRefCounters);
if (!ignoreRefCounters)
{
if (base->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoEBase reference counter is %d => memory will not "
"be released properly!", base->GetCount());
return false;
}
#ifdef WEBRTC_VOICE_ENGINE_CODEC_API
VoECodecImpl* codec = s;
if (codec->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoECodec reference counter is %d => memory will not "
"be released properly!", codec->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_DTMF_API
VoEDtmfImpl* dtmf = s;
if (dtmf->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoEDtmf reference counter is %d =>"
"memory will not be released properly!",
dtmf->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_ENCRYPTION_API
VoEEncryptionImpl* encrypt = s;
if (encrypt->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoEEncryption reference counter is %d => "
"memory will not be released properly!",
encrypt->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API
VoEExternalMediaImpl* extmedia = s;
if (extmedia->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoEExternalMedia reference counter is %d => "
"memory will not be released properly!",
extmedia->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_CALL_REPORT_API
VoECallReportImpl* report = s;
if (report->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoECallReport reference counter is %d => memory "
"will not be released properly!",
report->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_FILE_API
VoEFileImpl* file = s;
if (file->GetCount() != 0)
{
WEBRTC_TRACE(
kTraceCritical,
kTraceVoice,
-1,
"VoEFile reference counter is %d => memory will not "
"be released properly!",
file->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API
VoEHardwareImpl* hware = s;
if (hware->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoEHardware reference counter is %d => memory will "
"not be released properly!", hware->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
VoENetEqStatsImpl* neteqst = s;
if (neteqst->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoENetEqStats reference counter is %d => "
"memory will not be released properly!",
neteqst->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_NETWORK_API
VoENetworkImpl* netw = s;
if (netw->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoENetworkImpl reference counter is %d => memory "
"will not be released properly!", netw->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
VoERTP_RTCPImpl* rtcp = s;
if (rtcp->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoERTP_RTCP reference counter is %d =>"
"memory will not be released properly!",
rtcp->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API
VoEVideoSyncImpl* vsync = s;
if (vsync->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoEVideoSync reference counter is %d => "
"memory will not be released properly!",
vsync->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API
VoEVolumeControlImpl* volume = s;
if (volume->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoEVolumeControl reference counter is %d =>"
"memory will not be released properly!",
volume->GetCount());
return false;
}
#endif
#ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
VoEAudioProcessingImpl* apm = s;
if (apm->GetCount() != 0)
{
WEBRTC_TRACE(kTraceCritical, kTraceVoice, -1,
"VoEAudioProcessing reference counter is %d => "
"memory will not be released properly!",
apm->GetCount());
return false;
}
#endif
WEBRTC_TRACE(kTraceInfo, kTraceVoice, -1,
"all reference counters are zero => deleting the "
"VoiceEngine instance...");
} // if (!ignoreRefCounters)
else
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, -1,
"reference counters are ignored => deleting the "
"VoiceEngine instance...");
}
delete s;
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
// Release the reference that was added in GetVoiceEngine.
int ref = s->Release();
voiceEngine = NULL;
if (ref != 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, -1,
"VoiceEngine::Delete did not release the very last reference. "
"%d references remain.", ref);
}
return true;
}

View File

@ -11,6 +11,7 @@
#ifndef WEBRTC_VOICE_ENGINE_VOICE_ENGINE_IMPL_H
#define WEBRTC_VOICE_ENGINE_VOICE_ENGINE_IMPL_H
#include "atomic32.h"
#include "engine_configurations.h"
#include "voe_base_impl.h"
@ -140,12 +141,22 @@ public:
#ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API
VoEVolumeControlImpl(this),
#endif
VoEBaseImpl(this)
VoEBaseImpl(this),
_ref_count(0)
{
}
virtual ~VoiceEngineImpl()
{
assert(_ref_count.Value() == 0);
}
int AddRef();
// This implements the Release() method for all the inherited interfaces.
virtual int Release();
private:
Atomic32 _ref_count;
};
} // namespace webrtc

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -33,20 +33,20 @@ BeforeInitializationFixture::BeforeInitializationFixture()
}
BeforeInitializationFixture::~BeforeInitializationFixture() {
EXPECT_EQ(0, voe_base_->Release());
EXPECT_EQ(0, voe_codec_->Release());
EXPECT_EQ(0, voe_volume_control_->Release());
EXPECT_EQ(0, voe_dtmf_->Release());
EXPECT_EQ(0, voe_rtp_rtcp_->Release());
EXPECT_EQ(0, voe_apm_->Release());
EXPECT_EQ(0, voe_network_->Release());
EXPECT_EQ(0, voe_file_->Release());
EXPECT_EQ(0, voe_vsync_->Release());
EXPECT_EQ(0, voe_encrypt_->Release());
EXPECT_EQ(0, voe_hardware_->Release());
EXPECT_EQ(0, voe_xmedia_->Release());
EXPECT_EQ(0, voe_call_report_->Release());
EXPECT_EQ(0, voe_neteq_stats_->Release());
voe_base_->Release();
voe_codec_->Release();
voe_volume_control_->Release();
voe_dtmf_->Release();
voe_rtp_rtcp_->Release();
voe_apm_->Release();
voe_network_->Release();
voe_file_->Release();
voe_vsync_->Release();
voe_encrypt_->Release();
voe_hardware_->Release();
voe_xmedia_->Release();
voe_call_report_->Release();
voe_neteq_stats_->Release();
EXPECT_TRUE(webrtc::VoiceEngine::Delete(voice_engine_));
}

View File

@ -1531,7 +1531,7 @@ int VoEExtendedTest::TestBase() {
for (int instNum = 0; instNum < 7; instNum++) {
TEST_MUSTPASS(baseVE[instNum]->DeleteChannel(0));
TEST_MUSTPASS(baseVE[instNum]->Terminate());
TEST_MUSTPASS(baseVE[instNum]->Release());
baseVE[instNum]->Release();
VoiceEngine::Delete(instVE[instNum]);
}
@ -5307,7 +5307,8 @@ int VoEExtendedTest::TestNetwork() {
const char* localIP = "192.168.1.4";
#else
char localIP[64];
// Must be big enough so that we can print an IPv6 address.
char localIP[256] = {0};
// invalid parameter
TEST_MUSTPASS(!netw->GetLocalIP(NULL));

View File

@ -618,186 +618,70 @@ void VoETestManager::GetInterfaces() {
}
int VoETestManager::ReleaseInterfaces() {
int err(0), remInt(1), j(0);
bool releaseOK(true);
if (voe_base_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_base_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d base interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
// try to release one addition time (should fail)
TEST_MUSTPASS(-1 != voe_base_->Release());
err = voe_base_->LastError();
// it is considered safe to delete even if Release has been called
// too many times
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_base_->Release();
voe_base_ = NULL;
}
if (voe_codec_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_codec_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d codec interfaces"
" (should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_codec_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_codec_->Release();
voe_codec_ = NULL;
}
if (voe_volume_control_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_volume_control_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d volume interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_volume_control_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_volume_control_->Release();
voe_volume_control_ = NULL;
}
if (voe_dtmf_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_dtmf_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d dtmf interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_dtmf_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_dtmf_->Release();
voe_dtmf_ = NULL;
}
if (voe_rtp_rtcp_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_rtp_rtcp_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d rtp/rtcp interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_rtp_rtcp_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_rtp_rtcp_->Release();
voe_rtp_rtcp_ = NULL;
}
if (voe_apm_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_apm_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d apm interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_apm_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_apm_->Release();
voe_apm_ = NULL;
}
if (voe_network_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_network_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d network interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_network_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_network_->Release();
voe_network_ = NULL;
}
if (voe_file_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_file_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d file interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_file_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_file_->Release();
voe_file_ = NULL;
}
#ifdef _TEST_VIDEO_SYNC_
if (voe_vsync_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_vsync_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d video sync interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_vsync_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_vsync_->Release();
voe_vsync_ = NULL;
}
#endif
if (voe_encrypt_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_encrypt_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d encryption interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_encrypt_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_encrypt_->Release();
voe_encrypt_ = NULL;
}
if (voe_hardware_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_hardware_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d hardware interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_hardware_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_hardware_->Release();
voe_hardware_ = NULL;
}
#ifdef _TEST_XMEDIA_
if (voe_xmedia_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_xmedia_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d external media interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_xmedia_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_xmedia_->Release();
voe_xmedia_ = NULL;
}
#endif
#ifdef _TEST_CALL_REPORT_
if (voe_call_report_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_call_report_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d call report interfaces"
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_call_report_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_call_report_->Release();
voe_call_report_ = NULL;
}
#endif
#ifdef _TEST_NETEQ_STATS_
if (voe_neteq_stats_) {
for (remInt = 1, j = 0; remInt > 0; j++)
TEST_MUSTPASS(-1 == (remInt = voe_neteq_stats_->Release()));
if (j > 1) {
TEST_LOG("\n\n*** Error: released %d neteq stat interfaces "
"(should only be 1) \n", j);
releaseOK = false;
}
TEST_MUSTPASS(-1 != voe_neteq_stats_->Release());
err = voe_base_->LastError();
TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND);
voe_neteq_stats_->Release();
voe_neteq_stats_ = NULL;
}
#endif
if (false == VoiceEngine::Delete(voice_engine_)) {