| 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); |
| 484 | 488 |
| 485 if (!_ptrAudioDevice) | 489 AudioDeviceGeneric::InitStatus status = _ptrAudioDevice->Init(); |
| 486 return -1; | 490 RTC_HISTOGRAM_ENUMERATION( |
| 487 | 491 "WebRTC.Audio.InitializationResult", static_cast<int>(status), |
| 488 if (_ptrAudioDevice->Init() == -1) { | 492 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES)); |
| 493 if (status != 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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 } | 1433 } |
| 1428 | 1434 |
| 1429 // ---------------------------------------------------------------------------- | 1435 // ---------------------------------------------------------------------------- |
| 1430 // InitPlayout | 1436 // InitPlayout |
| 1431 // ---------------------------------------------------------------------------- | 1437 // ---------------------------------------------------------------------------- |
| 1432 | 1438 |
| 1433 int32_t AudioDeviceModuleImpl::InitPlayout() { | 1439 int32_t AudioDeviceModuleImpl::InitPlayout() { |
| 1434 LOG(INFO) << __FUNCTION__; | 1440 LOG(INFO) << __FUNCTION__; |
| 1435 CHECK_INITIALIZED(); | 1441 CHECK_INITIALIZED(); |
| 1436 _audioDeviceBuffer.InitPlayout(); | 1442 _audioDeviceBuffer.InitPlayout(); |
| 1437 return (_ptrAudioDevice->InitPlayout()); | 1443 int32_t result = _ptrAudioDevice->InitPlayout(); |
| 1444 LOG(INFO) << "output: " << result; |
| 1445 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess", |
| 1446 static_cast<int>(result == 0)); |
| 1447 return result; |
| 1438 } | 1448 } |
| 1439 | 1449 |
| 1440 // ---------------------------------------------------------------------------- | 1450 // ---------------------------------------------------------------------------- |
| 1441 // InitRecording | 1451 // InitRecording |
| 1442 // ---------------------------------------------------------------------------- | 1452 // ---------------------------------------------------------------------------- |
| 1443 | 1453 |
| 1444 int32_t AudioDeviceModuleImpl::InitRecording() { | 1454 int32_t AudioDeviceModuleImpl::InitRecording() { |
| 1445 LOG(INFO) << __FUNCTION__; | 1455 LOG(INFO) << __FUNCTION__; |
| 1446 CHECK_INITIALIZED(); | 1456 CHECK_INITIALIZED(); |
| 1447 _audioDeviceBuffer.InitRecording(); | 1457 _audioDeviceBuffer.InitRecording(); |
| 1448 return (_ptrAudioDevice->InitRecording()); | 1458 int32_t result = _ptrAudioDevice->InitRecording(); |
| 1459 LOG(INFO) << "output: " << result; |
| 1460 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess", |
| 1461 static_cast<int>(result == 0)); |
| 1462 return result; |
| 1449 } | 1463 } |
| 1450 | 1464 |
| 1451 // ---------------------------------------------------------------------------- | 1465 // ---------------------------------------------------------------------------- |
| 1452 // PlayoutIsInitialized | 1466 // PlayoutIsInitialized |
| 1453 // ---------------------------------------------------------------------------- | 1467 // ---------------------------------------------------------------------------- |
| 1454 | 1468 |
| 1455 bool AudioDeviceModuleImpl::PlayoutIsInitialized() const { | 1469 bool AudioDeviceModuleImpl::PlayoutIsInitialized() const { |
| 1456 LOG(INFO) << __FUNCTION__; | 1470 LOG(INFO) << __FUNCTION__; |
| 1457 CHECK_INITIALIZED_BOOL(); | 1471 CHECK_INITIALIZED_BOOL(); |
| 1458 return (_ptrAudioDevice->PlayoutIsInitialized()); | 1472 return (_ptrAudioDevice->PlayoutIsInitialized()); |
| 1459 } | 1473 } |
| 1460 | 1474 |
| 1461 // ---------------------------------------------------------------------------- | 1475 // ---------------------------------------------------------------------------- |
| 1462 // RecordingIsInitialized | 1476 // RecordingIsInitialized |
| 1463 // ---------------------------------------------------------------------------- | 1477 // ---------------------------------------------------------------------------- |
| 1464 | 1478 |
| 1465 bool AudioDeviceModuleImpl::RecordingIsInitialized() const { | 1479 bool AudioDeviceModuleImpl::RecordingIsInitialized() const { |
| 1466 LOG(INFO) << __FUNCTION__; | 1480 LOG(INFO) << __FUNCTION__; |
| 1467 CHECK_INITIALIZED_BOOL(); | 1481 CHECK_INITIALIZED_BOOL(); |
| 1468 return (_ptrAudioDevice->RecordingIsInitialized()); | 1482 return (_ptrAudioDevice->RecordingIsInitialized()); |
| 1469 } | 1483 } |
| 1470 | 1484 |
| 1471 // ---------------------------------------------------------------------------- | 1485 // ---------------------------------------------------------------------------- |
| 1472 // StartPlayout | 1486 // StartPlayout |
| 1473 // ---------------------------------------------------------------------------- | 1487 // ---------------------------------------------------------------------------- |
| 1474 | 1488 |
| 1475 int32_t AudioDeviceModuleImpl::StartPlayout() { | 1489 int32_t AudioDeviceModuleImpl::StartPlayout() { |
| 1476 LOG(INFO) << __FUNCTION__; | 1490 LOG(INFO) << __FUNCTION__; |
| 1477 CHECK_INITIALIZED(); | 1491 CHECK_INITIALIZED(); |
| 1478 return (_ptrAudioDevice->StartPlayout()); | 1492 int32_t result = _ptrAudioDevice->StartPlayout(); |
| 1493 LOG(INFO) << "output: " << result; |
| 1494 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess", |
| 1495 static_cast<int>(result == 0)); |
| 1496 return result; |
| 1479 } | 1497 } |
| 1480 | 1498 |
| 1481 // ---------------------------------------------------------------------------- | 1499 // ---------------------------------------------------------------------------- |
| 1482 // StopPlayout | 1500 // StopPlayout |
| 1483 // ---------------------------------------------------------------------------- | 1501 // ---------------------------------------------------------------------------- |
| 1484 | 1502 |
| 1485 int32_t AudioDeviceModuleImpl::StopPlayout() { | 1503 int32_t AudioDeviceModuleImpl::StopPlayout() { |
| 1486 LOG(INFO) << __FUNCTION__; | 1504 LOG(INFO) << __FUNCTION__; |
| 1487 CHECK_INITIALIZED(); | 1505 CHECK_INITIALIZED(); |
| 1488 return (_ptrAudioDevice->StopPlayout()); | 1506 int32_t result = _ptrAudioDevice->StopPlayout(); |
| 1507 LOG(INFO) << "output: " << result; |
| 1508 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess", |
| 1509 static_cast<int>(result == 0)); |
| 1510 return result; |
| 1489 } | 1511 } |
| 1490 | 1512 |
| 1491 // ---------------------------------------------------------------------------- | 1513 // ---------------------------------------------------------------------------- |
| 1492 // Playing | 1514 // Playing |
| 1493 // ---------------------------------------------------------------------------- | 1515 // ---------------------------------------------------------------------------- |
| 1494 | 1516 |
| 1495 bool AudioDeviceModuleImpl::Playing() const { | 1517 bool AudioDeviceModuleImpl::Playing() const { |
| 1496 LOG(INFO) << __FUNCTION__; | 1518 LOG(INFO) << __FUNCTION__; |
| 1497 CHECK_INITIALIZED_BOOL(); | 1519 CHECK_INITIALIZED_BOOL(); |
| 1498 return (_ptrAudioDevice->Playing()); | 1520 return (_ptrAudioDevice->Playing()); |
| 1499 } | 1521 } |
| 1500 | 1522 |
| 1501 // ---------------------------------------------------------------------------- | 1523 // ---------------------------------------------------------------------------- |
| 1502 // StartRecording | 1524 // StartRecording |
| 1503 // ---------------------------------------------------------------------------- | 1525 // ---------------------------------------------------------------------------- |
| 1504 | 1526 |
| 1505 int32_t AudioDeviceModuleImpl::StartRecording() { | 1527 int32_t AudioDeviceModuleImpl::StartRecording() { |
| 1506 LOG(INFO) << __FUNCTION__; | 1528 LOG(INFO) << __FUNCTION__; |
| 1507 CHECK_INITIALIZED(); | 1529 CHECK_INITIALIZED(); |
| 1508 return (_ptrAudioDevice->StartRecording()); | 1530 int32_t result = _ptrAudioDevice->StartRecording(); |
| 1531 LOG(INFO) << "output: " << result; |
| 1532 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess", |
| 1533 static_cast<int>(result == 0)); |
| 1534 return result; |
| 1509 } | 1535 } |
| 1510 // ---------------------------------------------------------------------------- | 1536 // ---------------------------------------------------------------------------- |
| 1511 // StopRecording | 1537 // StopRecording |
| 1512 // ---------------------------------------------------------------------------- | 1538 // ---------------------------------------------------------------------------- |
| 1513 | 1539 |
| 1514 int32_t AudioDeviceModuleImpl::StopRecording() { | 1540 int32_t AudioDeviceModuleImpl::StopRecording() { |
| 1515 LOG(INFO) << __FUNCTION__; | 1541 LOG(INFO) << __FUNCTION__; |
| 1516 CHECK_INITIALIZED(); | 1542 CHECK_INITIALIZED(); |
| 1517 return (_ptrAudioDevice->StopRecording()); | 1543 int32_t result = _ptrAudioDevice->StopRecording(); |
| 1544 LOG(INFO) << "output: " << result; |
| 1545 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess", |
| 1546 static_cast<int>(result == 0)); |
| 1547 return result; |
| 1518 } | 1548 } |
| 1519 | 1549 |
| 1520 // ---------------------------------------------------------------------------- | 1550 // ---------------------------------------------------------------------------- |
| 1521 // Recording | 1551 // Recording |
| 1522 // ---------------------------------------------------------------------------- | 1552 // ---------------------------------------------------------------------------- |
| 1523 | 1553 |
| 1524 bool AudioDeviceModuleImpl::Recording() const { | 1554 bool AudioDeviceModuleImpl::Recording() const { |
| 1525 LOG(INFO) << __FUNCTION__; | 1555 LOG(INFO) << __FUNCTION__; |
| 1526 CHECK_INITIALIZED_BOOL(); | 1556 CHECK_INITIALIZED_BOOL(); |
| 1527 return (_ptrAudioDevice->Recording()); | 1557 return (_ptrAudioDevice->Recording()); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 // PlatformAudioLayer | 1996 // PlatformAudioLayer |
| 1967 // ---------------------------------------------------------------------------- | 1997 // ---------------------------------------------------------------------------- |
| 1968 | 1998 |
| 1969 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() | 1999 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() |
| 1970 const { | 2000 const { |
| 1971 LOG(INFO) << __FUNCTION__; | 2001 LOG(INFO) << __FUNCTION__; |
| 1972 return _platformAudioLayer; | 2002 return _platformAudioLayer; |
| 1973 } | 2003 } |
| 1974 | 2004 |
| 1975 } // namespace webrtc | 2005 } // namespace webrtc |
| OLD | NEW |