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

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

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 // ---------------------------------------------------------------------------- 116 // ----------------------------------------------------------------------------
117 // AudioDeviceModuleImpl - ctor 117 // AudioDeviceModuleImpl - ctor
118 // ---------------------------------------------------------------------------- 118 // ----------------------------------------------------------------------------
119 119
120 AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id, 120 AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id,
121 const AudioLayer audioLayer) 121 const AudioLayer audioLayer)
122 : _critSect(*CriticalSectionWrapper::CreateCriticalSection()), 122 : _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
123 _critSectEventCb(*CriticalSectionWrapper::CreateCriticalSection()), 123 _critSectEventCb(*CriticalSectionWrapper::CreateCriticalSection()),
124 _critSectAudioCb(*CriticalSectionWrapper::CreateCriticalSection()), 124 _critSectAudioCb(*CriticalSectionWrapper::CreateCriticalSection()),
125 _ptrCbAudioDeviceObserver(NULL), 125 _ptrCbAudioDeviceObserver(nullptr),
126 _ptrAudioDevice(NULL), 126 _ptrAudioDevice(nullptr),
127 _id(id), 127 _id(id),
128 _platformAudioLayer(audioLayer), 128 _platformAudioLayer(audioLayer),
129 _lastProcessTime(rtc::TimeMillis()), 129 _lastProcessTime(rtc::TimeMillis()),
130 _platformType(kPlatformNotSupported), 130 _platformType(kPlatformNotSupported),
131 _initialized(false), 131 _initialized(false),
132 _lastError(kAdmErrNone) { 132 _lastError(kAdmErrNone) {
133 LOG(INFO) << __FUNCTION__; 133 LOG(INFO) << __FUNCTION__;
134 } 134 }
135 135
136 // ---------------------------------------------------------------------------- 136 // ----------------------------------------------------------------------------
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return 0; 174 return 0;
175 } 175 }
176 176
177 // ---------------------------------------------------------------------------- 177 // ----------------------------------------------------------------------------
178 // CreatePlatformSpecificObjects 178 // CreatePlatformSpecificObjects
179 // ---------------------------------------------------------------------------- 179 // ----------------------------------------------------------------------------
180 180
181 int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() { 181 int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
182 LOG(INFO) << __FUNCTION__; 182 LOG(INFO) << __FUNCTION__;
183 183
184 AudioDeviceGeneric* ptrAudioDevice(NULL); 184 AudioDeviceGeneric* ptrAudioDevice(nullptr);
185 185
186 #if defined(WEBRTC_DUMMY_AUDIO_BUILD) 186 #if defined(WEBRTC_DUMMY_AUDIO_BUILD)
187 ptrAudioDevice = new AudioDeviceDummy(Id()); 187 ptrAudioDevice = new AudioDeviceDummy(Id());
188 LOG(INFO) << "Dummy Audio APIs will be utilized"; 188 LOG(INFO) << "Dummy Audio APIs will be utilized";
189 #elif defined(WEBRTC_DUMMY_FILE_DEVICES) 189 #elif defined(WEBRTC_DUMMY_FILE_DEVICES)
190 ptrAudioDevice = FileAudioDeviceFactory::CreateFileAudioDevice(Id()); 190 ptrAudioDevice = FileAudioDeviceFactory::CreateFileAudioDevice(Id());
191 if (ptrAudioDevice) { 191 if (ptrAudioDevice) {
192 LOG(INFO) << "Will use file-playing dummy device."; 192 LOG(INFO) << "Will use file-playing dummy device.";
193 } else { 193 } else {
194 // Create a dummy device instead. 194 // Create a dummy device instead.
(...skipping 21 matching lines...) Expand all
216 (audioLayer == kPlatformDefaultAudio)) { 216 (audioLayer == kPlatformDefaultAudio)) {
217 LOG(INFO) << "attempting to use the Windows Core Audio APIs..."; 217 LOG(INFO) << "attempting to use the Windows Core Audio APIs...";
218 218
219 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) { 219 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
220 // create *Windows Core Audio* implementation 220 // create *Windows Core Audio* implementation
221 ptrAudioDevice = new AudioDeviceWindowsCore(Id()); 221 ptrAudioDevice = new AudioDeviceWindowsCore(Id());
222 LOG(INFO) << "Windows Core Audio APIs will be utilized"; 222 LOG(INFO) << "Windows Core Audio APIs will be utilized";
223 } else { 223 } else {
224 // create *Windows Wave Audio* implementation 224 // create *Windows Wave Audio* implementation
225 ptrAudioDevice = new AudioDeviceWindowsWave(Id()); 225 ptrAudioDevice = new AudioDeviceWindowsWave(Id());
226 if (ptrAudioDevice != NULL) { 226 if (ptrAudioDevice != nullptr) {
227 // Core Audio was not supported => revert to Windows Wave instead 227 // Core Audio was not supported => revert to Windows Wave instead
228 _platformAudioLayer = 228 _platformAudioLayer =
229 kWindowsWaveAudio; // modify the state set at construction 229 kWindowsWaveAudio; // modify the state set at construction
230 LOG(WARNING) << "Windows Core Audio is *not* supported => Wave APIs " 230 LOG(WARNING) << "Windows Core Audio is *not* supported => Wave APIs "
231 "will be utilized instead"; 231 "will be utilized instead";
232 } 232 }
233 } 233 }
234 } 234 }
235 #endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) 235 #endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
236 #endif // #if defined(_WIN32) 236 #endif // #if defined(_WIN32)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(Id()); 288 AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(Id());
289 if (pulseDevice->Init() == AudioDeviceGeneric::InitStatus::OK) { 289 if (pulseDevice->Init() == AudioDeviceGeneric::InitStatus::OK) {
290 ptrAudioDevice = pulseDevice; 290 ptrAudioDevice = pulseDevice;
291 LOG(INFO) << "Linux PulseAudio APIs will be utilized"; 291 LOG(INFO) << "Linux PulseAudio APIs will be utilized";
292 } else { 292 } else {
293 delete pulseDevice; 293 delete pulseDevice;
294 #endif 294 #endif
295 #if defined(LINUX_ALSA) 295 #if defined(LINUX_ALSA)
296 // create *Linux ALSA Audio* implementation 296 // create *Linux ALSA Audio* implementation
297 ptrAudioDevice = new AudioDeviceLinuxALSA(Id()); 297 ptrAudioDevice = new AudioDeviceLinuxALSA(Id());
298 if (ptrAudioDevice != NULL) { 298 if (ptrAudioDevice != nullptr) {
299 // Pulse Audio was not supported => revert to ALSA instead 299 // Pulse Audio was not supported => revert to ALSA instead
300 _platformAudioLayer = 300 _platformAudioLayer =
301 kLinuxAlsaAudio; // modify the state set at construction 301 kLinuxAlsaAudio; // modify the state set at construction
302 LOG(WARNING) << "Linux PulseAudio is *not* supported => ALSA APIs will " 302 LOG(WARNING) << "Linux PulseAudio is *not* supported => ALSA APIs will "
303 "be utilized instead"; 303 "be utilized instead";
304 } 304 }
305 #endif 305 #endif
306 #if defined(LINUX_PULSE) 306 #if defined(LINUX_PULSE)
307 } 307 }
308 #endif 308 #endif
(...skipping 30 matching lines...) Expand all
339 // Available for all platforms 339 // Available for all platforms
340 // 340 //
341 if (audioLayer == kDummyAudio) { 341 if (audioLayer == kDummyAudio) {
342 // Create *Dummy Audio* implementation 342 // Create *Dummy Audio* implementation
343 assert(!ptrAudioDevice); 343 assert(!ptrAudioDevice);
344 ptrAudioDevice = new AudioDeviceDummy(Id()); 344 ptrAudioDevice = new AudioDeviceDummy(Id());
345 LOG(INFO) << "Dummy Audio APIs will be utilized"; 345 LOG(INFO) << "Dummy Audio APIs will be utilized";
346 } 346 }
347 #endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD) 347 #endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
348 348
349 if (ptrAudioDevice == NULL) { 349 if (ptrAudioDevice == nullptr) {
350 LOG(LERROR) 350 LOG(LERROR)
351 << "unable to create the platform specific audio device implementation"; 351 << "unable to create the platform specific audio device implementation";
352 return -1; 352 return -1;
353 } 353 }
354 354
355 // Store valid output pointers 355 // Store valid output pointers
356 // 356 //
357 _ptrAudioDevice = ptrAudioDevice; 357 _ptrAudioDevice = ptrAudioDevice;
358 358
359 return 0; 359 return 0;
(...skipping 17 matching lines...) Expand all
377 377
378 // ---------------------------------------------------------------------------- 378 // ----------------------------------------------------------------------------
379 // ~AudioDeviceModuleImpl - dtor 379 // ~AudioDeviceModuleImpl - dtor
380 // ---------------------------------------------------------------------------- 380 // ----------------------------------------------------------------------------
381 381
382 AudioDeviceModuleImpl::~AudioDeviceModuleImpl() { 382 AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
383 LOG(INFO) << __FUNCTION__; 383 LOG(INFO) << __FUNCTION__;
384 384
385 if (_ptrAudioDevice) { 385 if (_ptrAudioDevice) {
386 delete _ptrAudioDevice; 386 delete _ptrAudioDevice;
387 _ptrAudioDevice = NULL; 387 _ptrAudioDevice = nullptr;
388 } 388 }
389 389
390 delete &_critSect; 390 delete &_critSect;
391 delete &_critSectEventCb; 391 delete &_critSectEventCb;
392 delete &_critSectAudioCb; 392 delete &_critSectAudioCb;
393 } 393 }
394 394
395 // ============================================================================ 395 // ============================================================================
396 // Module 396 // Module
397 // ============================================================================ 397 // ============================================================================
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 // PlayoutDeviceName 1245 // PlayoutDeviceName
1246 // ---------------------------------------------------------------------------- 1246 // ----------------------------------------------------------------------------
1247 1247
1248 int32_t AudioDeviceModuleImpl::PlayoutDeviceName( 1248 int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
1249 uint16_t index, 1249 uint16_t index,
1250 char name[kAdmMaxDeviceNameSize], 1250 char name[kAdmMaxDeviceNameSize],
1251 char guid[kAdmMaxGuidSize]) { 1251 char guid[kAdmMaxGuidSize]) {
1252 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)"; 1252 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
1253 CHECK_INITIALIZED(); 1253 CHECK_INITIALIZED();
1254 1254
1255 if (name == NULL) { 1255 if (name == nullptr) {
1256 _lastError = kAdmErrArgument; 1256 _lastError = kAdmErrArgument;
1257 return -1; 1257 return -1;
1258 } 1258 }
1259 1259
1260 if (_ptrAudioDevice->PlayoutDeviceName(index, name, guid) == -1) { 1260 if (_ptrAudioDevice->PlayoutDeviceName(index, name, guid) == -1) {
1261 return -1; 1261 return -1;
1262 } 1262 }
1263 1263
1264 if (name != NULL) { 1264 if (name != nullptr) {
1265 LOG(INFO) << "output: name = " << name; 1265 LOG(INFO) << "output: name = " << name;
1266 } 1266 }
1267 if (guid != NULL) { 1267 if (guid != nullptr) {
1268 LOG(INFO) << "output: guid = " << guid; 1268 LOG(INFO) << "output: guid = " << guid;
1269 } 1269 }
1270 1270
1271 return (0); 1271 return (0);
1272 } 1272 }
1273 1273
1274 // ---------------------------------------------------------------------------- 1274 // ----------------------------------------------------------------------------
1275 // RecordingDeviceName 1275 // RecordingDeviceName
1276 // ---------------------------------------------------------------------------- 1276 // ----------------------------------------------------------------------------
1277 1277
1278 int32_t AudioDeviceModuleImpl::RecordingDeviceName( 1278 int32_t AudioDeviceModuleImpl::RecordingDeviceName(
1279 uint16_t index, 1279 uint16_t index,
1280 char name[kAdmMaxDeviceNameSize], 1280 char name[kAdmMaxDeviceNameSize],
1281 char guid[kAdmMaxGuidSize]) { 1281 char guid[kAdmMaxGuidSize]) {
1282 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)"; 1282 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
1283 CHECK_INITIALIZED(); 1283 CHECK_INITIALIZED();
1284 1284
1285 if (name == NULL) { 1285 if (name == nullptr) {
1286 _lastError = kAdmErrArgument; 1286 _lastError = kAdmErrArgument;
1287 return -1; 1287 return -1;
1288 } 1288 }
1289 1289
1290 if (_ptrAudioDevice->RecordingDeviceName(index, name, guid) == -1) { 1290 if (_ptrAudioDevice->RecordingDeviceName(index, name, guid) == -1) {
1291 return -1; 1291 return -1;
1292 } 1292 }
1293 1293
1294 if (name != NULL) { 1294 if (name != nullptr) {
1295 LOG(INFO) << "output: name = " << name; 1295 LOG(INFO) << "output: name = " << name;
1296 } 1296 }
1297 if (guid != NULL) { 1297 if (guid != nullptr) {
1298 LOG(INFO) << "output: guid = " << guid; 1298 LOG(INFO) << "output: guid = " << guid;
1299 } 1299 }
1300 1300
1301 return (0); 1301 return (0);
1302 } 1302 }
1303 1303
1304 // ---------------------------------------------------------------------------- 1304 // ----------------------------------------------------------------------------
1305 // RecordingDevices 1305 // RecordingDevices
1306 // ---------------------------------------------------------------------------- 1306 // ----------------------------------------------------------------------------
1307 1307
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 1501
1502 // ---------------------------------------------------------------------------- 1502 // ----------------------------------------------------------------------------
1503 // StartRawInputFileRecording 1503 // StartRawInputFileRecording
1504 // ---------------------------------------------------------------------------- 1504 // ----------------------------------------------------------------------------
1505 1505
1506 int32_t AudioDeviceModuleImpl::StartRawInputFileRecording( 1506 int32_t AudioDeviceModuleImpl::StartRawInputFileRecording(
1507 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { 1507 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) {
1508 LOG(INFO) << __FUNCTION__; 1508 LOG(INFO) << __FUNCTION__;
1509 CHECK_INITIALIZED(); 1509 CHECK_INITIALIZED();
1510 1510
1511 if (NULL == pcmFileNameUTF8) { 1511 if (nullptr == pcmFileNameUTF8) {
1512 return -1; 1512 return -1;
1513 } 1513 }
1514 1514
1515 return (_audioDeviceBuffer.StartInputFileRecording(pcmFileNameUTF8)); 1515 return (_audioDeviceBuffer.StartInputFileRecording(pcmFileNameUTF8));
1516 } 1516 }
1517 1517
1518 // ---------------------------------------------------------------------------- 1518 // ----------------------------------------------------------------------------
1519 // StopRawInputFileRecording 1519 // StopRawInputFileRecording
1520 // ---------------------------------------------------------------------------- 1520 // ----------------------------------------------------------------------------
1521 1521
1522 int32_t AudioDeviceModuleImpl::StopRawInputFileRecording() { 1522 int32_t AudioDeviceModuleImpl::StopRawInputFileRecording() {
1523 LOG(INFO) << __FUNCTION__; 1523 LOG(INFO) << __FUNCTION__;
1524 CHECK_INITIALIZED(); 1524 CHECK_INITIALIZED();
1525 1525
1526 return (_audioDeviceBuffer.StopInputFileRecording()); 1526 return (_audioDeviceBuffer.StopInputFileRecording());
1527 } 1527 }
1528 1528
1529 // ---------------------------------------------------------------------------- 1529 // ----------------------------------------------------------------------------
1530 // StartRawOutputFileRecording 1530 // StartRawOutputFileRecording
1531 // ---------------------------------------------------------------------------- 1531 // ----------------------------------------------------------------------------
1532 1532
1533 int32_t AudioDeviceModuleImpl::StartRawOutputFileRecording( 1533 int32_t AudioDeviceModuleImpl::StartRawOutputFileRecording(
1534 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { 1534 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) {
1535 LOG(INFO) << __FUNCTION__; 1535 LOG(INFO) << __FUNCTION__;
1536 CHECK_INITIALIZED(); 1536 CHECK_INITIALIZED();
1537 1537
1538 if (NULL == pcmFileNameUTF8) { 1538 if (nullptr == pcmFileNameUTF8) {
1539 return -1; 1539 return -1;
1540 } 1540 }
1541 1541
1542 return (_audioDeviceBuffer.StartOutputFileRecording(pcmFileNameUTF8)); 1542 return (_audioDeviceBuffer.StartOutputFileRecording(pcmFileNameUTF8));
1543 } 1543 }
1544 1544
1545 // ---------------------------------------------------------------------------- 1545 // ----------------------------------------------------------------------------
1546 // StopRawOutputFileRecording 1546 // StopRawOutputFileRecording
1547 // ---------------------------------------------------------------------------- 1547 // ----------------------------------------------------------------------------
1548 1548
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 // PlatformAudioLayer 1871 // PlatformAudioLayer
1872 // ---------------------------------------------------------------------------- 1872 // ----------------------------------------------------------------------------
1873 1873
1874 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() 1874 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
1875 const { 1875 const {
1876 LOG(INFO) << __FUNCTION__; 1876 LOG(INFO) << __FUNCTION__;
1877 return _platformAudioLayer; 1877 return _platformAudioLayer;
1878 } 1878 }
1879 1879
1880 } // namespace webrtc 1880 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698