OLD | NEW |
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/voice_engine/voe_hardware_impl.h" | 11 #include "webrtc/voice_engine/voe_hardware_impl.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 #include "webrtc/system_wrappers/include/trace.h" | 15 #include "webrtc/system_wrappers/include/trace.h" |
16 #include "webrtc/voice_engine/include/voe_errors.h" | 16 #include "webrtc/voice_engine/include/voe_errors.h" |
17 #include "webrtc/voice_engine/voice_engine_impl.h" | 17 #include "webrtc/voice_engine/voice_engine_impl.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 VoEHardware* VoEHardware::GetInterface(VoiceEngine* voiceEngine) { | 21 VoEHardware* VoEHardware::GetInterface(VoiceEngine* voiceEngine) { |
22 if (NULL == voiceEngine) { | 22 if (nullptr == voiceEngine) { |
23 return NULL; | 23 return nullptr; |
24 } | 24 } |
25 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); | 25 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
26 s->AddRef(); | 26 s->AddRef(); |
27 return s; | 27 return s; |
28 } | 28 } |
29 | 29 |
30 VoEHardwareImpl::VoEHardwareImpl(voe::SharedData* shared) : _shared(shared) { | 30 VoEHardwareImpl::VoEHardwareImpl(voe::SharedData* shared) : _shared(shared) { |
31 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), | 31 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
32 "VoEHardwareImpl() - ctor"); | 32 "VoEHardwareImpl() - ctor"); |
33 } | 33 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 return 0; | 138 return 0; |
139 } | 139 } |
140 | 140 |
141 int VoEHardwareImpl::GetRecordingDeviceName(int index, | 141 int VoEHardwareImpl::GetRecordingDeviceName(int index, |
142 char strNameUTF8[128], | 142 char strNameUTF8[128], |
143 char strGuidUTF8[128]) { | 143 char strGuidUTF8[128]) { |
144 if (!_shared->statistics().Initialized()) { | 144 if (!_shared->statistics().Initialized()) { |
145 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 145 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
146 return -1; | 146 return -1; |
147 } | 147 } |
148 if (strNameUTF8 == NULL) { | 148 if (strNameUTF8 == nullptr) { |
149 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, | 149 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
150 "GetRecordingDeviceName() invalid argument"); | 150 "GetRecordingDeviceName() invalid argument"); |
151 return -1; | 151 return -1; |
152 } | 152 } |
153 | 153 |
154 // Note that strGuidUTF8 is allowed to be NULL | 154 // Note that strGuidUTF8 is allowed to be null |
155 | 155 |
156 // Init len variable to length of supplied vectors | 156 // Init len variable to length of supplied vectors |
157 const uint16_t strLen = 128; | 157 const uint16_t strLen = 128; |
158 | 158 |
159 // Check if length has been changed in module | 159 // Check if length has been changed in module |
160 static_assert(strLen == kAdmMaxDeviceNameSize, ""); | 160 static_assert(strLen == kAdmMaxDeviceNameSize, ""); |
161 static_assert(strLen == kAdmMaxGuidSize, ""); | 161 static_assert(strLen == kAdmMaxGuidSize, ""); |
162 | 162 |
163 char name[strLen]; | 163 char name[strLen]; |
164 char guid[strLen]; | 164 char guid[strLen]; |
165 | 165 |
166 // Get names from module | 166 // Get names from module |
167 if (_shared->audio_device()->RecordingDeviceName(index, name, guid) != 0) { | 167 if (_shared->audio_device()->RecordingDeviceName(index, name, guid) != 0) { |
168 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError, | 168 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError, |
169 "GetRecordingDeviceName() failed to get device name"); | 169 "GetRecordingDeviceName() failed to get device name"); |
170 return -1; | 170 return -1; |
171 } | 171 } |
172 | 172 |
173 // Copy to vectors supplied by user | 173 // Copy to vectors supplied by user |
174 strncpy(strNameUTF8, name, strLen); | 174 strncpy(strNameUTF8, name, strLen); |
175 | 175 |
176 if (strGuidUTF8 != NULL) { | 176 if (strGuidUTF8 != nullptr) { |
177 strncpy(strGuidUTF8, guid, strLen); | 177 strncpy(strGuidUTF8, guid, strLen); |
178 } | 178 } |
179 | 179 |
180 return 0; | 180 return 0; |
181 } | 181 } |
182 | 182 |
183 int VoEHardwareImpl::GetPlayoutDeviceName(int index, | 183 int VoEHardwareImpl::GetPlayoutDeviceName(int index, |
184 char strNameUTF8[128], | 184 char strNameUTF8[128], |
185 char strGuidUTF8[128]) { | 185 char strGuidUTF8[128]) { |
186 if (!_shared->statistics().Initialized()) { | 186 if (!_shared->statistics().Initialized()) { |
187 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 187 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
188 return -1; | 188 return -1; |
189 } | 189 } |
190 if (strNameUTF8 == NULL) { | 190 if (strNameUTF8 == nullptr) { |
191 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, | 191 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
192 "GetPlayoutDeviceName() invalid argument"); | 192 "GetPlayoutDeviceName() invalid argument"); |
193 return -1; | 193 return -1; |
194 } | 194 } |
195 | 195 |
196 // Note that strGuidUTF8 is allowed to be NULL | 196 // Note that strGuidUTF8 is allowed to be null |
197 | 197 |
198 // Init len variable to length of supplied vectors | 198 // Init len variable to length of supplied vectors |
199 const uint16_t strLen = 128; | 199 const uint16_t strLen = 128; |
200 | 200 |
201 // Check if length has been changed in module | 201 // Check if length has been changed in module |
202 static_assert(strLen == kAdmMaxDeviceNameSize, ""); | 202 static_assert(strLen == kAdmMaxDeviceNameSize, ""); |
203 static_assert(strLen == kAdmMaxGuidSize, ""); | 203 static_assert(strLen == kAdmMaxGuidSize, ""); |
204 | 204 |
205 char name[strLen]; | 205 char name[strLen]; |
206 char guid[strLen]; | 206 char guid[strLen]; |
207 | 207 |
208 // Get names from module | 208 // Get names from module |
209 if (_shared->audio_device()->PlayoutDeviceName(index, name, guid) != 0) { | 209 if (_shared->audio_device()->PlayoutDeviceName(index, name, guid) != 0) { |
210 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError, | 210 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError, |
211 "GetPlayoutDeviceName() failed to get device name"); | 211 "GetPlayoutDeviceName() failed to get device name"); |
212 return -1; | 212 return -1; |
213 } | 213 } |
214 | 214 |
215 // Copy to vectors supplied by user | 215 // Copy to vectors supplied by user |
216 strncpy(strNameUTF8, name, strLen); | 216 strncpy(strNameUTF8, name, strLen); |
217 | 217 |
218 if (strGuidUTF8 != NULL) { | 218 if (strGuidUTF8 != nullptr) { |
219 strncpy(strGuidUTF8, guid, strLen); | 219 strncpy(strGuidUTF8, guid, strLen); |
220 } | 220 } |
221 | 221 |
222 return 0; | 222 return 0; |
223 } | 223 } |
224 | 224 |
225 int VoEHardwareImpl::SetRecordingDevice(int index, | 225 int VoEHardwareImpl::SetRecordingDevice(int index, |
226 StereoChannel recordingChannel) { | 226 StereoChannel recordingChannel) { |
227 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 227 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
228 "SetRecordingDevice(index=%d, recordingChannel=%d)", index, | 228 "SetRecordingDevice(index=%d, recordingChannel=%d)", index, |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 499 |
500 int VoEHardwareImpl::EnableBuiltInNS(bool enable) { | 500 int VoEHardwareImpl::EnableBuiltInNS(bool enable) { |
501 if (!_shared->statistics().Initialized()) { | 501 if (!_shared->statistics().Initialized()) { |
502 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 502 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
503 return -1; | 503 return -1; |
504 } | 504 } |
505 return _shared->audio_device()->EnableBuiltInNS(enable); | 505 return _shared->audio_device()->EnableBuiltInNS(enable); |
506 } | 506 } |
507 | 507 |
508 } // namespace webrtc | 508 } // namespace webrtc |
OLD | NEW |