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

Side by Side Diff: webrtc/modules/video_capture/device_info_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
11 #include <assert.h> 11 #include <assert.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 13
14 #include "webrtc/modules/video_capture/device_info_impl.h" 14 #include "webrtc/modules/video_capture/device_info_impl.h"
15 #include "webrtc/modules/video_capture/video_capture_config.h" 15 #include "webrtc/modules/video_capture/video_capture_config.h"
16 #include "webrtc/system_wrappers/include/logging.h" 16 #include "webrtc/system_wrappers/include/logging.h"
17 17
18 #ifndef abs 18 #ifndef abs
19 #define abs(a) (a>=0?a:-a) 19 #define abs(a) (a>=0?a:-a)
20 #endif 20 #endif
21 21
22 namespace webrtc 22 namespace webrtc
23 { 23 {
24 namespace videocapturemodule 24 namespace videocapturemodule
25 { 25 {
26 DeviceInfoImpl::DeviceInfoImpl() 26 DeviceInfoImpl::DeviceInfoImpl()
27 : _apiLock(*RWLockWrapper::CreateRWLock()), _lastUsedDeviceName(NULL), 27 : _apiLock(*RWLockWrapper::CreateRWLock()),
28 _lastUsedDeviceNameLength(0) 28 _lastUsedDeviceName(nullptr),
29 { 29 _lastUsedDeviceNameLength(0) {}
30 }
31 30
32 DeviceInfoImpl::~DeviceInfoImpl(void) 31 DeviceInfoImpl::~DeviceInfoImpl(void)
33 { 32 {
34 _apiLock.AcquireLockExclusive(); 33 _apiLock.AcquireLockExclusive();
35 free(_lastUsedDeviceName); 34 free(_lastUsedDeviceName);
36 _apiLock.ReleaseLockExclusive(); 35 _apiLock.ReleaseLockExclusive();
37 36
38 delete &_apiLock; 37 delete &_apiLock;
39 } 38 }
40 int32_t DeviceInfoImpl::NumberOfCapabilities( 39 int32_t DeviceInfoImpl::NumberOfCapabilities(
(...skipping 28 matching lines...) Expand all
69 WriteLockScoped cs2(_apiLock); 68 WriteLockScoped cs2(_apiLock);
70 69
71 int32_t ret = CreateCapabilityMap(deviceUniqueIdUTF8); 70 int32_t ret = CreateCapabilityMap(deviceUniqueIdUTF8);
72 return ret; 71 return ret;
73 } 72 }
74 73
75 int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8, 74 int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8,
76 const uint32_t deviceCapabilityNumber, 75 const uint32_t deviceCapabilityNumber,
77 VideoCaptureCapability& capability) 76 VideoCaptureCapability& capability)
78 { 77 {
79 assert(deviceUniqueIdUTF8 != NULL); 78 assert(deviceUniqueIdUTF8 != nullptr);
80 79
81 ReadLockScoped cs(_apiLock); 80 ReadLockScoped cs(_apiLock);
82 81
83 if ((_lastUsedDeviceNameLength != strlen((char*) deviceUniqueIdUTF8)) 82 if ((_lastUsedDeviceNameLength != strlen((char*)deviceUniqueIdUTF8))
84 #if defined(WEBRTC_MAC) || defined(WEBRTC_LINUX) 83 #if defined(WEBRTC_MAC) || defined(WEBRTC_LINUX)
85 || (strncasecmp((char*)_lastUsedDeviceName, 84 || (strncasecmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
86 (char*) deviceUniqueIdUTF8, 85 _lastUsedDeviceNameLength) != 0))
87 _lastUsedDeviceNameLength)!=0))
88 #else 86 #else
89 || (_strnicmp((char*) _lastUsedDeviceName, 87 || (_strnicmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
90 (char*) deviceUniqueIdUTF8, 88 _lastUsedDeviceNameLength) != 0))
91 _lastUsedDeviceNameLength) != 0))
92 #endif 89 #endif
93 90
94 { 91 {
95 _apiLock.ReleaseLockShared(); 92 _apiLock.ReleaseLockShared();
96 _apiLock.AcquireLockExclusive(); 93 _apiLock.AcquireLockExclusive();
97 if (-1 == CreateCapabilityMap(deviceUniqueIdUTF8)) 94 if (-1 == CreateCapabilityMap(deviceUniqueIdUTF8))
98 { 95 {
99 _apiLock.ReleaseLockExclusive(); 96 _apiLock.ReleaseLockExclusive();
100 _apiLock.AcquireLockShared(); 97 _apiLock.AcquireLockShared();
101 return -1; 98 return -1;
102 } 99 }
103 _apiLock.ReleaseLockExclusive(); 100 _apiLock.ReleaseLockExclusive();
104 _apiLock.AcquireLockShared(); 101 _apiLock.AcquireLockShared();
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 347 }
351 348
352 //Default implementation. This should be overridden by Mobile implementations. 349 //Default implementation. This should be overridden by Mobile implementations.
353 int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, 350 int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8,
354 VideoRotation& orientation) { 351 VideoRotation& orientation) {
355 orientation = kVideoRotation_0; 352 orientation = kVideoRotation_0;
356 return -1; 353 return -1;
357 } 354 }
358 } // namespace videocapturemodule 355 } // namespace videocapturemodule
359 } // namespace webrtc 356 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698