Files
platform-external-webrtc/voice_engine/voice_engine_impl.cc
Fredrik Solenberg 4332d09028 Reland "Reland "Remove WEBRTC_TRACE.""
This is a reland of 68007e97ec9399125e4be9964af8b0338766cd91
Original change's description:
> Reland "Remove WEBRTC_TRACE."
> 
> This is a reland of 2209b90449473e1df3e0797b6271c7624b41907d
> Original change's description:
> > Remove WEBRTC_TRACE.
> > 
> > Bug: webrtc:5118
> > Change-Id: I0af0f8845ee016fa61d7cecc526e2a672ec8732d
> > Reviewed-on: https://webrtc-review.googlesource.com/5382
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#20114}
> 
> Bug: webrtc:5118
> Change-Id: I2d93fd40fcaa251c363bdcfb1c04b834a3a7f0e9
> Reviewed-on: https://webrtc-review.googlesource.com/6000
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20132}

Bug: webrtc:5118
Change-Id: I3b46406899d043c3260fc3195b524138324f7313
Reviewed-on: https://webrtc-review.googlesource.com/6301
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20144}
2017-10-04 14:40:44 +00:00

82 lines
2.5 KiB
C++

/*
* 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.
*/
#if defined(WEBRTC_ANDROID)
#include "modules/audio_device/android/audio_device_template.h"
#include "modules/audio_device/android/audio_record_jni.h"
#include "modules/audio_device/android/audio_track_jni.h"
#endif
#include "modules/audio_coding/include/audio_coding_module.h"
#include "rtc_base/checks.h"
#include "voice_engine/channel_proxy.h"
#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;
}
std::unique_ptr<voe::ChannelProxy> VoiceEngineImpl::GetChannelProxy(
int channel_id) {
RTC_DCHECK(channel_id >= 0);
rtc::CritScope cs(crit_sec());
return std::unique_ptr<voe::ChannelProxy>(
new voe::ChannelProxy(channel_manager().GetChannel(channel_id)));
}
VoiceEngine* VoiceEngine::Create() {
return GetVoiceEngine();
}
bool VoiceEngine::Delete(VoiceEngine*& voiceEngine) {
if (voiceEngine == NULL)
return false;
VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->Release();
voiceEngine = NULL;
return true;
}
} // namespace webrtc