blob: d01caa94233787fdfcba4d3bce256d63ebb797ea [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
xians@webrtc.org79af7342012-01-31 12:22:14 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000011#include "webrtc/voice_engine/voe_hardware_impl.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000013#include <assert.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000014
Henrik Kjellander98f53512015-10-28 18:17:40 +010015#include "webrtc/system_wrappers/include/trace.h"
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000016#include "webrtc/voice_engine/include/voe_errors.h"
17#include "webrtc/voice_engine/voice_engine_impl.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000018
Jelena Marusic0d266052015-05-04 14:15:32 +020019namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000020
Jelena Marusic0d266052015-05-04 14:15:32 +020021VoEHardware* VoEHardware::GetInterface(VoiceEngine* voiceEngine) {
niklase@google.com470e71d2011-07-07 08:21:25 +000022#ifndef WEBRTC_VOICE_ENGINE_HARDWARE_API
Jelena Marusic0d266052015-05-04 14:15:32 +020023 return NULL;
niklase@google.com470e71d2011-07-07 08:21:25 +000024#else
Jelena Marusic0d266052015-05-04 14:15:32 +020025 if (NULL == voiceEngine) {
26 return NULL;
27 }
28 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
29 s->AddRef();
30 return s;
niklase@google.com470e71d2011-07-07 08:21:25 +000031#endif
32}
33
34#ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API
35
Jelena Marusic0d266052015-05-04 14:15:32 +020036VoEHardwareImpl::VoEHardwareImpl(voe::SharedData* shared) : _shared(shared) {
37 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
38 "VoEHardwareImpl() - ctor");
niklase@google.com470e71d2011-07-07 08:21:25 +000039}
40
Jelena Marusic0d266052015-05-04 14:15:32 +020041VoEHardwareImpl::~VoEHardwareImpl() {
42 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
43 "~VoEHardwareImpl() - dtor");
niklase@google.com470e71d2011-07-07 08:21:25 +000044}
45
Jelena Marusic0d266052015-05-04 14:15:32 +020046int VoEHardwareImpl::SetAudioDeviceLayer(AudioLayers audioLayer) {
47 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
48 "SetAudioDeviceLayer(audioLayer=%d)", audioLayer);
niklase@google.com470e71d2011-07-07 08:21:25 +000049
Jelena Marusic0d266052015-05-04 14:15:32 +020050 // Don't allow a change if VoE is initialized
51 if (_shared->statistics().Initialized()) {
52 _shared->SetLastError(VE_ALREADY_INITED, kTraceError);
53 return -1;
54 }
niklase@google.com470e71d2011-07-07 08:21:25 +000055
Jelena Marusic0d266052015-05-04 14:15:32 +020056 // Map to AudioDeviceModule::AudioLayer
57 AudioDeviceModule::AudioLayer wantedLayer(
58 AudioDeviceModule::kPlatformDefaultAudio);
59 switch (audioLayer) {
60 case kAudioPlatformDefault:
61 // already set above
62 break;
63 case kAudioWindowsCore:
64 wantedLayer = AudioDeviceModule::kWindowsCoreAudio;
65 break;
66 case kAudioWindowsWave:
67 wantedLayer = AudioDeviceModule::kWindowsWaveAudio;
68 break;
69 case kAudioLinuxAlsa:
70 wantedLayer = AudioDeviceModule::kLinuxAlsaAudio;
71 break;
72 case kAudioLinuxPulse:
73 wantedLayer = AudioDeviceModule::kLinuxPulseAudio;
74 break;
75 }
niklase@google.com470e71d2011-07-07 08:21:25 +000076
Jelena Marusic0d266052015-05-04 14:15:32 +020077 // Save the audio device layer for Init()
78 _shared->set_audio_device_layer(wantedLayer);
niklase@google.com470e71d2011-07-07 08:21:25 +000079
Jelena Marusic0d266052015-05-04 14:15:32 +020080 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000081}
82
Jelena Marusic0d266052015-05-04 14:15:32 +020083int VoEHardwareImpl::GetAudioDeviceLayer(AudioLayers& audioLayer) {
Jelena Marusic0d266052015-05-04 14:15:32 +020084 // Can always be called regardless of VoE state
niklase@google.com470e71d2011-07-07 08:21:25 +000085
Jelena Marusic0d266052015-05-04 14:15:32 +020086 AudioDeviceModule::AudioLayer activeLayer(
87 AudioDeviceModule::kPlatformDefaultAudio);
niklase@google.com470e71d2011-07-07 08:21:25 +000088
Jelena Marusic0d266052015-05-04 14:15:32 +020089 if (_shared->audio_device()) {
90 // Get active audio layer from ADM
91 if (_shared->audio_device()->ActiveAudioLayer(&activeLayer) != 0) {
92 _shared->SetLastError(VE_UNDEFINED_SC_ERR, kTraceError,
93 " Audio Device error");
94 return -1;
niklase@google.com470e71d2011-07-07 08:21:25 +000095 }
Jelena Marusic0d266052015-05-04 14:15:32 +020096 } else {
97 // Return VoE's internal layer setting
98 activeLayer = _shared->audio_device_layer();
99 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
Jelena Marusic0d266052015-05-04 14:15:32 +0200101 // Map to AudioLayers
102 switch (activeLayer) {
103 case AudioDeviceModule::kPlatformDefaultAudio:
104 audioLayer = kAudioPlatformDefault;
105 break;
106 case AudioDeviceModule::kWindowsCoreAudio:
107 audioLayer = kAudioWindowsCore;
108 break;
109 case AudioDeviceModule::kWindowsWaveAudio:
110 audioLayer = kAudioWindowsWave;
111 break;
112 case AudioDeviceModule::kLinuxAlsaAudio:
113 audioLayer = kAudioLinuxAlsa;
114 break;
115 case AudioDeviceModule::kLinuxPulseAudio:
116 audioLayer = kAudioLinuxPulse;
117 break;
118 default:
119 _shared->SetLastError(VE_UNDEFINED_SC_ERR, kTraceError,
120 " unknown audio layer");
121 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000122
Jelena Marusic0d266052015-05-04 14:15:32 +0200123 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000124}
Jelena Marusic0d266052015-05-04 14:15:32 +0200125int VoEHardwareImpl::GetNumOfRecordingDevices(int& devices) {
Jelena Marusic0d266052015-05-04 14:15:32 +0200126 if (!_shared->statistics().Initialized()) {
127 _shared->SetLastError(VE_NOT_INITED, kTraceError);
128 return -1;
129 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000130
Jelena Marusic0d266052015-05-04 14:15:32 +0200131 devices = static_cast<int>(_shared->audio_device()->RecordingDevices());
niklase@google.com470e71d2011-07-07 08:21:25 +0000132
Jelena Marusic0d266052015-05-04 14:15:32 +0200133 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000134}
135
Jelena Marusic0d266052015-05-04 14:15:32 +0200136int VoEHardwareImpl::GetNumOfPlayoutDevices(int& devices) {
Jelena Marusic0d266052015-05-04 14:15:32 +0200137 if (!_shared->statistics().Initialized()) {
138 _shared->SetLastError(VE_NOT_INITED, kTraceError);
139 return -1;
140 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000141
Jelena Marusic0d266052015-05-04 14:15:32 +0200142 devices = static_cast<int>(_shared->audio_device()->PlayoutDevices());
niklase@google.com470e71d2011-07-07 08:21:25 +0000143
Jelena Marusic0d266052015-05-04 14:15:32 +0200144 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000145}
146
147int VoEHardwareImpl::GetRecordingDeviceName(int index,
148 char strNameUTF8[128],
Jelena Marusic0d266052015-05-04 14:15:32 +0200149 char strGuidUTF8[128]) {
Jelena Marusic0d266052015-05-04 14:15:32 +0200150 if (!_shared->statistics().Initialized()) {
151 _shared->SetLastError(VE_NOT_INITED, kTraceError);
152 return -1;
153 }
154 if (strNameUTF8 == NULL) {
155 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
156 "GetRecordingDeviceName() invalid argument");
157 return -1;
158 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000159
Jelena Marusic0d266052015-05-04 14:15:32 +0200160 // Note that strGuidUTF8 is allowed to be NULL
niklase@google.com470e71d2011-07-07 08:21:25 +0000161
Jelena Marusic0d266052015-05-04 14:15:32 +0200162 // Init len variable to length of supplied vectors
163 const uint16_t strLen = 128;
niklase@google.com470e71d2011-07-07 08:21:25 +0000164
Jelena Marusic0d266052015-05-04 14:15:32 +0200165 // Check if length has been changed in module
André Susano Pinto664cdaf2015-05-20 11:11:07 +0200166 static_assert(strLen == kAdmMaxDeviceNameSize, "");
167 static_assert(strLen == kAdmMaxGuidSize, "");
niklase@google.com470e71d2011-07-07 08:21:25 +0000168
Jelena Marusic0d266052015-05-04 14:15:32 +0200169 char name[strLen];
170 char guid[strLen];
niklase@google.com470e71d2011-07-07 08:21:25 +0000171
Jelena Marusic0d266052015-05-04 14:15:32 +0200172 // Get names from module
173 if (_shared->audio_device()->RecordingDeviceName(index, name, guid) != 0) {
174 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError,
175 "GetRecordingDeviceName() failed to get device name");
176 return -1;
177 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000178
Jelena Marusic0d266052015-05-04 14:15:32 +0200179 // Copy to vectors supplied by user
180 strncpy(strNameUTF8, name, strLen);
Jelena Marusic0d266052015-05-04 14:15:32 +0200181
182 if (strGuidUTF8 != NULL) {
183 strncpy(strGuidUTF8, guid, strLen);
Jelena Marusic0d266052015-05-04 14:15:32 +0200184 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000185
Jelena Marusic0d266052015-05-04 14:15:32 +0200186 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000187}
188
189int VoEHardwareImpl::GetPlayoutDeviceName(int index,
190 char strNameUTF8[128],
Jelena Marusic0d266052015-05-04 14:15:32 +0200191 char strGuidUTF8[128]) {
Jelena Marusic0d266052015-05-04 14:15:32 +0200192 if (!_shared->statistics().Initialized()) {
193 _shared->SetLastError(VE_NOT_INITED, kTraceError);
194 return -1;
195 }
196 if (strNameUTF8 == NULL) {
197 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
198 "GetPlayoutDeviceName() invalid argument");
199 return -1;
200 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000201
Jelena Marusic0d266052015-05-04 14:15:32 +0200202 // Note that strGuidUTF8 is allowed to be NULL
niklase@google.com470e71d2011-07-07 08:21:25 +0000203
Jelena Marusic0d266052015-05-04 14:15:32 +0200204 // Init len variable to length of supplied vectors
205 const uint16_t strLen = 128;
niklase@google.com470e71d2011-07-07 08:21:25 +0000206
Jelena Marusic0d266052015-05-04 14:15:32 +0200207 // Check if length has been changed in module
André Susano Pinto664cdaf2015-05-20 11:11:07 +0200208 static_assert(strLen == kAdmMaxDeviceNameSize, "");
209 static_assert(strLen == kAdmMaxGuidSize, "");
niklase@google.com470e71d2011-07-07 08:21:25 +0000210
Jelena Marusic0d266052015-05-04 14:15:32 +0200211 char name[strLen];
212 char guid[strLen];
niklase@google.com470e71d2011-07-07 08:21:25 +0000213
Jelena Marusic0d266052015-05-04 14:15:32 +0200214 // Get names from module
215 if (_shared->audio_device()->PlayoutDeviceName(index, name, guid) != 0) {
216 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError,
217 "GetPlayoutDeviceName() failed to get device name");
218 return -1;
219 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000220
Jelena Marusic0d266052015-05-04 14:15:32 +0200221 // Copy to vectors supplied by user
222 strncpy(strNameUTF8, name, strLen);
Jelena Marusic0d266052015-05-04 14:15:32 +0200223
224 if (strGuidUTF8 != NULL) {
225 strncpy(strGuidUTF8, guid, strLen);
Jelena Marusic0d266052015-05-04 14:15:32 +0200226 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000227
Jelena Marusic0d266052015-05-04 14:15:32 +0200228 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000229}
230
231int VoEHardwareImpl::SetRecordingDevice(int index,
Jelena Marusic0d266052015-05-04 14:15:32 +0200232 StereoChannel recordingChannel) {
233 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
234 "SetRecordingDevice(index=%d, recordingChannel=%d)", index,
235 (int)recordingChannel);
tommi31fc21f2016-01-21 10:37:37 -0800236 rtc::CritScope cs(_shared->crit_sec());
niklase@google.com470e71d2011-07-07 08:21:25 +0000237
Jelena Marusic0d266052015-05-04 14:15:32 +0200238 if (!_shared->statistics().Initialized()) {
239 _shared->SetLastError(VE_NOT_INITED, kTraceError);
240 return -1;
241 }
242
243 bool isRecording(false);
244
245 // Store state about activated recording to be able to restore it after the
246 // recording device has been modified.
247 if (_shared->audio_device()->Recording()) {
248 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
249 "SetRecordingDevice() device is modified while recording"
250 " is active...");
251 isRecording = true;
252 if (_shared->audio_device()->StopRecording() == -1) {
253 _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
254 "SetRecordingDevice() unable to stop recording");
255 return -1;
256 }
257 }
258
259 // We let the module do the index sanity
260
261 // Set recording channel
262 AudioDeviceModule::ChannelType recCh = AudioDeviceModule::kChannelBoth;
263 switch (recordingChannel) {
264 case kStereoLeft:
265 recCh = AudioDeviceModule::kChannelLeft;
266 break;
267 case kStereoRight:
268 recCh = AudioDeviceModule::kChannelRight;
269 break;
270 case kStereoBoth:
271 // default setting kChannelBoth (<=> mono)
272 break;
273 }
274
275 if (_shared->audio_device()->SetRecordingChannel(recCh) != 0) {
276 _shared->SetLastError(
277 VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
278 "SetRecordingChannel() unable to set the recording channel");
279 }
280
281 // Map indices to unsigned since underlying functions need that
282 uint16_t indexU = static_cast<uint16_t>(index);
283
284 int32_t res(0);
285
286 if (index == -1) {
287 res = _shared->audio_device()->SetRecordingDevice(
288 AudioDeviceModule::kDefaultCommunicationDevice);
289 } else if (index == -2) {
290 res = _shared->audio_device()->SetRecordingDevice(
291 AudioDeviceModule::kDefaultDevice);
292 } else {
293 res = _shared->audio_device()->SetRecordingDevice(indexU);
294 }
295
296 if (res != 0) {
297 _shared->SetLastError(
298 VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
299 "SetRecordingDevice() unable to set the recording device");
300 return -1;
301 }
302
303 // Init microphone, so user can do volume settings etc
304 if (_shared->audio_device()->InitMicrophone() == -1) {
305 _shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceWarning,
306 "SetRecordingDevice() cannot access microphone");
307 }
308
309 // Set number of channels
310 bool available = false;
311 if (_shared->audio_device()->StereoRecordingIsAvailable(&available) != 0) {
312 _shared->SetLastError(
313 VE_SOUNDCARD_ERROR, kTraceWarning,
314 "StereoRecordingIsAvailable() failed to query stereo recording");
315 }
316
317 if (_shared->audio_device()->SetStereoRecording(available) != 0) {
318 _shared->SetLastError(
319 VE_SOUNDCARD_ERROR, kTraceWarning,
320 "SetRecordingDevice() failed to set mono recording mode");
321 }
322
323 // Restore recording if it was enabled already when calling this function.
324 if (isRecording) {
solenberge313e022015-09-08 02:16:04 -0700325 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
326 "SetRecordingDevice() recording is now being restored...");
327 if (_shared->audio_device()->InitRecording() != 0) {
328 WEBRTC_TRACE(kTraceError, kTraceVoice,
329 VoEId(_shared->instance_id(), -1),
330 "SetRecordingDevice() failed to initialize recording");
331 return -1;
332 }
333 if (_shared->audio_device()->StartRecording() != 0) {
334 WEBRTC_TRACE(kTraceError, kTraceVoice,
335 VoEId(_shared->instance_id(), -1),
336 "SetRecordingDevice() failed to start recording");
337 return -1;
niklase@google.com470e71d2011-07-07 08:21:25 +0000338 }
Jelena Marusic0d266052015-05-04 14:15:32 +0200339 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000340
Jelena Marusic0d266052015-05-04 14:15:32 +0200341 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000342}
343
Jelena Marusic0d266052015-05-04 14:15:32 +0200344int VoEHardwareImpl::SetPlayoutDevice(int index) {
345 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
346 "SetPlayoutDevice(index=%d)", index);
tommi31fc21f2016-01-21 10:37:37 -0800347 rtc::CritScope cs(_shared->crit_sec());
niklase@google.com470e71d2011-07-07 08:21:25 +0000348
Jelena Marusic0d266052015-05-04 14:15:32 +0200349 if (!_shared->statistics().Initialized()) {
350 _shared->SetLastError(VE_NOT_INITED, kTraceError);
351 return -1;
352 }
353
354 bool isPlaying(false);
355
356 // Store state about activated playout to be able to restore it after the
357 // playout device has been modified.
358 if (_shared->audio_device()->Playing()) {
359 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
360 "SetPlayoutDevice() device is modified while playout is "
361 "active...");
362 isPlaying = true;
363 if (_shared->audio_device()->StopPlayout() == -1) {
364 _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
365 "SetPlayoutDevice() unable to stop playout");
366 return -1;
367 }
368 }
369
370 // We let the module do the index sanity
371
372 // Map indices to unsigned since underlying functions need that
373 uint16_t indexU = static_cast<uint16_t>(index);
374
375 int32_t res(0);
376
377 if (index == -1) {
378 res = _shared->audio_device()->SetPlayoutDevice(
379 AudioDeviceModule::kDefaultCommunicationDevice);
380 } else if (index == -2) {
381 res = _shared->audio_device()->SetPlayoutDevice(
382 AudioDeviceModule::kDefaultDevice);
383 } else {
384 res = _shared->audio_device()->SetPlayoutDevice(indexU);
385 }
386
387 if (res != 0) {
388 _shared->SetLastError(
389 VE_SOUNDCARD_ERROR, kTraceError,
390 "SetPlayoutDevice() unable to set the playout device");
391 return -1;
392 }
393
394 // Init speaker, so user can do volume settings etc
395 if (_shared->audio_device()->InitSpeaker() == -1) {
396 _shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceWarning,
397 "SetPlayoutDevice() cannot access speaker");
398 }
399
400 // Set number of channels
401 bool available = false;
402 _shared->audio_device()->StereoPlayoutIsAvailable(&available);
403 if (_shared->audio_device()->SetStereoPlayout(available) != 0) {
404 _shared->SetLastError(
405 VE_SOUNDCARD_ERROR, kTraceWarning,
406 "SetPlayoutDevice() failed to set stereo playout mode");
407 }
408
409 // Restore playout if it was enabled already when calling this function.
410 if (isPlaying) {
solenberge313e022015-09-08 02:16:04 -0700411 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
412 "SetPlayoutDevice() playout is now being restored...");
413 if (_shared->audio_device()->InitPlayout() != 0) {
414 WEBRTC_TRACE(kTraceError, kTraceVoice,
415 VoEId(_shared->instance_id(), -1),
416 "SetPlayoutDevice() failed to initialize playout");
417 return -1;
418 }
419 if (_shared->audio_device()->StartPlayout() != 0) {
420 WEBRTC_TRACE(kTraceError, kTraceVoice,
421 VoEId(_shared->instance_id(), -1),
422 "SetPlayoutDevice() failed to start playout");
423 return -1;
niklase@google.com470e71d2011-07-07 08:21:25 +0000424 }
Jelena Marusic0d266052015-05-04 14:15:32 +0200425 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000426
Jelena Marusic0d266052015-05-04 14:15:32 +0200427 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000428}
429
leozwang@webrtc.org96bcac82012-12-04 19:11:55 +0000430int VoEHardwareImpl::SetRecordingSampleRate(unsigned int samples_per_sec) {
431 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
432 "%s", __FUNCTION__);
433 if (!_shared->statistics().Initialized()) {
434 _shared->SetLastError(VE_NOT_INITED, kTraceError);
435 return false;
436 }
437 return _shared->audio_device()->SetRecordingSampleRate(samples_per_sec);
438}
439
440int VoEHardwareImpl::RecordingSampleRate(unsigned int* samples_per_sec) const {
leozwang@webrtc.org96bcac82012-12-04 19:11:55 +0000441 if (!_shared->statistics().Initialized()) {
442 _shared->SetLastError(VE_NOT_INITED, kTraceError);
443 return false;
444 }
445 return _shared->audio_device()->RecordingSampleRate(samples_per_sec);
446}
447
448int VoEHardwareImpl::SetPlayoutSampleRate(unsigned int samples_per_sec) {
449 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
450 "%s", __FUNCTION__);
451 if (!_shared->statistics().Initialized()) {
452 _shared->SetLastError(VE_NOT_INITED, kTraceError);
453 return false;
454 }
455 return _shared->audio_device()->SetPlayoutSampleRate(samples_per_sec);
456}
457
458int VoEHardwareImpl::PlayoutSampleRate(unsigned int* samples_per_sec) const {
leozwang@webrtc.org96bcac82012-12-04 19:11:55 +0000459 if (!_shared->statistics().Initialized()) {
460 _shared->SetLastError(VE_NOT_INITED, kTraceError);
461 return false;
462 }
463 return _shared->audio_device()->PlayoutSampleRate(samples_per_sec);
464}
465
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000466bool VoEHardwareImpl::BuiltInAECIsAvailable() const {
Jelena Marusic0d266052015-05-04 14:15:32 +0200467 if (!_shared->statistics().Initialized()) {
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000468 _shared->SetLastError(VE_NOT_INITED, kTraceError);
469 return false;
470 }
471 return _shared->audio_device()->BuiltInAECIsAvailable();
472}
473
474int VoEHardwareImpl::EnableBuiltInAEC(bool enable) {
Jelena Marusic0d266052015-05-04 14:15:32 +0200475 if (!_shared->statistics().Initialized()) {
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000476 _shared->SetLastError(VE_NOT_INITED, kTraceError);
Bjorn Volcker1d83f1e2015-04-07 15:25:39 +0200477 return -1;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000478 }
479 return _shared->audio_device()->EnableBuiltInAEC(enable);
480}
481
henrikac14f5ff2015-09-23 14:08:33 +0200482bool VoEHardwareImpl::BuiltInAGCIsAvailable() const {
483 if (!_shared->statistics().Initialized()) {
484 _shared->SetLastError(VE_NOT_INITED, kTraceError);
485 return false;
486 }
487 return _shared->audio_device()->BuiltInAGCIsAvailable();
488}
489
490int VoEHardwareImpl::EnableBuiltInAGC(bool enable) {
491 if (!_shared->statistics().Initialized()) {
492 _shared->SetLastError(VE_NOT_INITED, kTraceError);
493 return -1;
494 }
495 return _shared->audio_device()->EnableBuiltInAGC(enable);
496}
497
498bool VoEHardwareImpl::BuiltInNSIsAvailable() const {
499 if (!_shared->statistics().Initialized()) {
500 _shared->SetLastError(VE_NOT_INITED, kTraceError);
501 return false;
502 }
503 return _shared->audio_device()->BuiltInNSIsAvailable();
504}
505
506int VoEHardwareImpl::EnableBuiltInNS(bool enable) {
507 if (!_shared->statistics().Initialized()) {
508 _shared->SetLastError(VE_NOT_INITED, kTraceError);
509 return -1;
510 }
511 return _shared->audio_device()->EnableBuiltInNS(enable);
512}
513
niklase@google.com470e71d2011-07-07 08:21:25 +0000514#endif // WEBRTC_VOICE_ENGINE_HARDWARE_API
515
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000516} // namespace webrtc