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/base/checks.h" |
11 #include "webrtc/base/logging.h" | 12 #include "webrtc/base/logging.h" |
12 #include "webrtc/base/refcount.h" | 13 #include "webrtc/base/refcount.h" |
13 #include "webrtc/base/timeutils.h" | 14 #include "webrtc/base/timeutils.h" |
14 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 15 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
15 #include "webrtc/modules/audio_device/audio_device_config.h" | 16 #include "webrtc/modules/audio_device/audio_device_config.h" |
| 17 #include "webrtc/modules/audio_device/audio_device_generic.h" |
16 #include "webrtc/modules/audio_device/audio_device_impl.h" | 18 #include "webrtc/modules/audio_device/audio_device_impl.h" |
| 19 #include "webrtc/system_wrappers/include/metrics.h" |
17 | 20 |
18 #include <assert.h> | 21 #include <assert.h> |
19 #include <string.h> | 22 #include <string.h> |
20 | 23 |
21 #if defined(_WIN32) | 24 #if defined(_WIN32) |
22 #include "audio_device_wave_win.h" | 25 #include "audio_device_wave_win.h" |
23 #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) | 26 #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
24 #include "audio_device_core_win.h" | 27 #include "audio_device_core_win.h" |
25 #endif | 28 #endif |
26 #elif defined(WEBRTC_ANDROID) | 29 #elif defined(WEBRTC_ANDROID) |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // Create the *Linux* implementation of the Audio Device | 262 // Create the *Linux* implementation of the Audio Device |
260 // | 263 // |
261 #elif defined(WEBRTC_LINUX) | 264 #elif defined(WEBRTC_LINUX) |
262 if ((audioLayer == kLinuxPulseAudio) || | 265 if ((audioLayer == kLinuxPulseAudio) || |
263 (audioLayer == kPlatformDefaultAudio)) { | 266 (audioLayer == kPlatformDefaultAudio)) { |
264 #if defined(LINUX_PULSE) | 267 #if defined(LINUX_PULSE) |
265 LOG(INFO) << "attempting to use the Linux PulseAudio APIs..."; | 268 LOG(INFO) << "attempting to use the Linux PulseAudio APIs..."; |
266 | 269 |
267 // create *Linux PulseAudio* implementation | 270 // create *Linux PulseAudio* implementation |
268 AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(Id()); | 271 AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(Id()); |
269 if (pulseDevice->Init() != -1) { | 272 if (pulseDevice->Init() == AudioDeviceGeneric::InitStatus::OK) { |
270 ptrAudioDevice = pulseDevice; | 273 ptrAudioDevice = pulseDevice; |
271 LOG(INFO) << "Linux PulseAudio APIs will be utilized"; | 274 LOG(INFO) << "Linux PulseAudio APIs will be utilized"; |
272 } else { | 275 } else { |
273 delete pulseDevice; | 276 delete pulseDevice; |
274 #endif | 277 #endif |
275 #if defined(LINUX_ALSA) | 278 #if defined(LINUX_ALSA) |
276 // create *Linux ALSA Audio* implementation | 279 // create *Linux ALSA Audio* implementation |
277 ptrAudioDevice = new AudioDeviceLinuxALSA(Id()); | 280 ptrAudioDevice = new AudioDeviceLinuxALSA(Id()); |
278 if (ptrAudioDevice != NULL) { | 281 if (ptrAudioDevice != NULL) { |
279 // Pulse Audio was not supported => revert to ALSA instead | 282 // Pulse Audio was not supported => revert to ALSA instead |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 477 } |
475 | 478 |
476 // ---------------------------------------------------------------------------- | 479 // ---------------------------------------------------------------------------- |
477 // Init | 480 // Init |
478 // ---------------------------------------------------------------------------- | 481 // ---------------------------------------------------------------------------- |
479 | 482 |
480 int32_t AudioDeviceModuleImpl::Init() { | 483 int32_t AudioDeviceModuleImpl::Init() { |
481 LOG(INFO) << __FUNCTION__; | 484 LOG(INFO) << __FUNCTION__; |
482 if (_initialized) | 485 if (_initialized) |
483 return 0; | 486 return 0; |
| 487 RTC_CHECK(_ptrAudioDevice) << "no _ptrAudioDevice!"; |
484 | 488 |
485 if (!_ptrAudioDevice) | 489 AudioDeviceGeneric::InitStatus err = _ptrAudioDevice->Init(); |
486 return -1; | 490 RTC_HISTOGRAM_ENUMERATION( |
487 | 491 "WebRTC.Audio.InitializationResult", static_cast<int>(err), |
488 if (_ptrAudioDevice->Init() == -1) { | 492 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES)); |
| 493 if (err != AudioDeviceGeneric::InitStatus::OK) { |
| 494 LOG(LS_ERROR) << "audio device initialization failed."; |
489 return -1; | 495 return -1; |
490 } | 496 } |
491 | 497 |
492 _initialized = true; | 498 _initialized = true; |
493 return 0; | 499 return 0; |
494 } | 500 } |
495 | 501 |
496 // ---------------------------------------------------------------------------- | 502 // ---------------------------------------------------------------------------- |
497 // Terminate | 503 // Terminate |
498 // ---------------------------------------------------------------------------- | 504 // ---------------------------------------------------------------------------- |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 return (_ptrAudioDevice->RecordingIsInitialized()); | 1474 return (_ptrAudioDevice->RecordingIsInitialized()); |
1469 } | 1475 } |
1470 | 1476 |
1471 // ---------------------------------------------------------------------------- | 1477 // ---------------------------------------------------------------------------- |
1472 // StartPlayout | 1478 // StartPlayout |
1473 // ---------------------------------------------------------------------------- | 1479 // ---------------------------------------------------------------------------- |
1474 | 1480 |
1475 int32_t AudioDeviceModuleImpl::StartPlayout() { | 1481 int32_t AudioDeviceModuleImpl::StartPlayout() { |
1476 LOG(INFO) << __FUNCTION__; | 1482 LOG(INFO) << __FUNCTION__; |
1477 CHECK_INITIALIZED(); | 1483 CHECK_INITIALIZED(); |
1478 return (_ptrAudioDevice->StartPlayout()); | 1484 int32_t r = _ptrAudioDevice->StartPlayout(); |
| 1485 LOG(INFO) << "output: " << r; |
| 1486 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.StartPlayoutSuccess", |
| 1487 static_cast<int>(r == 0), 2); |
| 1488 return r; |
1479 } | 1489 } |
1480 | 1490 |
1481 // ---------------------------------------------------------------------------- | 1491 // ---------------------------------------------------------------------------- |
1482 // StopPlayout | 1492 // StopPlayout |
1483 // ---------------------------------------------------------------------------- | 1493 // ---------------------------------------------------------------------------- |
1484 | 1494 |
1485 int32_t AudioDeviceModuleImpl::StopPlayout() { | 1495 int32_t AudioDeviceModuleImpl::StopPlayout() { |
1486 LOG(INFO) << __FUNCTION__; | 1496 LOG(INFO) << __FUNCTION__; |
1487 CHECK_INITIALIZED(); | 1497 CHECK_INITIALIZED(); |
1488 return (_ptrAudioDevice->StopPlayout()); | 1498 return (_ptrAudioDevice->StopPlayout()); |
1489 } | 1499 } |
1490 | 1500 |
1491 // ---------------------------------------------------------------------------- | 1501 // ---------------------------------------------------------------------------- |
1492 // Playing | 1502 // Playing |
1493 // ---------------------------------------------------------------------------- | 1503 // ---------------------------------------------------------------------------- |
1494 | 1504 |
1495 bool AudioDeviceModuleImpl::Playing() const { | 1505 bool AudioDeviceModuleImpl::Playing() const { |
1496 LOG(INFO) << __FUNCTION__; | 1506 LOG(INFO) << __FUNCTION__; |
1497 CHECK_INITIALIZED_BOOL(); | 1507 CHECK_INITIALIZED_BOOL(); |
1498 return (_ptrAudioDevice->Playing()); | 1508 return (_ptrAudioDevice->Playing()); |
1499 } | 1509 } |
1500 | 1510 |
1501 // ---------------------------------------------------------------------------- | 1511 // ---------------------------------------------------------------------------- |
1502 // StartRecording | 1512 // StartRecording |
1503 // ---------------------------------------------------------------------------- | 1513 // ---------------------------------------------------------------------------- |
1504 | 1514 |
1505 int32_t AudioDeviceModuleImpl::StartRecording() { | 1515 int32_t AudioDeviceModuleImpl::StartRecording() { |
1506 LOG(INFO) << __FUNCTION__; | 1516 LOG(INFO) << __FUNCTION__; |
1507 CHECK_INITIALIZED(); | 1517 CHECK_INITIALIZED(); |
1508 return (_ptrAudioDevice->StartRecording()); | 1518 int32_t r = _ptrAudioDevice->StartRecording(); |
| 1519 LOG(INFO) << "output: " << r; |
| 1520 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.StartRecordingSuccess", |
| 1521 static_cast<int>(r == 0), 2); |
| 1522 return r; |
1509 } | 1523 } |
1510 // ---------------------------------------------------------------------------- | 1524 // ---------------------------------------------------------------------------- |
1511 // StopRecording | 1525 // StopRecording |
1512 // ---------------------------------------------------------------------------- | 1526 // ---------------------------------------------------------------------------- |
1513 | 1527 |
1514 int32_t AudioDeviceModuleImpl::StopRecording() { | 1528 int32_t AudioDeviceModuleImpl::StopRecording() { |
1515 LOG(INFO) << __FUNCTION__; | 1529 LOG(INFO) << __FUNCTION__; |
1516 CHECK_INITIALIZED(); | 1530 CHECK_INITIALIZED(); |
1517 return (_ptrAudioDevice->StopRecording()); | 1531 return (_ptrAudioDevice->StopRecording()); |
1518 } | 1532 } |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 // PlatformAudioLayer | 1980 // PlatformAudioLayer |
1967 // ---------------------------------------------------------------------------- | 1981 // ---------------------------------------------------------------------------- |
1968 | 1982 |
1969 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() | 1983 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() |
1970 const { | 1984 const { |
1971 LOG(INFO) << __FUNCTION__; | 1985 LOG(INFO) << __FUNCTION__; |
1972 return _platformAudioLayer; | 1986 return _platformAudioLayer; |
1973 } | 1987 } |
1974 | 1988 |
1975 } // namespace webrtc | 1989 } // namespace webrtc |
OLD | NEW |