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/logging.h" | 11 #include "webrtc/base/logging.h" |
12 #include "webrtc/base/refcount.h" | 12 #include "webrtc/base/refcount.h" |
13 #include "webrtc/base/timeutils.h" | 13 #include "webrtc/base/timeutils.h" |
14 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" | 14 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" |
15 #include "webrtc/modules/audio_device/audio_device_config.h" | 15 #include "webrtc/modules/audio_device/audio_device_config.h" |
16 #include "webrtc/modules/audio_device/audio_device_generic.h" | |
16 #include "webrtc/modules/audio_device/audio_device_impl.h" | 17 #include "webrtc/modules/audio_device/audio_device_impl.h" |
18 #include "webrtc/system_wrappers/include/metrics.h" | |
17 | 19 |
18 #include <assert.h> | 20 #include <assert.h> |
19 #include <string.h> | 21 #include <string.h> |
20 | 22 |
21 #if defined(_WIN32) | 23 #if defined(_WIN32) |
22 #include "audio_device_wave_win.h" | 24 #include "audio_device_wave_win.h" |
23 #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) | 25 #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
24 #include "audio_device_core_win.h" | 26 #include "audio_device_core_win.h" |
25 #endif | 27 #endif |
26 #elif defined(WEBRTC_ANDROID) | 28 #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 | 261 // Create the *Linux* implementation of the Audio Device |
260 // | 262 // |
261 #elif defined(WEBRTC_LINUX) | 263 #elif defined(WEBRTC_LINUX) |
262 if ((audioLayer == kLinuxPulseAudio) || | 264 if ((audioLayer == kLinuxPulseAudio) || |
263 (audioLayer == kPlatformDefaultAudio)) { | 265 (audioLayer == kPlatformDefaultAudio)) { |
264 #if defined(LINUX_PULSE) | 266 #if defined(LINUX_PULSE) |
265 LOG(INFO) << "attempting to use the Linux PulseAudio APIs..."; | 267 LOG(INFO) << "attempting to use the Linux PulseAudio APIs..."; |
266 | 268 |
267 // create *Linux PulseAudio* implementation | 269 // create *Linux PulseAudio* implementation |
268 AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(Id()); | 270 AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(Id()); |
269 if (pulseDevice->Init() != -1) { | 271 if (pulseDevice->Init() == AudioDeviceGeneric::InitStatus::kOk) { |
henrika_webrtc
2016/06/30 08:44:20
Can you get rid of the AudioDeviceGeneric:: prefix
Max Morin WebRTC
2016/06/30 10:56:04
I could throw InitStatus into audio_device_config.
| |
270 ptrAudioDevice = pulseDevice; | 272 ptrAudioDevice = pulseDevice; |
271 LOG(INFO) << "Linux PulseAudio APIs will be utilized"; | 273 LOG(INFO) << "Linux PulseAudio APIs will be utilized"; |
272 } else { | 274 } else { |
273 delete pulseDevice; | 275 delete pulseDevice; |
274 #endif | 276 #endif |
275 #if defined(LINUX_ALSA) | 277 #if defined(LINUX_ALSA) |
276 // create *Linux ALSA Audio* implementation | 278 // create *Linux ALSA Audio* implementation |
277 ptrAudioDevice = new AudioDeviceLinuxALSA(Id()); | 279 ptrAudioDevice = new AudioDeviceLinuxALSA(Id()); |
278 if (ptrAudioDevice != NULL) { | 280 if (ptrAudioDevice != NULL) { |
279 // Pulse Audio was not supported => revert to ALSA instead | 281 // Pulse Audio was not supported => revert to ALSA instead |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 | 477 |
476 // ---------------------------------------------------------------------------- | 478 // ---------------------------------------------------------------------------- |
477 // Init | 479 // Init |
478 // ---------------------------------------------------------------------------- | 480 // ---------------------------------------------------------------------------- |
479 | 481 |
480 int32_t AudioDeviceModuleImpl::Init() { | 482 int32_t AudioDeviceModuleImpl::Init() { |
481 LOG(INFO) << __FUNCTION__; | 483 LOG(INFO) << __FUNCTION__; |
482 if (_initialized) | 484 if (_initialized) |
483 return 0; | 485 return 0; |
484 | 486 |
485 if (!_ptrAudioDevice) | 487 if (!_ptrAudioDevice) { |
488 LOG(LS_ERROR) << __FUNCTION__ << " called with _ptrAudioDevice == nullptr."; | |
henrika_webrtc
2016/06/30 08:44:20
I actually think we should do CHECK() << "short co
Max Morin WebRTC
2016/06/30 10:56:04
Done.
| |
486 return -1; | 489 return -1; |
487 | 490 } |
488 if (_ptrAudioDevice->Init() == -1) { | 491 AudioDeviceGeneric::InitStatus err = _ptrAudioDevice->Init(); |
492 RTC_HISTOGRAM_ENUMERATION( | |
493 "WebRTC.Audio.InitializationResult", static_cast<int>(err), | |
494 static_cast<int>(AudioDeviceGeneric::InitStatus::kNumStatuses)); | |
495 if (err != AudioDeviceGeneric::InitStatus::kOk) { | |
496 LOG(LS_ERROR) << __FUNCTION__ << " audio device initialization failed."; | |
henrika_webrtc
2016/06/30 08:44:20
Don't need __FUNCTION__. Give shorter comment.
Max Morin WebRTC
2016/06/30 10:56:04
Done.
| |
489 return -1; | 497 return -1; |
490 } | 498 } |
491 | 499 |
492 _initialized = true; | 500 _initialized = true; |
493 return 0; | 501 return 0; |
494 } | 502 } |
495 | 503 |
496 // ---------------------------------------------------------------------------- | 504 // ---------------------------------------------------------------------------- |
497 // Terminate | 505 // Terminate |
498 // ---------------------------------------------------------------------------- | 506 // ---------------------------------------------------------------------------- |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1468 return (_ptrAudioDevice->RecordingIsInitialized()); | 1476 return (_ptrAudioDevice->RecordingIsInitialized()); |
1469 } | 1477 } |
1470 | 1478 |
1471 // ---------------------------------------------------------------------------- | 1479 // ---------------------------------------------------------------------------- |
1472 // StartPlayout | 1480 // StartPlayout |
1473 // ---------------------------------------------------------------------------- | 1481 // ---------------------------------------------------------------------------- |
1474 | 1482 |
1475 int32_t AudioDeviceModuleImpl::StartPlayout() { | 1483 int32_t AudioDeviceModuleImpl::StartPlayout() { |
1476 LOG(INFO) << __FUNCTION__; | 1484 LOG(INFO) << __FUNCTION__; |
1477 CHECK_INITIALIZED(); | 1485 CHECK_INITIALIZED(); |
1478 return (_ptrAudioDevice->StartPlayout()); | 1486 int32_t r = _ptrAudioDevice->StartPlayout(); |
henrika_webrtc
2016/06/30 08:44:20
Feels a bit unclear converting to an int here. Can
Max Morin WebRTC
2016/06/30 10:56:04
There is no conversion, StartPlayout returns an in
| |
1487 LOG(INFO) << __FUNCTION__ << " output: " << r; | |
henrika_webrtc
2016/06/30 08:44:20
Remove _FUNCTION_. THe log will be OK even without
Max Morin WebRTC
2016/06/30 10:56:04
Done.
| |
1488 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.StartPlayoutSuccess", | |
1489 static_cast<int>(r == 0), 2); | |
1490 return r; | |
1479 } | 1491 } |
1480 | 1492 |
1481 // ---------------------------------------------------------------------------- | 1493 // ---------------------------------------------------------------------------- |
1482 // StopPlayout | 1494 // StopPlayout |
1483 // ---------------------------------------------------------------------------- | 1495 // ---------------------------------------------------------------------------- |
1484 | 1496 |
1485 int32_t AudioDeviceModuleImpl::StopPlayout() { | 1497 int32_t AudioDeviceModuleImpl::StopPlayout() { |
1486 LOG(INFO) << __FUNCTION__; | 1498 LOG(INFO) << __FUNCTION__; |
1487 CHECK_INITIALIZED(); | 1499 CHECK_INITIALIZED(); |
1488 return (_ptrAudioDevice->StopPlayout()); | 1500 return (_ptrAudioDevice->StopPlayout()); |
1489 } | 1501 } |
1490 | 1502 |
1491 // ---------------------------------------------------------------------------- | 1503 // ---------------------------------------------------------------------------- |
1492 // Playing | 1504 // Playing |
1493 // ---------------------------------------------------------------------------- | 1505 // ---------------------------------------------------------------------------- |
1494 | 1506 |
1495 bool AudioDeviceModuleImpl::Playing() const { | 1507 bool AudioDeviceModuleImpl::Playing() const { |
1496 LOG(INFO) << __FUNCTION__; | 1508 LOG(INFO) << __FUNCTION__; |
1497 CHECK_INITIALIZED_BOOL(); | 1509 CHECK_INITIALIZED_BOOL(); |
1498 return (_ptrAudioDevice->Playing()); | 1510 return (_ptrAudioDevice->Playing()); |
1499 } | 1511 } |
1500 | 1512 |
1501 // ---------------------------------------------------------------------------- | 1513 // ---------------------------------------------------------------------------- |
1502 // StartRecording | 1514 // StartRecording |
1503 // ---------------------------------------------------------------------------- | 1515 // ---------------------------------------------------------------------------- |
1504 | 1516 |
1505 int32_t AudioDeviceModuleImpl::StartRecording() { | 1517 int32_t AudioDeviceModuleImpl::StartRecording() { |
1506 LOG(INFO) << __FUNCTION__; | 1518 LOG(INFO) << __FUNCTION__; |
1507 CHECK_INITIALIZED(); | 1519 CHECK_INITIALIZED(); |
1508 return (_ptrAudioDevice->StartRecording()); | 1520 int32_t r = _ptrAudioDevice->StartRecording(); |
henrika_webrtc
2016/06/30 08:44:20
Same here.
Max Morin WebRTC
2016/06/30 10:56:04
Done.
| |
1521 LOG(INFO) << __FUNCTION__ << " output: " << r; | |
1522 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.StartRecordingSuccess", | |
1523 static_cast<int>(r == 0), 2); | |
1524 return r; | |
1509 } | 1525 } |
1510 // ---------------------------------------------------------------------------- | 1526 // ---------------------------------------------------------------------------- |
1511 // StopRecording | 1527 // StopRecording |
1512 // ---------------------------------------------------------------------------- | 1528 // ---------------------------------------------------------------------------- |
1513 | 1529 |
1514 int32_t AudioDeviceModuleImpl::StopRecording() { | 1530 int32_t AudioDeviceModuleImpl::StopRecording() { |
1515 LOG(INFO) << __FUNCTION__; | 1531 LOG(INFO) << __FUNCTION__; |
1516 CHECK_INITIALIZED(); | 1532 CHECK_INITIALIZED(); |
1517 return (_ptrAudioDevice->StopRecording()); | 1533 return (_ptrAudioDevice->StopRecording()); |
1518 } | 1534 } |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1966 // PlatformAudioLayer | 1982 // PlatformAudioLayer |
1967 // ---------------------------------------------------------------------------- | 1983 // ---------------------------------------------------------------------------- |
1968 | 1984 |
1969 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() | 1985 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() |
1970 const { | 1986 const { |
1971 LOG(INFO) << __FUNCTION__; | 1987 LOG(INFO) << __FUNCTION__; |
1972 return _platformAudioLayer; | 1988 return _platformAudioLayer; |
1973 } | 1989 } |
1974 | 1990 |
1975 } // namespace webrtc | 1991 } // namespace webrtc |
OLD | NEW |