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 |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 629 |
630 if (_ptrAudioDevice->MinSpeakerVolume(minVol) == -1) { | 630 if (_ptrAudioDevice->MinSpeakerVolume(minVol) == -1) { |
631 return -1; | 631 return -1; |
632 } | 632 } |
633 | 633 |
634 *minVolume = minVol; | 634 *minVolume = minVol; |
635 return (0); | 635 return (0); |
636 } | 636 } |
637 | 637 |
638 // ---------------------------------------------------------------------------- | 638 // ---------------------------------------------------------------------------- |
639 // SpeakerVolumeStepSize | |
640 // ---------------------------------------------------------------------------- | |
641 | |
642 int32_t AudioDeviceModuleImpl::SpeakerVolumeStepSize(uint16_t* stepSize) const { | |
643 LOG(INFO) << __FUNCTION__; | |
644 CHECK_INITIALIZED(); | |
645 | |
646 uint16_t delta(0); | |
647 | |
648 if (_ptrAudioDevice->SpeakerVolumeStepSize(delta) == -1) { | |
649 LOG(LERROR) << "failed to retrieve the speaker-volume step size"; | |
650 return -1; | |
651 } | |
652 | |
653 *stepSize = delta; | |
654 LOG(INFO) << "output: " << *stepSize; | |
655 return (0); | |
656 } | |
657 | |
658 // ---------------------------------------------------------------------------- | |
659 // SpeakerMuteIsAvailable | 639 // SpeakerMuteIsAvailable |
660 // ---------------------------------------------------------------------------- | 640 // ---------------------------------------------------------------------------- |
661 | 641 |
662 int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) { | 642 int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) { |
663 LOG(INFO) << __FUNCTION__; | 643 LOG(INFO) << __FUNCTION__; |
664 CHECK_INITIALIZED(); | 644 CHECK_INITIALIZED(); |
665 | 645 |
666 bool isAvailable(0); | 646 bool isAvailable(0); |
667 | 647 |
668 if (_ptrAudioDevice->SpeakerMuteIsAvailable(isAvailable) == -1) { | 648 if (_ptrAudioDevice->SpeakerMuteIsAvailable(isAvailable) == -1) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 if (_ptrAudioDevice->MicrophoneMute(muted) == -1) { | 725 if (_ptrAudioDevice->MicrophoneMute(muted) == -1) { |
746 return -1; | 726 return -1; |
747 } | 727 } |
748 | 728 |
749 *enabled = muted; | 729 *enabled = muted; |
750 LOG(INFO) << "output: " << muted; | 730 LOG(INFO) << "output: " << muted; |
751 return (0); | 731 return (0); |
752 } | 732 } |
753 | 733 |
754 // ---------------------------------------------------------------------------- | 734 // ---------------------------------------------------------------------------- |
755 // MicrophoneBoostIsAvailable | |
756 // ---------------------------------------------------------------------------- | |
757 | |
758 int32_t AudioDeviceModuleImpl::MicrophoneBoostIsAvailable(bool* available) { | |
759 LOG(INFO) << __FUNCTION__; | |
760 CHECK_INITIALIZED(); | |
761 | |
762 bool isAvailable(0); | |
763 | |
764 if (_ptrAudioDevice->MicrophoneBoostIsAvailable(isAvailable) == -1) { | |
765 return -1; | |
766 } | |
767 | |
768 *available = isAvailable; | |
769 LOG(INFO) << "output: " << isAvailable; | |
770 return (0); | |
771 } | |
772 | |
773 // ---------------------------------------------------------------------------- | |
774 // SetMicrophoneBoost | |
775 // ---------------------------------------------------------------------------- | |
776 | |
777 int32_t AudioDeviceModuleImpl::SetMicrophoneBoost(bool enable) { | |
778 LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; | |
779 CHECK_INITIALIZED(); | |
780 return (_ptrAudioDevice->SetMicrophoneBoost(enable)); | |
781 } | |
782 | |
783 // ---------------------------------------------------------------------------- | |
784 // MicrophoneBoost | |
785 // ---------------------------------------------------------------------------- | |
786 | |
787 int32_t AudioDeviceModuleImpl::MicrophoneBoost(bool* enabled) const { | |
788 LOG(INFO) << __FUNCTION__; | |
789 CHECK_INITIALIZED(); | |
790 | |
791 bool onOff(false); | |
792 | |
793 if (_ptrAudioDevice->MicrophoneBoost(onOff) == -1) { | |
794 return -1; | |
795 } | |
796 | |
797 *enabled = onOff; | |
798 LOG(INFO) << "output: " << onOff; | |
799 return (0); | |
800 } | |
801 | |
802 // ---------------------------------------------------------------------------- | |
803 // MicrophoneVolumeIsAvailable | 735 // MicrophoneVolumeIsAvailable |
804 // ---------------------------------------------------------------------------- | 736 // ---------------------------------------------------------------------------- |
805 | 737 |
806 int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) { | 738 int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) { |
807 LOG(INFO) << __FUNCTION__; | 739 LOG(INFO) << __FUNCTION__; |
808 CHECK_INITIALIZED(); | 740 CHECK_INITIALIZED(); |
809 | 741 |
810 bool isAvailable(0); | 742 bool isAvailable(0); |
811 | 743 |
812 if (_ptrAudioDevice->MicrophoneVolumeIsAvailable(isAvailable) == -1) { | 744 if (_ptrAudioDevice->MicrophoneVolumeIsAvailable(isAvailable) == -1) { |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 | 1046 |
1115 if (_ptrAudioDevice->MinMicrophoneVolume(minVol) == -1) { | 1047 if (_ptrAudioDevice->MinMicrophoneVolume(minVol) == -1) { |
1116 return -1; | 1048 return -1; |
1117 } | 1049 } |
1118 | 1050 |
1119 *minVolume = minVol; | 1051 *minVolume = minVol; |
1120 return (0); | 1052 return (0); |
1121 } | 1053 } |
1122 | 1054 |
1123 // ---------------------------------------------------------------------------- | 1055 // ---------------------------------------------------------------------------- |
1124 // MicrophoneVolumeStepSize | |
1125 // ---------------------------------------------------------------------------- | |
1126 | |
1127 int32_t AudioDeviceModuleImpl::MicrophoneVolumeStepSize( | |
1128 uint16_t* stepSize) const { | |
1129 LOG(INFO) << __FUNCTION__; | |
1130 CHECK_INITIALIZED(); | |
1131 | |
1132 uint16_t delta(0); | |
1133 | |
1134 if (_ptrAudioDevice->MicrophoneVolumeStepSize(delta) == -1) { | |
1135 return -1; | |
1136 } | |
1137 | |
1138 *stepSize = delta; | |
1139 LOG(INFO) << "output: " << *stepSize; | |
1140 return (0); | |
1141 } | |
1142 | |
1143 // ---------------------------------------------------------------------------- | |
1144 // PlayoutDevices | 1056 // PlayoutDevices |
1145 // ---------------------------------------------------------------------------- | 1057 // ---------------------------------------------------------------------------- |
1146 | 1058 |
1147 int16_t AudioDeviceModuleImpl::PlayoutDevices() { | 1059 int16_t AudioDeviceModuleImpl::PlayoutDevices() { |
1148 LOG(INFO) << __FUNCTION__; | 1060 LOG(INFO) << __FUNCTION__; |
1149 CHECK_INITIALIZED(); | 1061 CHECK_INITIALIZED(); |
1150 | 1062 |
1151 uint16_t nPlayoutDevices = _ptrAudioDevice->PlayoutDevices(); | 1063 uint16_t nPlayoutDevices = _ptrAudioDevice->PlayoutDevices(); |
1152 LOG(INFO) << "output: " << nPlayoutDevices; | 1064 LOG(INFO) << "output: " << nPlayoutDevices; |
1153 return ((int16_t)(nPlayoutDevices)); | 1065 return ((int16_t)(nPlayoutDevices)); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 // ---------------------------------------------------------------------------- | 1338 // ---------------------------------------------------------------------------- |
1427 | 1339 |
1428 int32_t AudioDeviceModuleImpl::RegisterAudioCallback( | 1340 int32_t AudioDeviceModuleImpl::RegisterAudioCallback( |
1429 AudioTransport* audioCallback) { | 1341 AudioTransport* audioCallback) { |
1430 LOG(INFO) << __FUNCTION__; | 1342 LOG(INFO) << __FUNCTION__; |
1431 rtc::CritScope lock(&_critSectAudioCb); | 1343 rtc::CritScope lock(&_critSectAudioCb); |
1432 return _audioDeviceBuffer.RegisterAudioCallback(audioCallback); | 1344 return _audioDeviceBuffer.RegisterAudioCallback(audioCallback); |
1433 } | 1345 } |
1434 | 1346 |
1435 // ---------------------------------------------------------------------------- | 1347 // ---------------------------------------------------------------------------- |
1436 // StartRawInputFileRecording | |
1437 // ---------------------------------------------------------------------------- | |
1438 | |
1439 int32_t AudioDeviceModuleImpl::StartRawInputFileRecording( | |
1440 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { | |
1441 LOG(INFO) << __FUNCTION__; | |
1442 CHECK_INITIALIZED(); | |
1443 | |
1444 if (NULL == pcmFileNameUTF8) { | |
1445 return -1; | |
1446 } | |
1447 | |
1448 return (_audioDeviceBuffer.StartInputFileRecording(pcmFileNameUTF8)); | |
1449 } | |
1450 | |
1451 // ---------------------------------------------------------------------------- | |
1452 // StopRawInputFileRecording | |
1453 // ---------------------------------------------------------------------------- | |
1454 | |
1455 int32_t AudioDeviceModuleImpl::StopRawInputFileRecording() { | |
1456 LOG(INFO) << __FUNCTION__; | |
1457 CHECK_INITIALIZED(); | |
1458 | |
1459 return (_audioDeviceBuffer.StopInputFileRecording()); | |
1460 } | |
1461 | |
1462 // ---------------------------------------------------------------------------- | |
1463 // StartRawOutputFileRecording | |
1464 // ---------------------------------------------------------------------------- | |
1465 | |
1466 int32_t AudioDeviceModuleImpl::StartRawOutputFileRecording( | |
1467 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { | |
1468 LOG(INFO) << __FUNCTION__; | |
1469 CHECK_INITIALIZED(); | |
1470 | |
1471 if (NULL == pcmFileNameUTF8) { | |
1472 return -1; | |
1473 } | |
1474 | |
1475 return (_audioDeviceBuffer.StartOutputFileRecording(pcmFileNameUTF8)); | |
1476 } | |
1477 | |
1478 // ---------------------------------------------------------------------------- | |
1479 // StopRawOutputFileRecording | |
1480 // ---------------------------------------------------------------------------- | |
1481 | |
1482 int32_t AudioDeviceModuleImpl::StopRawOutputFileRecording() { | |
1483 LOG(INFO) << __FUNCTION__; | |
1484 CHECK_INITIALIZED(); | |
1485 | |
1486 return (_audioDeviceBuffer.StopOutputFileRecording()); | |
1487 } | |
1488 | |
1489 // ---------------------------------------------------------------------------- | |
1490 // SetPlayoutBuffer | |
1491 // ---------------------------------------------------------------------------- | |
1492 | |
1493 int32_t AudioDeviceModuleImpl::SetPlayoutBuffer(const BufferType type, | |
1494 uint16_t sizeMS) { | |
1495 if (type == kFixedBufferSize) { | |
1496 LOG(INFO) << __FUNCTION__ << "(fixed buffer, " << sizeMS << "ms)"; | |
1497 } else if (type == kAdaptiveBufferSize) { | |
1498 LOG(INFO) << __FUNCTION__ << "(adaptive buffer, " << sizeMS << "ms)"; | |
1499 } else { | |
1500 LOG(INFO) << __FUNCTION__ << "(?, " << sizeMS << "ms)"; | |
1501 } | |
1502 CHECK_INITIALIZED(); | |
1503 | |
1504 if (_ptrAudioDevice->PlayoutIsInitialized()) { | |
1505 LOG(LERROR) << "unable to modify the playout buffer while playing side is " | |
1506 "initialized"; | |
1507 return -1; | |
1508 } | |
1509 | |
1510 int32_t ret(0); | |
1511 | |
1512 if (kFixedBufferSize == type) { | |
1513 if (sizeMS < kAdmMinPlayoutBufferSizeMs || | |
1514 sizeMS > kAdmMaxPlayoutBufferSizeMs) { | |
1515 LOG(LERROR) << "size parameter is out of range"; | |
1516 return -1; | |
1517 } | |
1518 } | |
1519 | |
1520 if ((ret = _ptrAudioDevice->SetPlayoutBuffer(type, sizeMS)) == -1) { | |
1521 LOG(LERROR) << "failed to set the playout buffer (error: " << LastError() | |
1522 << ")"; | |
1523 } | |
1524 | |
1525 return ret; | |
1526 } | |
1527 | |
1528 // ---------------------------------------------------------------------------- | |
1529 // PlayoutBuffer | |
1530 // ---------------------------------------------------------------------------- | |
1531 | |
1532 int32_t AudioDeviceModuleImpl::PlayoutBuffer(BufferType* type, | |
1533 uint16_t* sizeMS) const { | |
1534 LOG(INFO) << __FUNCTION__; | |
1535 CHECK_INITIALIZED(); | |
1536 | |
1537 BufferType bufType; | |
1538 uint16_t size(0); | |
1539 | |
1540 if (_ptrAudioDevice->PlayoutBuffer(bufType, size) == -1) { | |
1541 LOG(LERROR) << "failed to retrieve the buffer type and size"; | |
1542 return -1; | |
1543 } | |
1544 | |
1545 *type = bufType; | |
1546 *sizeMS = size; | |
1547 | |
1548 LOG(INFO) << "output: type = " << *type << ", sizeMS = " << *sizeMS; | |
1549 return (0); | |
1550 } | |
1551 | |
1552 // ---------------------------------------------------------------------------- | |
1553 // PlayoutDelay | 1348 // PlayoutDelay |
1554 // ---------------------------------------------------------------------------- | 1349 // ---------------------------------------------------------------------------- |
1555 | 1350 |
1556 int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const { | 1351 int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const { |
1557 CHECK_INITIALIZED(); | 1352 CHECK_INITIALIZED(); |
1558 | 1353 |
1559 uint16_t delay(0); | 1354 uint16_t delay(0); |
1560 | 1355 |
1561 if (_ptrAudioDevice->PlayoutDelay(delay) == -1) { | 1356 if (_ptrAudioDevice->PlayoutDelay(delay) == -1) { |
1562 LOG(LERROR) << "failed to retrieve the playout delay"; | 1357 LOG(LERROR) << "failed to retrieve the playout delay"; |
(...skipping 18 matching lines...) Expand all Loading... |
1581 LOG(LERROR) << "failed to retrieve the recording delay"; | 1376 LOG(LERROR) << "failed to retrieve the recording delay"; |
1582 return -1; | 1377 return -1; |
1583 } | 1378 } |
1584 | 1379 |
1585 *delayMS = delay; | 1380 *delayMS = delay; |
1586 LOG(INFO) << "output: " << *delayMS; | 1381 LOG(INFO) << "output: " << *delayMS; |
1587 return (0); | 1382 return (0); |
1588 } | 1383 } |
1589 | 1384 |
1590 // ---------------------------------------------------------------------------- | 1385 // ---------------------------------------------------------------------------- |
1591 // CPULoad | |
1592 // ---------------------------------------------------------------------------- | |
1593 | |
1594 int32_t AudioDeviceModuleImpl::CPULoad(uint16_t* load) const { | |
1595 LOG(INFO) << __FUNCTION__; | |
1596 CHECK_INITIALIZED(); | |
1597 | |
1598 uint16_t cpuLoad(0); | |
1599 | |
1600 if (_ptrAudioDevice->CPULoad(cpuLoad) == -1) { | |
1601 LOG(LERROR) << "failed to retrieve the CPU load"; | |
1602 return -1; | |
1603 } | |
1604 | |
1605 *load = cpuLoad; | |
1606 LOG(INFO) << "output: " << *load; | |
1607 return (0); | |
1608 } | |
1609 | |
1610 // ---------------------------------------------------------------------------- | |
1611 // SetRecordingSampleRate | 1386 // SetRecordingSampleRate |
1612 // ---------------------------------------------------------------------------- | 1387 // ---------------------------------------------------------------------------- |
1613 | 1388 |
1614 int32_t AudioDeviceModuleImpl::SetRecordingSampleRate( | 1389 int32_t AudioDeviceModuleImpl::SetRecordingSampleRate( |
1615 const uint32_t samplesPerSec) { | 1390 const uint32_t samplesPerSec) { |
1616 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")"; | 1391 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")"; |
1617 CHECK_INITIALIZED(); | 1392 CHECK_INITIALIZED(); |
1618 | 1393 |
1619 if (_ptrAudioDevice->SetRecordingSampleRate(samplesPerSec) != 0) { | 1394 if (_ptrAudioDevice->SetRecordingSampleRate(samplesPerSec) != 0) { |
1620 return -1; | 1395 return -1; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 LOG(LERROR) << "failed to retrieve the sample rate"; | 1450 LOG(LERROR) << "failed to retrieve the sample rate"; |
1676 return -1; | 1451 return -1; |
1677 } | 1452 } |
1678 | 1453 |
1679 *samplesPerSec = sampleRate; | 1454 *samplesPerSec = sampleRate; |
1680 LOG(INFO) << "output: " << *samplesPerSec; | 1455 LOG(INFO) << "output: " << *samplesPerSec; |
1681 return (0); | 1456 return (0); |
1682 } | 1457 } |
1683 | 1458 |
1684 // ---------------------------------------------------------------------------- | 1459 // ---------------------------------------------------------------------------- |
1685 // ResetAudioDevice | |
1686 // ---------------------------------------------------------------------------- | |
1687 | |
1688 int32_t AudioDeviceModuleImpl::ResetAudioDevice() { | |
1689 LOG(INFO) << __FUNCTION__; | |
1690 FATAL() << "Should never be called"; | |
1691 return -1; | |
1692 } | |
1693 | |
1694 // ---------------------------------------------------------------------------- | |
1695 // SetLoudspeakerStatus | 1460 // SetLoudspeakerStatus |
1696 // ---------------------------------------------------------------------------- | 1461 // ---------------------------------------------------------------------------- |
1697 | 1462 |
1698 int32_t AudioDeviceModuleImpl::SetLoudspeakerStatus(bool enable) { | 1463 int32_t AudioDeviceModuleImpl::SetLoudspeakerStatus(bool enable) { |
1699 LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; | 1464 LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
1700 CHECK_INITIALIZED(); | 1465 CHECK_INITIALIZED(); |
1701 | 1466 |
1702 if (_ptrAudioDevice->SetLoudspeakerStatus(enable) != 0) { | 1467 if (_ptrAudioDevice->SetLoudspeakerStatus(enable) != 0) { |
1703 return -1; | 1468 return -1; |
1704 } | 1469 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 // PlatformAudioLayer | 1569 // PlatformAudioLayer |
1805 // ---------------------------------------------------------------------------- | 1570 // ---------------------------------------------------------------------------- |
1806 | 1571 |
1807 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() | 1572 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() |
1808 const { | 1573 const { |
1809 LOG(INFO) << __FUNCTION__; | 1574 LOG(INFO) << __FUNCTION__; |
1810 return _platformAudioLayer; | 1575 return _platformAudioLayer; |
1811 } | 1576 } |
1812 | 1577 |
1813 } // namespace webrtc | 1578 } // namespace webrtc |
OLD | NEW |