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

Side by Side Diff: webrtc/modules/audio_device/audio_device_impl.cc

Issue 1477013005: Replace RefCountImpl with rtc::RefCountedObject. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: add back explicit Release()s in test Created 4 years, 9 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 #include "webrtc/base/refcount.h"
11 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 12 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
12 #include "webrtc/modules/audio_device/audio_device_config.h" 13 #include "webrtc/modules/audio_device/audio_device_config.h"
13 #include "webrtc/modules/audio_device/audio_device_impl.h" 14 #include "webrtc/modules/audio_device/audio_device_impl.h"
14 #include "webrtc/system_wrappers/include/ref_count.h"
15 #include "webrtc/system_wrappers/include/tick_util.h" 15 #include "webrtc/system_wrappers/include/tick_util.h"
16 16
17 #include <assert.h> 17 #include <assert.h>
18 #include <string.h> 18 #include <string.h>
19 19
20 #if defined(_WIN32) 20 #if defined(_WIN32)
21 #include "audio_device_wave_win.h" 21 #include "audio_device_wave_win.h"
22 #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) 22 #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
23 #include "audio_device_core_win.h" 23 #include "audio_device_core_win.h"
24 #endif 24 #endif
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 }; \ 58 }; \
59 } 59 }
60 60
61 #define CHECK_INITIALIZED_BOOL() \ 61 #define CHECK_INITIALIZED_BOOL() \
62 { \ 62 { \
63 if (!_initialized) { \ 63 if (!_initialized) { \
64 return false; \ 64 return false; \
65 }; \ 65 }; \
66 } 66 }
67 67
68 namespace webrtc 68 namespace webrtc {
69 {
70
71 AudioDeviceModule* CreateAudioDeviceModule(
72 int32_t id, AudioDeviceModule::AudioLayer audioLayer) {
73 return AudioDeviceModuleImpl::Create(id, audioLayer);
74 }
75 69
76 // ============================================================================ 70 // ============================================================================
77 // Static methods 71 // Static methods
78 // ============================================================================ 72 // ============================================================================
79 73
80 // ---------------------------------------------------------------------------- 74 // ----------------------------------------------------------------------------
81 // AudioDeviceModule::Create() 75 // AudioDeviceModule::Create()
82 // ---------------------------------------------------------------------------- 76 // ----------------------------------------------------------------------------
83 77
84 AudioDeviceModule* AudioDeviceModuleImpl::Create(const int32_t id, 78 rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModuleImpl::Create(
85 const AudioLayer audioLayer) 79 const int32_t id,
86 { 80 const AudioLayer audioLayer) {
87 // Create the generic ref counted (platform independent) implementation. 81 // Create the generic ref counted (platform independent) implementation.
88 RefCountImpl<AudioDeviceModuleImpl>* audioDevice = 82 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
89 new RefCountImpl<AudioDeviceModuleImpl>(id, audioLayer); 83 new rtc::RefCountedObject<AudioDeviceModuleImpl>(id, audioLayer));
90 84
91 // Ensure that the current platform is supported. 85 // Ensure that the current platform is supported.
92 if (audioDevice->CheckPlatform() == -1) 86 if (audioDevice->CheckPlatform() == -1)
93 { 87 {
94 delete audioDevice; 88 return nullptr;
95 return NULL;
96 } 89 }
97 90
98 // Create the platform-dependent implementation. 91 // Create the platform-dependent implementation.
99 if (audioDevice->CreatePlatformSpecificObjects() == -1) 92 if (audioDevice->CreatePlatformSpecificObjects() == -1)
100 { 93 {
101 delete audioDevice; 94 return nullptr;
102 return NULL;
103 } 95 }
104 96
105 // Ensure that the generic audio buffer can communicate with the 97 // Ensure that the generic audio buffer can communicate with the
106 // platform-specific parts. 98 // platform-specific parts.
107 if (audioDevice->AttachAudioBuffer() == -1) 99 if (audioDevice->AttachAudioBuffer() == -1)
108 { 100 {
109 delete audioDevice; 101 return nullptr;
110 return NULL;
111 } 102 }
112 103
113 WebRtcSpl_Init(); 104 WebRtcSpl_Init();
114 105
115 return audioDevice; 106 return audioDevice;
116 } 107 }
117 108
118 // ============================================================================ 109 // ============================================================================
119 // Construction & Destruction 110 // Construction & Destruction
120 // ============================================================================ 111 // ============================================================================
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 // ---------------------------------------------------------------------------- 1927 // ----------------------------------------------------------------------------
1937 // PlatformAudioLayer 1928 // PlatformAudioLayer
1938 // ---------------------------------------------------------------------------- 1929 // ----------------------------------------------------------------------------
1939 1930
1940 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() const 1931 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() const
1941 { 1932 {
1942 return _platformAudioLayer; 1933 return _platformAudioLayer;
1943 } 1934 }
1944 1935
1945 } // namespace webrtc 1936 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/audio_device_impl.h ('k') | webrtc/modules/audio_device/include/audio_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698