Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: webrtc/voice_engine/voice_engine_impl.cc

Issue 1347793005: Replace Atomic32 with webrtc/base/atomicops.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix typo Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #if defined(WEBRTC_ANDROID) 11 #if defined(WEBRTC_ANDROID)
12 #include "webrtc/modules/audio_device/android/audio_device_template.h" 12 #include "webrtc/modules/audio_device/android/audio_device_template.h"
13 #include "webrtc/modules/audio_device/android/audio_record_jni.h" 13 #include "webrtc/modules/audio_device/android/audio_record_jni.h"
14 #include "webrtc/modules/audio_device/android/audio_track_jni.h" 14 #include "webrtc/modules/audio_device/android/audio_track_jni.h"
15 #include "webrtc/modules/utility/interface/jvm_android.h" 15 #include "webrtc/modules/utility/interface/jvm_android.h"
16 #endif 16 #endif
17 17 #include "webrtc/base/atomicops.h"
18 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" 18 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
19 #include "webrtc/system_wrappers/interface/trace.h" 19 #include "webrtc/system_wrappers/interface/trace.h"
20 #include "webrtc/voice_engine/voice_engine_impl.h" 20 #include "webrtc/voice_engine/voice_engine_impl.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 23
24 // Counter to be ensure that we can add a correct ID in all static trace 24 // Counter to be ensure that we can add a correct ID in all static trace
25 // methods. It is not the nicest solution, especially not since we already 25 // methods. It is not the nicest solution, especially not since we already
26 // have a counter in VoEBaseImpl. In other words, there is room for 26 // have a counter in VoEBaseImpl. In other words, there is room for
27 // improvement here. 27 // improvement here.
(...skipping 19 matching lines...) Expand all
47 47
48 VoiceEngineImpl* self = new VoiceEngineImpl(config, owns_config); 48 VoiceEngineImpl* self = new VoiceEngineImpl(config, owns_config);
49 if (self != NULL) { 49 if (self != NULL) {
50 self->AddRef(); // First reference. Released in VoiceEngine::Delete. 50 self->AddRef(); // First reference. Released in VoiceEngine::Delete.
51 gVoiceEngineInstanceCounter++; 51 gVoiceEngineInstanceCounter++;
52 } 52 }
53 return self; 53 return self;
54 } 54 }
55 55
56 int VoiceEngineImpl::AddRef() { 56 int VoiceEngineImpl::AddRef() {
57 return ++_ref_count; 57 return rtc::AtomicOps::Increment(&_ref_count);
58 } 58 }
59 59
60 // This implements the Release() method for all the inherited interfaces. 60 // This implements the Release() method for all the inherited interfaces.
61 int VoiceEngineImpl::Release() { 61 int VoiceEngineImpl::Release() {
62 int new_ref = --_ref_count; 62 int new_ref = rtc::AtomicOps::Decrement(&_ref_count);
63 assert(new_ref >= 0); 63 assert(new_ref >= 0);
64 if (new_ref == 0) { 64 if (new_ref == 0) {
65 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, -1, 65 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, -1,
66 "VoiceEngineImpl self deleting (voiceEngine=0x%p)", this); 66 "VoiceEngineImpl self deleting (voiceEngine=0x%p)", this);
67 67
68 // Clear any pointers before starting destruction. Otherwise worker- 68 // Clear any pointers before starting destruction. Otherwise worker-
69 // threads will still have pointers to a partially destructed object. 69 // threads will still have pointers to a partially destructed object.
70 // Example: AudioDeviceBuffer::RequestPlayoutData() can access a 70 // Example: AudioDeviceBuffer::RequestPlayoutData() can access a
71 // partially deconstructed |_ptrCbAudioTransport| during destruction 71 // partially deconstructed |_ptrCbAudioTransport| during destruction
72 // if we don't call Terminate here. 72 // if we don't call Terminate here.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 webrtc::JVM::Initialize(reinterpret_cast<JavaVM*>(javaVM), 147 webrtc::JVM::Initialize(reinterpret_cast<JavaVM*>(javaVM),
148 reinterpret_cast<jobject>(context)); 148 reinterpret_cast<jobject>(context));
149 return 0; 149 return 0;
150 #else 150 #else
151 return -1; 151 return -1;
152 #endif 152 #endif
153 } 153 }
154 #endif 154 #endif
155 155
156 } // namespace webrtc 156 } // namespace webrtc
OLDNEW
« webrtc/system_wrappers/interface/atomic32.h ('K') | « webrtc/voice_engine/voice_engine_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698