From 2d49e4e18d63bc15bb168c95fd3e9457d5d82c18 Mon Sep 17 00:00:00 2001 From: Fredrik Solenberg Date: Fri, 12 Jan 2018 10:31:52 +0100 Subject: [PATCH] Remove legacy VoiceEngine. Now that voe::Channel is owned by Audio[Send|Receive]Stream, the legacy VoiceEngine and the VoEBase interface is unused. Also removes Atomic32, which was only used for ref counting VoiceEngine. Bug: webrtc:4690 Change-Id: I73b8a083df544a8ab6383d57075a65ce955c592a Reviewed-on: https://webrtc-review.googlesource.com/38723 Commit-Queue: Fredrik Solenberg Reviewed-by: Henrik Andreassson Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#21595} --- PRESUBMIT.py | 1 - native-api.md | 1 - system_wrappers/BUILD.gn | 2 - system_wrappers/include/atomic32.h | 59 ----------- system_wrappers/source/atomic32.cc | 47 -------- voice_engine/BUILD.gn | 6 -- voice_engine/include/voe_base.h | 118 --------------------- voice_engine/include/voe_errors.h | 165 ----------------------------- voice_engine/voe_base_impl.cc | 29 ----- voice_engine/voe_base_impl.h | 38 ------- voice_engine/voice_engine_impl.cc | 63 ----------- voice_engine/voice_engine_impl.h | 43 -------- 12 files changed, 572 deletions(-) delete mode 100644 system_wrappers/include/atomic32.h delete mode 100644 system_wrappers/source/atomic32.cc delete mode 100644 voice_engine/include/voe_base.h delete mode 100644 voice_engine/include/voe_errors.h delete mode 100644 voice_engine/voe_base_impl.cc delete mode 100644 voice_engine/voe_base_impl.h delete mode 100644 voice_engine/voice_engine_impl.cc delete mode 100644 voice_engine/voice_engine_impl.h diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 3f0a72c7f1..a621f3b058 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -94,7 +94,6 @@ LEGACY_API_DIRS = ( 'modules/video_coding/include', 'rtc_base', 'system_wrappers/include', - 'voice_engine/include', ) # NOTE: The set of directories in API_DIRS should be the same as those diff --git a/native-api.md b/native-api.md index 6e6251f387..d9b80093cf 100644 --- a/native-api.md +++ b/native-api.md @@ -34,7 +34,6 @@ Legacy API directory | Including subdirectories? `pc` | No `rtc_base` | No `system_wrappers/include` | No -`voice_engine/include` | No While the files, types, functions, macros, build targets, etc. in the API and legacy API directories will sometimes undergo incompatible diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index 2c12cc37f6..8d19e755c2 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -17,7 +17,6 @@ rtc_static_library("system_wrappers") { sources = [ "include/aligned_array.h", "include/aligned_malloc.h", - "include/atomic32.h", "include/clock.h", "include/cpu_info.h", "include/event_wrapper.h", @@ -28,7 +27,6 @@ rtc_static_library("system_wrappers") { "include/sleep.h", "include/timestamp_extrapolator.h", "source/aligned_malloc.cc", - "source/atomic32.cc", "source/clock.cc", "source/cpu_features.cc", "source/cpu_info.cc", diff --git a/system_wrappers/include/atomic32.h b/system_wrappers/include/atomic32.h deleted file mode 100644 index 74a540ed89..0000000000 --- a/system_wrappers/include/atomic32.h +++ /dev/null @@ -1,59 +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. - */ - -// Atomic, system independent 32-bit integer. Unless you know what you're -// doing, use locks instead! :-) -// -// Note: assumes 32-bit (or higher) system -#ifndef SYSTEM_WRAPPERS_INCLUDE_ATOMIC32_H_ -#define SYSTEM_WRAPPERS_INCLUDE_ATOMIC32_H_ - -#include - -#include - -#include "common_types.h" // NOLINT(build/include) -#include "rtc_base/constructormagic.h" - -namespace webrtc { - -// DEPRECATED: Please use std::atomic instead. -// TODO(yuweih): Replace Atomic32 uses with std::atomic and remove this -// class. (bugs.webrtc.org/8428) -// 32 bit atomic variable. Note that this class relies on the compiler to -// align the 32 bit value correctly (on a 32 bit boundary), so as long as you're -// not doing things like reinterpret_cast over some custom allocated memory -// without being careful with alignment, you should be fine. -class Atomic32 { - public: - Atomic32(int32_t initial_value = 0); - ~Atomic32(); - - // Prefix operator! - int32_t operator++(); - int32_t operator--(); - - int32_t operator+=(int32_t value); - int32_t operator-=(int32_t value); - - // Sets the value atomically to new_value if the value equals compare value. - // The function returns true if the exchange happened. - bool CompareExchange(int32_t new_value, int32_t compare_value); - int32_t Value() const; - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(Atomic32); - - std::atomic value_; -}; - -} // namespace webrtc - -#endif // SYSTEM_WRAPPERS_INCLUDE_ATOMIC32_H_ diff --git a/system_wrappers/source/atomic32.cc b/system_wrappers/source/atomic32.cc deleted file mode 100644 index 581c13e0c3..0000000000 --- a/system_wrappers/source/atomic32.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017 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 "system_wrappers/include/atomic32.h" - -#include - -#include "common_types.h" // NOLINT(build/include) - -namespace webrtc { - -Atomic32::Atomic32(int32_t initial_value) : value_(initial_value) {} - -Atomic32::~Atomic32() {} - -int32_t Atomic32::operator++() { - return ++value_; -} - -int32_t Atomic32::operator--() { - return --value_; -} - -int32_t Atomic32::operator+=(int32_t value) { - return value_ += value; -} - -int32_t Atomic32::operator-=(int32_t value) { - return value_ -= value; -} - -bool Atomic32::CompareExchange(int32_t new_value, int32_t compare_value) { - return value_.compare_exchange_strong(compare_value, new_value); -} - -int32_t Atomic32::Value() const { - return value_.load(); -} - -} // namespace webrtc diff --git a/voice_engine/BUILD.gn b/voice_engine/BUILD.gn index 701c3ae529..d0de9c64af 100644 --- a/voice_engine/BUILD.gn +++ b/voice_engine/BUILD.gn @@ -17,16 +17,10 @@ rtc_static_library("voice_engine") { "channel.h", "channel_proxy.cc", "channel_proxy.h", - "include/voe_base.h", - "include/voe_errors.h", "transport_feedback_packet_loss_tracker.cc", "transport_feedback_packet_loss_tracker.h", "utility.cc", "utility.h", - "voe_base_impl.cc", - "voe_base_impl.h", - "voice_engine_impl.cc", - "voice_engine_impl.h", ] if (is_win) { diff --git a/voice_engine/include/voe_base.h b/voice_engine/include/voe_base.h deleted file mode 100644 index 8924fae2e3..0000000000 --- a/voice_engine/include/voe_base.h +++ /dev/null @@ -1,118 +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. - */ - -// This sub-API supports the following functionalities: -// -// - Enables full duplex VoIP sessions via RTP using G.711 (mu-Law or A-Law). -// - Initialization and termination. -// - Trace information on text files or via callbacks. -// - Multi-channel support (mixing, sending to multiple destinations etc.). -// -// To support other codecs than G.711, the VoECodec sub-API must be utilized. -// -// Usage example, omitting error checking: -// -// using namespace webrtc; -// VoiceEngine* voe = VoiceEngine::Create(); -// VoEBase* base = VoEBase::GetInterface(voe); -// base->Init(); -// int ch = base->CreateChannel(); -// base->StartPlayout(ch); -// ... -// base->DeleteChannel(ch); -// base->Terminate(); -// base->Release(); -// VoiceEngine::Delete(voe); -// -#ifndef VOICE_ENGINE_VOE_BASE_H_ -#define VOICE_ENGINE_VOE_BASE_H_ - -#include "api/audio_codecs/audio_decoder_factory.h" -#include "common_types.h" // NOLINT(build/include) -#include "modules/audio_coding/include/audio_coding_module.h" -#include "rtc_base/scoped_ref_ptr.h" - -namespace webrtc { - -class AudioDeviceModule; -class AudioProcessing; - -// VoiceEngine -class WEBRTC_DLLEXPORT VoiceEngine { - public: - // Creates a VoiceEngine object, which can then be used to acquire - // sub-APIs. Returns NULL on failure. - static VoiceEngine* Create(); - - // Deletes a created VoiceEngine object and releases the utilized resources. - // 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); - - protected: - VoiceEngine() {} - ~VoiceEngine() {} -}; - -// VoEBase -class WEBRTC_DLLEXPORT VoEBase { - public: - struct ChannelConfig { - AudioCodingModule::Config acm_config; - bool enable_voice_pacing = false; - }; - - // Factory for the VoEBase sub-API. Increases an internal reference - // counter if successful. Returns NULL if the API is not supported or if - // construction fails. - static VoEBase* GetInterface(VoiceEngine* voiceEngine); - - // Releases the VoEBase sub-API and decreases an internal reference - // counter. Returns the new reference count. This value should be zero - // for all sub-APIs before the VoiceEngine object can be safely deleted. - virtual int Release() = 0; - - // Initializes all common parts of the VoiceEngine; e.g. all - // encoders/decoders, the sound card and core receiving components. - // This method also makes it possible to install some user-defined external - // modules: - // - The Audio Device Module (ADM) which implements all the audio layer - // functionality in a separate (reference counted) module. - // - The AudioProcessing module is unused - only kept for API compatibility. - // - An AudioDecoderFactory - used to create audio decoders. - virtual int Init( - AudioDeviceModule* audio_device, - AudioProcessing* audio_processing, - const rtc::scoped_refptr& decoder_factory) = 0; - - // Terminates all VoiceEngine functions and releases allocated resources. - virtual void Terminate() = 0; - - // Creates a new channel and allocates the required resources for it. - // The second version accepts a |config| struct which includes an Audio Coding - // Module config and an option to enable voice pacing. Note that the - // decoder_factory member of the ACM config will be ignored (the decoder - // factory set through Init() will always be used). - // Returns channel ID or -1 in case of an error. - virtual int CreateChannel(const ChannelConfig& config) = 0; - - // Deletes an existing channel and releases the utilized resources. - // Returns -1 in case of an error, 0 otherwise. - virtual int DeleteChannel(int channel) = 0; - - protected: - VoEBase() {} - virtual ~VoEBase() {} -}; - -} // namespace webrtc - -#endif // VOICE_ENGINE_VOE_BASE_H_ diff --git a/voice_engine/include/voe_errors.h b/voice_engine/include/voe_errors.h deleted file mode 100644 index 7479ab3957..0000000000 --- a/voice_engine/include/voe_errors.h +++ /dev/null @@ -1,165 +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 VOICE_ENGINE_VOE_ERRORS_H_ -#define VOICE_ENGINE_VOE_ERRORS_H_ - -// Warnings -#define VE_PORT_NOT_DEFINED 8001 -#define VE_CHANNEL_NOT_VALID 8002 -#define VE_FUNC_NOT_SUPPORTED 8003 -#define VE_INVALID_LISTNR 8004 -#define VE_INVALID_ARGUMENT 8005 -#define VE_INVALID_PORT_NMBR 8006 -#define VE_INVALID_PLNAME 8007 -#define VE_INVALID_PLFREQ 8008 -#define VE_INVALID_PLTYPE 8009 -#define VE_INVALID_PACSIZE 8010 -#define VE_NOT_SUPPORTED 8011 -#define VE_ALREADY_LISTENING 8012 -#define VE_CHANNEL_NOT_CREATED 8013 -#define VE_MAX_ACTIVE_CHANNELS_REACHED 8014 -#define VE_REC_CANNOT_PREPARE_HEADER 8015 -#define VE_REC_CANNOT_ADD_BUFFER 8016 -#define VE_PLAY_CANNOT_PREPARE_HEADER 8017 -#define VE_ALREADY_SENDING 8018 -#define VE_INVALID_IP_ADDRESS 8019 -#define VE_ALREADY_PLAYING 8020 -#define VE_NOT_ALL_VERSION_INFO 8021 -// 8022 is not used -#define VE_INVALID_CHANNELS 8023 -#define VE_SET_PLTYPE_FAILED 8024 -// 8025 is not used -#define VE_NOT_INITED 8026 -#define VE_NOT_SENDING 8027 -#define VE_EXT_TRANSPORT_NOT_SUPPORTED 8028 -#define VE_EXTERNAL_TRANSPORT_ENABLED 8029 -#define VE_STOP_RECORDING_FAILED 8030 -#define VE_INVALID_RATE 8031 -#define VE_INVALID_PACKET 8032 -#define VE_NO_GQOS 8033 -#define VE_INVALID_TIMESTAMP 8034 -#define VE_RECEIVE_PACKET_TIMEOUT 8035 -// 8036 is not used -#define VE_INIT_FAILED_WRONG_EXPIRY 8037 -#define VE_SENDING 8038 -#define VE_ENABLE_IPV6_FAILED 8039 -#define VE_FUNC_NO_STEREO 8040 -// Range 8041-8080 is not used -#define VE_FW_TRAVERSAL_ALREADY_INITIALIZED 8081 -#define VE_PACKET_RECEIPT_RESTARTED 8082 -#define VE_NOT_ALL_INFO 8083 -#define VE_CANNOT_SET_SEND_CODEC 8084 -#define VE_CODEC_ERROR 8085 -#define VE_NETEQ_ERROR 8086 -#define VE_RTCP_ERROR 8087 -#define VE_INVALID_OPERATION 8088 -#define VE_CPU_INFO_ERROR 8089 -#define VE_SOUNDCARD_ERROR 8090 -#define VE_SPEECH_LEVEL_ERROR 8091 -#define VE_SEND_ERROR 8092 -#define VE_CANNOT_REMOVE_CONF_CHANNEL 8093 -#define VE_PLTYPE_ERROR 8094 -#define VE_SET_RED_FAILED 8095 -#define VE_CANNOT_GET_PLAY_DATA 8096 -#define VE_APM_ERROR 8097 -#define VE_RUNTIME_PLAY_WARNING 8098 -#define VE_RUNTIME_REC_WARNING 8099 -#define VE_NOT_PLAYING 8100 -#define VE_SOCKETS_NOT_INITED 8101 -#define VE_CANNOT_GET_SOCKET_INFO 8102 -#define VE_INVALID_MULTICAST_ADDRESS 8103 -#define VE_DESTINATION_NOT_INITED 8104 -#define VE_RECEIVE_SOCKETS_CONFLICT 8105 -#define VE_SEND_SOCKETS_CONFLICT 8106 -// 8107 is not used -#define VE_NOISE_WARNING 8109 -#define VE_CANNOT_GET_SEND_CODEC 8110 -#define VE_CANNOT_GET_REC_CODEC 8111 -#define VE_ALREADY_INITED 8112 -#define VE_CANNOT_SET_SECONDARY_SEND_CODEC 8113 -#define VE_CANNOT_GET_SECONDARY_SEND_CODEC 8114 -#define VE_CANNOT_REMOVE_SECONDARY_SEND_CODEC 8115 -// 8116 is not used - -// Errors causing limited functionality -#define VE_RTCP_SOCKET_ERROR 9001 -#define VE_MIC_VOL_ERROR 9002 -#define VE_SPEAKER_VOL_ERROR 9003 -#define VE_CANNOT_ACCESS_MIC_VOL 9004 -#define VE_CANNOT_ACCESS_SPEAKER_VOL 9005 -#define VE_GET_MIC_VOL_ERROR 9006 -#define VE_GET_SPEAKER_VOL_ERROR 9007 -#define VE_THREAD_RTCP_ERROR 9008 -#define VE_CANNOT_INIT_APM 9009 -#define VE_SEND_SOCKET_TOS_ERROR 9010 -#define VE_CANNOT_RETRIEVE_DEVICE_NAME 9013 -#define VE_SRTP_ERROR 9014 -// 9015 is not used -#define VE_INTERFACE_NOT_FOUND 9016 -#define VE_TOS_GQOS_CONFLICT 9017 -#define VE_CANNOT_ADD_CONF_CHANNEL 9018 -#define VE_BUFFER_TOO_SMALL 9019 -#define VE_CANNOT_EXECUTE_SETTING 9020 -#define VE_CANNOT_RETRIEVE_SETTING 9021 -// 9022 is not used -#define VE_RTP_KEEPALIVE_FAILED 9023 -#define VE_SEND_DTMF_FAILED 9024 -#define VE_CANNOT_RETRIEVE_CNAME 9025 -// 9026 is not used -// 9027 is not used -#define VE_CANNOT_RETRIEVE_RTP_STAT 9028 -#define VE_GQOS_ERROR 9029 -#define VE_BINDING_SOCKET_TO_LOCAL_ADDRESS_FAILED 9030 -#define VE_TOS_INVALID 9031 -#define VE_TOS_ERROR 9032 -#define VE_CANNOT_RETRIEVE_VALUE 9033 - -// Critical errors that stops voice functionality -#define VE_PLAY_UNDEFINED_SC_ERR 10001 -#define VE_REC_CANNOT_OPEN_SC 10002 -#define VE_SOCKET_ERROR 10003 -#define VE_MMSYSERR_INVALHANDLE 10004 -#define VE_MMSYSERR_NODRIVER 10005 -#define VE_MMSYSERR_NOMEM 10006 -#define VE_WAVERR_UNPREPARED 10007 -#define VE_WAVERR_STILLPLAYING 10008 -#define VE_UNDEFINED_SC_ERR 10009 -#define VE_UNDEFINED_SC_REC_ERR 10010 -#define VE_THREAD_ERROR 10011 -#define VE_CANNOT_START_RECORDING 10012 -#define VE_PLAY_CANNOT_OPEN_SC 10013 -#define VE_NO_WINSOCK_2 10014 -#define VE_SEND_SOCKET_ERROR 10015 -#define VE_BAD_FILE 10016 -#define VE_EXPIRED_COPY 10017 -#define VE_NOT_AUTHORISED 10018 -#define VE_RUNTIME_PLAY_ERROR 10019 -#define VE_RUNTIME_REC_ERROR 10020 -#define VE_BAD_ARGUMENT 10021 -#define VE_LINUX_API_ONLY 10022 -#define VE_REC_DEVICE_REMOVED 10023 -#define VE_NO_MEMORY 10024 -#define VE_BAD_HANDLE 10025 -#define VE_RTP_RTCP_MODULE_ERROR 10026 -#define VE_AUDIO_CODING_MODULE_ERROR 10027 -#define VE_AUDIO_DEVICE_MODULE_ERROR 10028 -#define VE_CANNOT_START_PLAYOUT 10029 -#define VE_CANNOT_STOP_RECORDING 10030 -#define VE_CANNOT_STOP_PLAYOUT 10031 -#define VE_CANNOT_INIT_CHANNEL 10032 -#define VE_RECV_SOCKET_ERROR 10033 -#define VE_SOCKET_TRANSPORT_MODULE_ERROR 10034 -#define VE_AUDIO_CONF_MIX_MODULE_ERROR 10035 - -// Warnings for other platforms (reserved range 8061-8080) -#define VE_IGNORED_FUNCTION 8061 - -#endif // VOICE_ENGINE_VOE_ERRORS_H_ diff --git a/voice_engine/voe_base_impl.cc b/voice_engine/voe_base_impl.cc deleted file mode 100644 index a7eaf74ada..0000000000 --- a/voice_engine/voe_base_impl.cc +++ /dev/null @@ -1,29 +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 "voice_engine/voe_base_impl.h" - -#include "voice_engine/voice_engine_impl.h" - -namespace webrtc { - -VoEBase* VoEBase::GetInterface(VoiceEngine* voiceEngine) { - if (nullptr == voiceEngine) { - return nullptr; - } - VoiceEngineImpl* s = static_cast(voiceEngine); - s->AddRef(); - return s; -} - -VoEBaseImpl::VoEBaseImpl() {} - -VoEBaseImpl::~VoEBaseImpl() {} -} // namespace webrtc diff --git a/voice_engine/voe_base_impl.h b/voice_engine/voe_base_impl.h deleted file mode 100644 index 37867766d1..0000000000 --- a/voice_engine/voe_base_impl.h +++ /dev/null @@ -1,38 +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. - */ - -#ifndef VOICE_ENGINE_VOE_BASE_IMPL_H_ -#define VOICE_ENGINE_VOE_BASE_IMPL_H_ - -#include "voice_engine/include/voe_base.h" - -namespace webrtc { - -class VoEBaseImpl : public VoEBase { - public: - int Init( - AudioDeviceModule* audio_device, - AudioProcessing* audio_processing, - const rtc::scoped_refptr& decoder_factory) override { - return 0; - } - void Terminate() override {} - - int CreateChannel(const ChannelConfig& config) override { return 1; } - int DeleteChannel(int channel) override { return 0; } - - protected: - VoEBaseImpl(); - ~VoEBaseImpl() override; -}; - -} // namespace webrtc - -#endif // VOICE_ENGINE_VOE_BASE_IMPL_H_ diff --git a/voice_engine/voice_engine_impl.cc b/voice_engine/voice_engine_impl.cc deleted file mode 100644 index f47b4d7dbd..0000000000 --- a/voice_engine/voice_engine_impl.cc +++ /dev/null @@ -1,63 +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 "voice_engine/voice_engine_impl.h" - -namespace webrtc { - -// Counter to be ensure that we can add a correct ID in all static trace -// methods. It is not the nicest solution, especially not since we already -// have a counter in VoEBaseImpl. In other words, there is room for -// improvement here. -static int32_t gVoiceEngineInstanceCounter = 0; - -VoiceEngine* GetVoiceEngine() { - VoiceEngineImpl* self = new VoiceEngineImpl(); - if (self != NULL) { - self->AddRef(); // First reference. Released in VoiceEngine::Delete. - gVoiceEngineInstanceCounter++; - } - return self; -} - -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) { - // Clear any pointers before starting destruction. Otherwise worker- - // threads will still have pointers to a partially destructed object. - // Example: AudioDeviceBuffer::RequestPlayoutData() can access a - // partially deconstructed |_ptrCbAudioTransport| during destruction - // if we don't call Terminate here. - Terminate(); - delete this; - } - - return new_ref; -} - -VoiceEngine* VoiceEngine::Create() { - return GetVoiceEngine(); -} - -bool VoiceEngine::Delete(VoiceEngine*& voiceEngine) { - if (voiceEngine == NULL) - return false; - - VoiceEngineImpl* s = static_cast(voiceEngine); - s->Release(); - voiceEngine = NULL; - return true; -} -} // namespace webrtc diff --git a/voice_engine/voice_engine_impl.h b/voice_engine/voice_engine_impl.h deleted file mode 100644 index 41b72824bd..0000000000 --- a/voice_engine/voice_engine_impl.h +++ /dev/null @@ -1,43 +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. - */ - -#ifndef VOICE_ENGINE_VOICE_ENGINE_IMPL_H_ -#define VOICE_ENGINE_VOICE_ENGINE_IMPL_H_ - -#include - -#include "system_wrappers/include/atomic32.h" -#include "typedefs.h" // NOLINT(build/include) -#include "voice_engine/voe_base_impl.h" - -namespace webrtc { - -class VoiceEngineImpl : public VoiceEngine, - public VoEBaseImpl { - public: - VoiceEngineImpl() - : VoEBaseImpl(), - _ref_count(0) {} - ~VoiceEngineImpl() override { assert(_ref_count.Value() == 0); } - - int AddRef(); - - // This implements the Release() method for all the inherited interfaces. - int Release() override; - - // This is *protected* so that FakeVoiceEngine can inherit from the class and - // manipulate the reference count. See: fake_voice_engine.h. - protected: - Atomic32 _ref_count; -}; - -} // namespace webrtc - -#endif // VOICE_ENGINE_VOICE_ENGINE_IMPL_H_