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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // ============================================================================ | 399 // ============================================================================ |
400 // Construction & Destruction | 400 // Construction & Destruction |
401 // ============================================================================ | 401 // ============================================================================ |
402 | 402 |
403 // ---------------------------------------------------------------------------- | 403 // ---------------------------------------------------------------------------- |
404 // AudioDeviceWindowsCore() - ctor | 404 // AudioDeviceWindowsCore() - ctor |
405 // ---------------------------------------------------------------------------- | 405 // ---------------------------------------------------------------------------- |
406 | 406 |
407 AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) : | 407 AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) : |
408 _comInit(ScopedCOMInitializer::kMTA), | 408 _comInit(ScopedCOMInitializer::kMTA), |
409 _critSect(*CriticalSectionWrapper::CreateCriticalSection()), | |
410 _volumeMutex(*CriticalSectionWrapper::CreateCriticalSection()), | |
411 _id(id), | 409 _id(id), |
412 _ptrAudioBuffer(NULL), | 410 _ptrAudioBuffer(NULL), |
413 _ptrEnumerator(NULL), | 411 _ptrEnumerator(NULL), |
414 _ptrRenderCollection(NULL), | 412 _ptrRenderCollection(NULL), |
415 _ptrCaptureCollection(NULL), | 413 _ptrCaptureCollection(NULL), |
416 _ptrDeviceOut(NULL), | 414 _ptrDeviceOut(NULL), |
417 _ptrDeviceIn(NULL), | 415 _ptrDeviceIn(NULL), |
418 _ptrClientOut(NULL), | 416 _ptrClientOut(NULL), |
419 _ptrClientIn(NULL), | 417 _ptrClientIn(NULL), |
420 _ptrRenderClient(NULL), | 418 _ptrRenderClient(NULL), |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 { | 629 { |
632 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, | 630 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
633 "AudioDeviceWindowsCore::~AudioDeviceWindowsCore() failed to fre
e the loaded Avrt DLL module correctly"); | 631 "AudioDeviceWindowsCore::~AudioDeviceWindowsCore() failed to fre
e the loaded Avrt DLL module correctly"); |
634 } | 632 } |
635 else | 633 else |
636 { | 634 { |
637 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, | 635 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
638 "AudioDeviceWindowsCore::~AudioDeviceWindowsCore() the Avrt DLL
module is now unloaded"); | 636 "AudioDeviceWindowsCore::~AudioDeviceWindowsCore() the Avrt DLL
module is now unloaded"); |
639 } | 637 } |
640 } | 638 } |
641 | |
642 delete &_critSect; | |
643 delete &_volumeMutex; | |
644 } | 639 } |
645 | 640 |
646 // ============================================================================ | 641 // ============================================================================ |
647 // API | 642 // API |
648 // ============================================================================ | 643 // ============================================================================ |
649 | 644 |
650 // ---------------------------------------------------------------------------- | 645 // ---------------------------------------------------------------------------- |
651 // AttachAudioBuffer | 646 // AttachAudioBuffer |
652 // ---------------------------------------------------------------------------- | 647 // ---------------------------------------------------------------------------- |
653 | 648 |
(...skipping 19 matching lines...) Expand all Loading... |
673 { | 668 { |
674 audioLayer = AudioDeviceModule::kWindowsCoreAudio; | 669 audioLayer = AudioDeviceModule::kWindowsCoreAudio; |
675 return 0; | 670 return 0; |
676 } | 671 } |
677 | 672 |
678 // ---------------------------------------------------------------------------- | 673 // ---------------------------------------------------------------------------- |
679 // Init | 674 // Init |
680 // ---------------------------------------------------------------------------- | 675 // ---------------------------------------------------------------------------- |
681 | 676 |
682 AudioDeviceGeneric::InitStatus AudioDeviceWindowsCore::Init() { | 677 AudioDeviceGeneric::InitStatus AudioDeviceWindowsCore::Init() { |
683 CriticalSectionScoped lock(&_critSect); | 678 rtc::CritScope lock(&_critSect); |
684 | 679 |
685 if (_initialized) { | 680 if (_initialized) { |
686 return InitStatus::OK; | 681 return InitStatus::OK; |
687 } | 682 } |
688 | 683 |
689 _playWarning = 0; | 684 _playWarning = 0; |
690 _playError = 0; | 685 _playError = 0; |
691 _recWarning = 0; | 686 _recWarning = 0; |
692 _recError = 0; | 687 _recError = 0; |
693 | 688 |
694 // Enumerate all audio rendering and capturing endpoint devices. | 689 // Enumerate all audio rendering and capturing endpoint devices. |
695 // Note that, some of these will not be able to select by the user. | 690 // Note that, some of these will not be able to select by the user. |
696 // The complete collection is for internal use only. | 691 // The complete collection is for internal use only. |
697 _EnumerateEndpointDevicesAll(eRender); | 692 _EnumerateEndpointDevicesAll(eRender); |
698 _EnumerateEndpointDevicesAll(eCapture); | 693 _EnumerateEndpointDevicesAll(eCapture); |
699 | 694 |
700 _initialized = true; | 695 _initialized = true; |
701 | 696 |
702 return InitStatus::OK; | 697 return InitStatus::OK; |
703 } | 698 } |
704 | 699 |
705 // ---------------------------------------------------------------------------- | 700 // ---------------------------------------------------------------------------- |
706 // Terminate | 701 // Terminate |
707 // ---------------------------------------------------------------------------- | 702 // ---------------------------------------------------------------------------- |
708 | 703 |
709 int32_t AudioDeviceWindowsCore::Terminate() | 704 int32_t AudioDeviceWindowsCore::Terminate() |
710 { | 705 { |
711 | 706 |
712 CriticalSectionScoped lock(&_critSect); | 707 rtc::CritScope lock(&_critSect); |
713 | 708 |
714 if (!_initialized) { | 709 if (!_initialized) { |
715 return 0; | 710 return 0; |
716 } | 711 } |
717 | 712 |
718 _initialized = false; | 713 _initialized = false; |
719 _speakerIsInitialized = false; | 714 _speakerIsInitialized = false; |
720 _microphoneIsInitialized = false; | 715 _microphoneIsInitialized = false; |
721 _playing = false; | 716 _playing = false; |
722 _recording = false; | 717 _recording = false; |
(...skipping 21 matching lines...) Expand all Loading... |
744 return (_initialized); | 739 return (_initialized); |
745 } | 740 } |
746 | 741 |
747 // ---------------------------------------------------------------------------- | 742 // ---------------------------------------------------------------------------- |
748 // InitSpeaker | 743 // InitSpeaker |
749 // ---------------------------------------------------------------------------- | 744 // ---------------------------------------------------------------------------- |
750 | 745 |
751 int32_t AudioDeviceWindowsCore::InitSpeaker() | 746 int32_t AudioDeviceWindowsCore::InitSpeaker() |
752 { | 747 { |
753 | 748 |
754 CriticalSectionScoped lock(&_critSect); | 749 rtc::CritScope lock(&_critSect); |
755 | 750 |
756 if (_playing) | 751 if (_playing) |
757 { | 752 { |
758 return -1; | 753 return -1; |
759 } | 754 } |
760 | 755 |
761 if (_ptrDeviceOut == NULL) | 756 if (_ptrDeviceOut == NULL) |
762 { | 757 { |
763 return -1; | 758 return -1; |
764 } | 759 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 return 0; | 821 return 0; |
827 } | 822 } |
828 | 823 |
829 // ---------------------------------------------------------------------------- | 824 // ---------------------------------------------------------------------------- |
830 // InitMicrophone | 825 // InitMicrophone |
831 // ---------------------------------------------------------------------------- | 826 // ---------------------------------------------------------------------------- |
832 | 827 |
833 int32_t AudioDeviceWindowsCore::InitMicrophone() | 828 int32_t AudioDeviceWindowsCore::InitMicrophone() |
834 { | 829 { |
835 | 830 |
836 CriticalSectionScoped lock(&_critSect); | 831 rtc::CritScope lock(&_critSect); |
837 | 832 |
838 if (_recording) | 833 if (_recording) |
839 { | 834 { |
840 return -1; | 835 return -1; |
841 } | 836 } |
842 | 837 |
843 if (_ptrDeviceIn == NULL) | 838 if (_ptrDeviceIn == NULL) |
844 { | 839 { |
845 return -1; | 840 return -1; |
846 } | 841 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 return (_microphoneIsInitialized); | 911 return (_microphoneIsInitialized); |
917 } | 912 } |
918 | 913 |
919 // ---------------------------------------------------------------------------- | 914 // ---------------------------------------------------------------------------- |
920 // SpeakerVolumeIsAvailable | 915 // SpeakerVolumeIsAvailable |
921 // ---------------------------------------------------------------------------- | 916 // ---------------------------------------------------------------------------- |
922 | 917 |
923 int32_t AudioDeviceWindowsCore::SpeakerVolumeIsAvailable(bool& available) | 918 int32_t AudioDeviceWindowsCore::SpeakerVolumeIsAvailable(bool& available) |
924 { | 919 { |
925 | 920 |
926 CriticalSectionScoped lock(&_critSect); | 921 rtc::CritScope lock(&_critSect); |
927 | 922 |
928 if (_ptrDeviceOut == NULL) | 923 if (_ptrDeviceOut == NULL) |
929 { | 924 { |
930 return -1; | 925 return -1; |
931 } | 926 } |
932 | 927 |
933 HRESULT hr = S_OK; | 928 HRESULT hr = S_OK; |
934 IAudioSessionManager* pManager = NULL; | 929 IAudioSessionManager* pManager = NULL; |
935 ISimpleAudioVolume* pVolume = NULL; | 930 ISimpleAudioVolume* pVolume = NULL; |
936 | 931 |
(...skipping 24 matching lines...) Expand all Loading... |
961 } | 956 } |
962 | 957 |
963 // ---------------------------------------------------------------------------- | 958 // ---------------------------------------------------------------------------- |
964 // SetSpeakerVolume | 959 // SetSpeakerVolume |
965 // ---------------------------------------------------------------------------- | 960 // ---------------------------------------------------------------------------- |
966 | 961 |
967 int32_t AudioDeviceWindowsCore::SetSpeakerVolume(uint32_t volume) | 962 int32_t AudioDeviceWindowsCore::SetSpeakerVolume(uint32_t volume) |
968 { | 963 { |
969 | 964 |
970 { | 965 { |
971 CriticalSectionScoped lock(&_critSect); | 966 rtc::CritScope lock(&_critSect); |
972 | 967 |
973 if (!_speakerIsInitialized) | 968 if (!_speakerIsInitialized) |
974 { | 969 { |
975 return -1; | 970 return -1; |
976 } | 971 } |
977 | 972 |
978 if (_ptrDeviceOut == NULL) | 973 if (_ptrDeviceOut == NULL) |
979 { | 974 { |
980 return -1; | 975 return -1; |
981 } | 976 } |
(...skipping 22 matching lines...) Expand all Loading... |
1004 } | 999 } |
1005 | 1000 |
1006 // ---------------------------------------------------------------------------- | 1001 // ---------------------------------------------------------------------------- |
1007 // SpeakerVolume | 1002 // SpeakerVolume |
1008 // ---------------------------------------------------------------------------- | 1003 // ---------------------------------------------------------------------------- |
1009 | 1004 |
1010 int32_t AudioDeviceWindowsCore::SpeakerVolume(uint32_t& volume) const | 1005 int32_t AudioDeviceWindowsCore::SpeakerVolume(uint32_t& volume) const |
1011 { | 1006 { |
1012 | 1007 |
1013 { | 1008 { |
1014 CriticalSectionScoped lock(&_critSect); | 1009 rtc::CritScope lock(&_critSect); |
1015 | 1010 |
1016 if (!_speakerIsInitialized) | 1011 if (!_speakerIsInitialized) |
1017 { | 1012 { |
1018 return -1; | 1013 return -1; |
1019 } | 1014 } |
1020 | 1015 |
1021 if (_ptrDeviceOut == NULL) | 1016 if (_ptrDeviceOut == NULL) |
1022 { | 1017 { |
1023 return -1; | 1018 return -1; |
1024 } | 1019 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 return 0; | 1111 return 0; |
1117 } | 1112 } |
1118 | 1113 |
1119 // ---------------------------------------------------------------------------- | 1114 // ---------------------------------------------------------------------------- |
1120 // SpeakerMuteIsAvailable | 1115 // SpeakerMuteIsAvailable |
1121 // ---------------------------------------------------------------------------- | 1116 // ---------------------------------------------------------------------------- |
1122 | 1117 |
1123 int32_t AudioDeviceWindowsCore::SpeakerMuteIsAvailable(bool& available) | 1118 int32_t AudioDeviceWindowsCore::SpeakerMuteIsAvailable(bool& available) |
1124 { | 1119 { |
1125 | 1120 |
1126 CriticalSectionScoped lock(&_critSect); | 1121 rtc::CritScope lock(&_critSect); |
1127 | 1122 |
1128 if (_ptrDeviceOut == NULL) | 1123 if (_ptrDeviceOut == NULL) |
1129 { | 1124 { |
1130 return -1; | 1125 return -1; |
1131 } | 1126 } |
1132 | 1127 |
1133 HRESULT hr = S_OK; | 1128 HRESULT hr = S_OK; |
1134 IAudioEndpointVolume* pVolume = NULL; | 1129 IAudioEndpointVolume* pVolume = NULL; |
1135 | 1130 |
1136 // Query the speaker system mute state. | 1131 // Query the speaker system mute state. |
(...skipping 18 matching lines...) Expand all Loading... |
1155 return -1; | 1150 return -1; |
1156 } | 1151 } |
1157 | 1152 |
1158 // ---------------------------------------------------------------------------- | 1153 // ---------------------------------------------------------------------------- |
1159 // SetSpeakerMute | 1154 // SetSpeakerMute |
1160 // ---------------------------------------------------------------------------- | 1155 // ---------------------------------------------------------------------------- |
1161 | 1156 |
1162 int32_t AudioDeviceWindowsCore::SetSpeakerMute(bool enable) | 1157 int32_t AudioDeviceWindowsCore::SetSpeakerMute(bool enable) |
1163 { | 1158 { |
1164 | 1159 |
1165 CriticalSectionScoped lock(&_critSect); | 1160 rtc::CritScope lock(&_critSect); |
1166 | 1161 |
1167 if (!_speakerIsInitialized) | 1162 if (!_speakerIsInitialized) |
1168 { | 1163 { |
1169 return -1; | 1164 return -1; |
1170 } | 1165 } |
1171 | 1166 |
1172 if (_ptrDeviceOut == NULL) | 1167 if (_ptrDeviceOut == NULL) |
1173 { | 1168 { |
1174 return -1; | 1169 return -1; |
1175 } | 1170 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 return -1; | 1230 return -1; |
1236 } | 1231 } |
1237 | 1232 |
1238 // ---------------------------------------------------------------------------- | 1233 // ---------------------------------------------------------------------------- |
1239 // MicrophoneMuteIsAvailable | 1234 // MicrophoneMuteIsAvailable |
1240 // ---------------------------------------------------------------------------- | 1235 // ---------------------------------------------------------------------------- |
1241 | 1236 |
1242 int32_t AudioDeviceWindowsCore::MicrophoneMuteIsAvailable(bool& available) | 1237 int32_t AudioDeviceWindowsCore::MicrophoneMuteIsAvailable(bool& available) |
1243 { | 1238 { |
1244 | 1239 |
1245 CriticalSectionScoped lock(&_critSect); | 1240 rtc::CritScope lock(&_critSect); |
1246 | 1241 |
1247 if (_ptrDeviceIn == NULL) | 1242 if (_ptrDeviceIn == NULL) |
1248 { | 1243 { |
1249 return -1; | 1244 return -1; |
1250 } | 1245 } |
1251 | 1246 |
1252 HRESULT hr = S_OK; | 1247 HRESULT hr = S_OK; |
1253 IAudioEndpointVolume* pVolume = NULL; | 1248 IAudioEndpointVolume* pVolume = NULL; |
1254 | 1249 |
1255 // Query the microphone system mute state. | 1250 // Query the microphone system mute state. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 return 0; | 1390 return 0; |
1396 } | 1391 } |
1397 | 1392 |
1398 // ---------------------------------------------------------------------------- | 1393 // ---------------------------------------------------------------------------- |
1399 // SetStereoRecording | 1394 // SetStereoRecording |
1400 // ---------------------------------------------------------------------------- | 1395 // ---------------------------------------------------------------------------- |
1401 | 1396 |
1402 int32_t AudioDeviceWindowsCore::SetStereoRecording(bool enable) | 1397 int32_t AudioDeviceWindowsCore::SetStereoRecording(bool enable) |
1403 { | 1398 { |
1404 | 1399 |
1405 CriticalSectionScoped lock(&_critSect); | 1400 rtc::CritScope lock(&_critSect); |
1406 | 1401 |
1407 if (enable) | 1402 if (enable) |
1408 { | 1403 { |
1409 _recChannelsPrioList[0] = 2; // try stereo first | 1404 _recChannelsPrioList[0] = 2; // try stereo first |
1410 _recChannelsPrioList[1] = 1; | 1405 _recChannelsPrioList[1] = 1; |
1411 _recChannels = 2; | 1406 _recChannels = 2; |
1412 } | 1407 } |
1413 else | 1408 else |
1414 { | 1409 { |
1415 _recChannelsPrioList[0] = 1; // try mono first | 1410 _recChannelsPrioList[0] = 1; // try mono first |
(...skipping 30 matching lines...) Expand all Loading... |
1446 return 0; | 1441 return 0; |
1447 } | 1442 } |
1448 | 1443 |
1449 // ---------------------------------------------------------------------------- | 1444 // ---------------------------------------------------------------------------- |
1450 // SetStereoPlayout | 1445 // SetStereoPlayout |
1451 // ---------------------------------------------------------------------------- | 1446 // ---------------------------------------------------------------------------- |
1452 | 1447 |
1453 int32_t AudioDeviceWindowsCore::SetStereoPlayout(bool enable) | 1448 int32_t AudioDeviceWindowsCore::SetStereoPlayout(bool enable) |
1454 { | 1449 { |
1455 | 1450 |
1456 CriticalSectionScoped lock(&_critSect); | 1451 rtc::CritScope lock(&_critSect); |
1457 | 1452 |
1458 if (enable) | 1453 if (enable) |
1459 { | 1454 { |
1460 _playChannelsPrioList[0] = 2; // try stereo first | 1455 _playChannelsPrioList[0] = 2; // try stereo first |
1461 _playChannelsPrioList[1] = 1; | 1456 _playChannelsPrioList[1] = 1; |
1462 _playChannels = 2; | 1457 _playChannels = 2; |
1463 } | 1458 } |
1464 else | 1459 else |
1465 { | 1460 { |
1466 _playChannelsPrioList[0] = 1; // try mono first | 1461 _playChannelsPrioList[0] = 1; // try mono first |
(...skipping 18 matching lines...) Expand all Loading... |
1485 | 1480 |
1486 return 0; | 1481 return 0; |
1487 } | 1482 } |
1488 | 1483 |
1489 // ---------------------------------------------------------------------------- | 1484 // ---------------------------------------------------------------------------- |
1490 // SetAGC | 1485 // SetAGC |
1491 // ---------------------------------------------------------------------------- | 1486 // ---------------------------------------------------------------------------- |
1492 | 1487 |
1493 int32_t AudioDeviceWindowsCore::SetAGC(bool enable) | 1488 int32_t AudioDeviceWindowsCore::SetAGC(bool enable) |
1494 { | 1489 { |
1495 CriticalSectionScoped lock(&_critSect); | 1490 rtc::CritScope lock(&_critSect); |
1496 _AGC = enable; | 1491 _AGC = enable; |
1497 return 0; | 1492 return 0; |
1498 } | 1493 } |
1499 | 1494 |
1500 // ---------------------------------------------------------------------------- | 1495 // ---------------------------------------------------------------------------- |
1501 // AGC | 1496 // AGC |
1502 // ---------------------------------------------------------------------------- | 1497 // ---------------------------------------------------------------------------- |
1503 | 1498 |
1504 bool AudioDeviceWindowsCore::AGC() const | 1499 bool AudioDeviceWindowsCore::AGC() const |
1505 { | 1500 { |
1506 CriticalSectionScoped lock(&_critSect); | 1501 rtc::CritScope lock(&_critSect); |
1507 return _AGC; | 1502 return _AGC; |
1508 } | 1503 } |
1509 | 1504 |
1510 // ---------------------------------------------------------------------------- | 1505 // ---------------------------------------------------------------------------- |
1511 // MicrophoneVolumeIsAvailable | 1506 // MicrophoneVolumeIsAvailable |
1512 // ---------------------------------------------------------------------------- | 1507 // ---------------------------------------------------------------------------- |
1513 | 1508 |
1514 int32_t AudioDeviceWindowsCore::MicrophoneVolumeIsAvailable(bool& available) | 1509 int32_t AudioDeviceWindowsCore::MicrophoneVolumeIsAvailable(bool& available) |
1515 { | 1510 { |
1516 | 1511 |
1517 CriticalSectionScoped lock(&_critSect); | 1512 rtc::CritScope lock(&_critSect); |
1518 | 1513 |
1519 if (_ptrDeviceIn == NULL) | 1514 if (_ptrDeviceIn == NULL) |
1520 { | 1515 { |
1521 return -1; | 1516 return -1; |
1522 } | 1517 } |
1523 | 1518 |
1524 HRESULT hr = S_OK; | 1519 HRESULT hr = S_OK; |
1525 IAudioEndpointVolume* pVolume = NULL; | 1520 IAudioEndpointVolume* pVolume = NULL; |
1526 | 1521 |
1527 hr = _ptrDeviceIn->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL
, reinterpret_cast<void**>(&pVolume)); | 1522 hr = _ptrDeviceIn->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL
, reinterpret_cast<void**>(&pVolume)); |
(...skipping 18 matching lines...) Expand all Loading... |
1546 | 1541 |
1547 // ---------------------------------------------------------------------------- | 1542 // ---------------------------------------------------------------------------- |
1548 // SetMicrophoneVolume | 1543 // SetMicrophoneVolume |
1549 // ---------------------------------------------------------------------------- | 1544 // ---------------------------------------------------------------------------- |
1550 | 1545 |
1551 int32_t AudioDeviceWindowsCore::SetMicrophoneVolume(uint32_t volume) | 1546 int32_t AudioDeviceWindowsCore::SetMicrophoneVolume(uint32_t volume) |
1552 { | 1547 { |
1553 WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "AudioDeviceWindowsCore::
SetMicrophoneVolume(volume=%u)", volume); | 1548 WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "AudioDeviceWindowsCore::
SetMicrophoneVolume(volume=%u)", volume); |
1554 | 1549 |
1555 { | 1550 { |
1556 CriticalSectionScoped lock(&_critSect); | 1551 rtc::CritScope lock(&_critSect); |
1557 | 1552 |
1558 if (!_microphoneIsInitialized) | 1553 if (!_microphoneIsInitialized) |
1559 { | 1554 { |
1560 return -1; | 1555 return -1; |
1561 } | 1556 } |
1562 | 1557 |
1563 if (_ptrDeviceIn == NULL) | 1558 if (_ptrDeviceIn == NULL) |
1564 { | 1559 { |
1565 return -1; | 1560 return -1; |
1566 } | 1561 } |
(...skipping 20 matching lines...) Expand all Loading... |
1587 return -1; | 1582 return -1; |
1588 } | 1583 } |
1589 | 1584 |
1590 // ---------------------------------------------------------------------------- | 1585 // ---------------------------------------------------------------------------- |
1591 // MicrophoneVolume | 1586 // MicrophoneVolume |
1592 // ---------------------------------------------------------------------------- | 1587 // ---------------------------------------------------------------------------- |
1593 | 1588 |
1594 int32_t AudioDeviceWindowsCore::MicrophoneVolume(uint32_t& volume) const | 1589 int32_t AudioDeviceWindowsCore::MicrophoneVolume(uint32_t& volume) const |
1595 { | 1590 { |
1596 { | 1591 { |
1597 CriticalSectionScoped lock(&_critSect); | 1592 rtc::CritScope lock(&_critSect); |
1598 | 1593 |
1599 if (!_microphoneIsInitialized) | 1594 if (!_microphoneIsInitialized) |
1600 { | 1595 { |
1601 return -1; | 1596 return -1; |
1602 } | 1597 } |
1603 | 1598 |
1604 if (_ptrDeviceIn == NULL) | 1599 if (_ptrDeviceIn == NULL) |
1605 { | 1600 { |
1606 return -1; | 1601 return -1; |
1607 } | 1602 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 return 0; | 1677 return 0; |
1683 } | 1678 } |
1684 | 1679 |
1685 // ---------------------------------------------------------------------------- | 1680 // ---------------------------------------------------------------------------- |
1686 // PlayoutDevices | 1681 // PlayoutDevices |
1687 // ---------------------------------------------------------------------------- | 1682 // ---------------------------------------------------------------------------- |
1688 | 1683 |
1689 int16_t AudioDeviceWindowsCore::PlayoutDevices() | 1684 int16_t AudioDeviceWindowsCore::PlayoutDevices() |
1690 { | 1685 { |
1691 | 1686 |
1692 CriticalSectionScoped lock(&_critSect); | 1687 rtc::CritScope lock(&_critSect); |
1693 | 1688 |
1694 if (_RefreshDeviceList(eRender) != -1) | 1689 if (_RefreshDeviceList(eRender) != -1) |
1695 { | 1690 { |
1696 return (_DeviceListCount(eRender)); | 1691 return (_DeviceListCount(eRender)); |
1697 } | 1692 } |
1698 | 1693 |
1699 return -1; | 1694 return -1; |
1700 } | 1695 } |
1701 | 1696 |
1702 // ---------------------------------------------------------------------------- | 1697 // ---------------------------------------------------------------------------- |
(...skipping 10 matching lines...) Expand all Loading... |
1713 | 1708 |
1714 // Get current number of available rendering endpoint devices and refresh th
e rendering collection. | 1709 // Get current number of available rendering endpoint devices and refresh th
e rendering collection. |
1715 UINT nDevices = PlayoutDevices(); | 1710 UINT nDevices = PlayoutDevices(); |
1716 | 1711 |
1717 if (index < 0 || index > (nDevices-1)) | 1712 if (index < 0 || index > (nDevices-1)) |
1718 { | 1713 { |
1719 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "device index is out o
f range [0,%u]", (nDevices-1)); | 1714 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "device index is out o
f range [0,%u]", (nDevices-1)); |
1720 return -1; | 1715 return -1; |
1721 } | 1716 } |
1722 | 1717 |
1723 CriticalSectionScoped lock(&_critSect); | 1718 rtc::CritScope lock(&_critSect); |
1724 | 1719 |
1725 HRESULT hr(S_OK); | 1720 HRESULT hr(S_OK); |
1726 | 1721 |
1727 assert(_ptrRenderCollection != NULL); | 1722 assert(_ptrRenderCollection != NULL); |
1728 | 1723 |
1729 // Select an endpoint rendering device given the specified index | 1724 // Select an endpoint rendering device given the specified index |
1730 SAFE_RELEASE(_ptrDeviceOut); | 1725 SAFE_RELEASE(_ptrDeviceOut); |
1731 hr = _ptrRenderCollection->Item( | 1726 hr = _ptrRenderCollection->Item( |
1732 index, | 1727 index, |
1733 &_ptrDeviceOut); | 1728 &_ptrDeviceOut); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 | 1763 |
1769 if (device == AudioDeviceModule::kDefaultDevice) | 1764 if (device == AudioDeviceModule::kDefaultDevice) |
1770 { | 1765 { |
1771 role = eConsole; | 1766 role = eConsole; |
1772 } | 1767 } |
1773 else if (device == AudioDeviceModule::kDefaultCommunicationDevice) | 1768 else if (device == AudioDeviceModule::kDefaultCommunicationDevice) |
1774 { | 1769 { |
1775 role = eCommunications; | 1770 role = eCommunications; |
1776 } | 1771 } |
1777 | 1772 |
1778 CriticalSectionScoped lock(&_critSect); | 1773 rtc::CritScope lock(&_critSect); |
1779 | 1774 |
1780 // Refresh the list of rendering endpoint devices | 1775 // Refresh the list of rendering endpoint devices |
1781 _RefreshDeviceList(eRender); | 1776 _RefreshDeviceList(eRender); |
1782 | 1777 |
1783 HRESULT hr(S_OK); | 1778 HRESULT hr(S_OK); |
1784 | 1779 |
1785 assert(_ptrEnumerator != NULL); | 1780 assert(_ptrEnumerator != NULL); |
1786 | 1781 |
1787 // Select an endpoint rendering device given the specified role | 1782 // Select an endpoint rendering device given the specified role |
1788 SAFE_RELEASE(_ptrDeviceOut); | 1783 SAFE_RELEASE(_ptrDeviceOut); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 return -1; | 1833 return -1; |
1839 } | 1834 } |
1840 | 1835 |
1841 memset(name, 0, kAdmMaxDeviceNameSize); | 1836 memset(name, 0, kAdmMaxDeviceNameSize); |
1842 | 1837 |
1843 if (guid != NULL) | 1838 if (guid != NULL) |
1844 { | 1839 { |
1845 memset(guid, 0, kAdmMaxGuidSize); | 1840 memset(guid, 0, kAdmMaxGuidSize); |
1846 } | 1841 } |
1847 | 1842 |
1848 CriticalSectionScoped lock(&_critSect); | 1843 rtc::CritScope lock(&_critSect); |
1849 | 1844 |
1850 int32_t ret(-1); | 1845 int32_t ret(-1); |
1851 WCHAR szDeviceName[MAX_PATH]; | 1846 WCHAR szDeviceName[MAX_PATH]; |
1852 const int bufferLen = sizeof(szDeviceName)/sizeof(szDeviceName)[0]; | 1847 const int bufferLen = sizeof(szDeviceName)/sizeof(szDeviceName)[0]; |
1853 | 1848 |
1854 // Get the endpoint device's friendly-name | 1849 // Get the endpoint device's friendly-name |
1855 if (defaultCommunicationDevice) | 1850 if (defaultCommunicationDevice) |
1856 { | 1851 { |
1857 ret = _GetDefaultDeviceName(eRender, eCommunications, szDeviceName, buff
erLen); | 1852 ret = _GetDefaultDeviceName(eRender, eCommunications, szDeviceName, buff
erLen); |
1858 } | 1853 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 return -1; | 1913 return -1; |
1919 } | 1914 } |
1920 | 1915 |
1921 memset(name, 0, kAdmMaxDeviceNameSize); | 1916 memset(name, 0, kAdmMaxDeviceNameSize); |
1922 | 1917 |
1923 if (guid != NULL) | 1918 if (guid != NULL) |
1924 { | 1919 { |
1925 memset(guid, 0, kAdmMaxGuidSize); | 1920 memset(guid, 0, kAdmMaxGuidSize); |
1926 } | 1921 } |
1927 | 1922 |
1928 CriticalSectionScoped lock(&_critSect); | 1923 rtc::CritScope lock(&_critSect); |
1929 | 1924 |
1930 int32_t ret(-1); | 1925 int32_t ret(-1); |
1931 WCHAR szDeviceName[MAX_PATH]; | 1926 WCHAR szDeviceName[MAX_PATH]; |
1932 const int bufferLen = sizeof(szDeviceName)/sizeof(szDeviceName)[0]; | 1927 const int bufferLen = sizeof(szDeviceName)/sizeof(szDeviceName)[0]; |
1933 | 1928 |
1934 // Get the endpoint device's friendly-name | 1929 // Get the endpoint device's friendly-name |
1935 if (defaultCommunicationDevice) | 1930 if (defaultCommunicationDevice) |
1936 { | 1931 { |
1937 ret = _GetDefaultDeviceName(eCapture, eCommunications, szDeviceName, buf
ferLen); | 1932 ret = _GetDefaultDeviceName(eCapture, eCommunications, szDeviceName, buf
ferLen); |
1938 } | 1933 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 return ret; | 1967 return ret; |
1973 } | 1968 } |
1974 | 1969 |
1975 // ---------------------------------------------------------------------------- | 1970 // ---------------------------------------------------------------------------- |
1976 // RecordingDevices | 1971 // RecordingDevices |
1977 // ---------------------------------------------------------------------------- | 1972 // ---------------------------------------------------------------------------- |
1978 | 1973 |
1979 int16_t AudioDeviceWindowsCore::RecordingDevices() | 1974 int16_t AudioDeviceWindowsCore::RecordingDevices() |
1980 { | 1975 { |
1981 | 1976 |
1982 CriticalSectionScoped lock(&_critSect); | 1977 rtc::CritScope lock(&_critSect); |
1983 | 1978 |
1984 if (_RefreshDeviceList(eCapture) != -1) | 1979 if (_RefreshDeviceList(eCapture) != -1) |
1985 { | 1980 { |
1986 return (_DeviceListCount(eCapture)); | 1981 return (_DeviceListCount(eCapture)); |
1987 } | 1982 } |
1988 | 1983 |
1989 return -1; | 1984 return -1; |
1990 } | 1985 } |
1991 | 1986 |
1992 // ---------------------------------------------------------------------------- | 1987 // ---------------------------------------------------------------------------- |
(...skipping 10 matching lines...) Expand all Loading... |
2003 | 1998 |
2004 // Get current number of available capture endpoint devices and refresh the
capture collection. | 1999 // Get current number of available capture endpoint devices and refresh the
capture collection. |
2005 UINT nDevices = RecordingDevices(); | 2000 UINT nDevices = RecordingDevices(); |
2006 | 2001 |
2007 if (index < 0 || index > (nDevices-1)) | 2002 if (index < 0 || index > (nDevices-1)) |
2008 { | 2003 { |
2009 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "device index is out o
f range [0,%u]", (nDevices-1)); | 2004 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "device index is out o
f range [0,%u]", (nDevices-1)); |
2010 return -1; | 2005 return -1; |
2011 } | 2006 } |
2012 | 2007 |
2013 CriticalSectionScoped lock(&_critSect); | 2008 rtc::CritScope lock(&_critSect); |
2014 | 2009 |
2015 HRESULT hr(S_OK); | 2010 HRESULT hr(S_OK); |
2016 | 2011 |
2017 assert(_ptrCaptureCollection != NULL); | 2012 assert(_ptrCaptureCollection != NULL); |
2018 | 2013 |
2019 // Select an endpoint capture device given the specified index | 2014 // Select an endpoint capture device given the specified index |
2020 SAFE_RELEASE(_ptrDeviceIn); | 2015 SAFE_RELEASE(_ptrDeviceIn); |
2021 hr = _ptrCaptureCollection->Item( | 2016 hr = _ptrCaptureCollection->Item( |
2022 index, | 2017 index, |
2023 &_ptrDeviceIn); | 2018 &_ptrDeviceIn); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 | 2053 |
2059 if (device == AudioDeviceModule::kDefaultDevice) | 2054 if (device == AudioDeviceModule::kDefaultDevice) |
2060 { | 2055 { |
2061 role = eConsole; | 2056 role = eConsole; |
2062 } | 2057 } |
2063 else if (device == AudioDeviceModule::kDefaultCommunicationDevice) | 2058 else if (device == AudioDeviceModule::kDefaultCommunicationDevice) |
2064 { | 2059 { |
2065 role = eCommunications; | 2060 role = eCommunications; |
2066 } | 2061 } |
2067 | 2062 |
2068 CriticalSectionScoped lock(&_critSect); | 2063 rtc::CritScope lock(&_critSect); |
2069 | 2064 |
2070 // Refresh the list of capture endpoint devices | 2065 // Refresh the list of capture endpoint devices |
2071 _RefreshDeviceList(eCapture); | 2066 _RefreshDeviceList(eCapture); |
2072 | 2067 |
2073 HRESULT hr(S_OK); | 2068 HRESULT hr(S_OK); |
2074 | 2069 |
2075 assert(_ptrEnumerator != NULL); | 2070 assert(_ptrEnumerator != NULL); |
2076 | 2071 |
2077 // Select an endpoint capture device given the specified role | 2072 // Select an endpoint capture device given the specified role |
2078 SAFE_RELEASE(_ptrDeviceIn); | 2073 SAFE_RELEASE(_ptrDeviceIn); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2148 return 0; | 2143 return 0; |
2149 } | 2144 } |
2150 | 2145 |
2151 // ---------------------------------------------------------------------------- | 2146 // ---------------------------------------------------------------------------- |
2152 // InitPlayout | 2147 // InitPlayout |
2153 // ---------------------------------------------------------------------------- | 2148 // ---------------------------------------------------------------------------- |
2154 | 2149 |
2155 int32_t AudioDeviceWindowsCore::InitPlayout() | 2150 int32_t AudioDeviceWindowsCore::InitPlayout() |
2156 { | 2151 { |
2157 | 2152 |
2158 CriticalSectionScoped lock(&_critSect); | 2153 rtc::CritScope lock(&_critSect); |
2159 | 2154 |
2160 if (_playing) | 2155 if (_playing) |
2161 { | 2156 { |
2162 return -1; | 2157 return -1; |
2163 } | 2158 } |
2164 | 2159 |
2165 if (_playIsInitialized) | 2160 if (_playIsInitialized) |
2166 { | 2161 { |
2167 return 0; | 2162 return 0; |
2168 } | 2163 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 return 0; | 2483 return 0; |
2489 } | 2484 } |
2490 | 2485 |
2491 // ---------------------------------------------------------------------------- | 2486 // ---------------------------------------------------------------------------- |
2492 // InitRecording | 2487 // InitRecording |
2493 // ---------------------------------------------------------------------------- | 2488 // ---------------------------------------------------------------------------- |
2494 | 2489 |
2495 int32_t AudioDeviceWindowsCore::InitRecording() | 2490 int32_t AudioDeviceWindowsCore::InitRecording() |
2496 { | 2491 { |
2497 | 2492 |
2498 CriticalSectionScoped lock(&_critSect); | 2493 rtc::CritScope lock(&_critSect); |
2499 | 2494 |
2500 if (_recording) | 2495 if (_recording) |
2501 { | 2496 { |
2502 return -1; | 2497 return -1; |
2503 } | 2498 } |
2504 | 2499 |
2505 if (_recIsInitialized) | 2500 if (_recIsInitialized) |
2506 { | 2501 { |
2507 return 0; | 2502 return 0; |
2508 } | 2503 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 { | 2734 { |
2740 return 0; | 2735 return 0; |
2741 } | 2736 } |
2742 | 2737 |
2743 if (_recording) | 2738 if (_recording) |
2744 { | 2739 { |
2745 return 0; | 2740 return 0; |
2746 } | 2741 } |
2747 | 2742 |
2748 { | 2743 { |
2749 CriticalSectionScoped critScoped(&_critSect); | 2744 rtc::CritScope critScoped(&_critSect); |
2750 | 2745 |
2751 // Create thread which will drive the capturing | 2746 // Create thread which will drive the capturing |
2752 LPTHREAD_START_ROUTINE lpStartAddress = WSAPICaptureThread; | 2747 LPTHREAD_START_ROUTINE lpStartAddress = WSAPICaptureThread; |
2753 if (_builtInAecEnabled) | 2748 if (_builtInAecEnabled) |
2754 { | 2749 { |
2755 // Redirect to the DMO polling method. | 2750 // Redirect to the DMO polling method. |
2756 lpStartAddress = WSAPICaptureThreadPollDMO; | 2751 lpStartAddress = WSAPICaptureThreadPollDMO; |
2757 | 2752 |
2758 if (!_playing) | 2753 if (!_playing) |
2759 { | 2754 { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2989 { | 2984 { |
2990 return 0; | 2985 return 0; |
2991 } | 2986 } |
2992 | 2987 |
2993 if (_playing) | 2988 if (_playing) |
2994 { | 2989 { |
2995 return 0; | 2990 return 0; |
2996 } | 2991 } |
2997 | 2992 |
2998 { | 2993 { |
2999 CriticalSectionScoped critScoped(&_critSect); | 2994 rtc::CritScope critScoped(&_critSect); |
3000 | 2995 |
3001 // Create thread which will drive the rendering. | 2996 // Create thread which will drive the rendering. |
3002 assert(_hPlayThread == NULL); | 2997 assert(_hPlayThread == NULL); |
3003 _hPlayThread = CreateThread( | 2998 _hPlayThread = CreateThread( |
3004 NULL, | 2999 NULL, |
3005 0, | 3000 0, |
3006 WSAPIRenderThread, | 3001 WSAPIRenderThread, |
3007 this, | 3002 this, |
3008 0, | 3003 0, |
3009 NULL); | 3004 NULL); |
(...skipping 29 matching lines...) Expand all Loading... |
3039 | 3034 |
3040 int32_t AudioDeviceWindowsCore::StopPlayout() | 3035 int32_t AudioDeviceWindowsCore::StopPlayout() |
3041 { | 3036 { |
3042 | 3037 |
3043 if (!_playIsInitialized) | 3038 if (!_playIsInitialized) |
3044 { | 3039 { |
3045 return 0; | 3040 return 0; |
3046 } | 3041 } |
3047 | 3042 |
3048 { | 3043 { |
3049 CriticalSectionScoped critScoped(&_critSect) ; | 3044 rtc::CritScope critScoped(&_critSect) ; |
3050 | 3045 |
3051 if (_hPlayThread == NULL) | 3046 if (_hPlayThread == NULL) |
3052 { | 3047 { |
3053 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 3048 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
3054 "no rendering stream is active => close down WASAPI only"); | 3049 "no rendering stream is active => close down WASAPI only"); |
3055 SAFE_RELEASE(_ptrClientOut); | 3050 SAFE_RELEASE(_ptrClientOut); |
3056 SAFE_RELEASE(_ptrRenderClient); | 3051 SAFE_RELEASE(_ptrRenderClient); |
3057 _playIsInitialized = false; | 3052 _playIsInitialized = false; |
3058 _playing = false; | 3053 _playing = false; |
3059 return 0; | 3054 return 0; |
(...skipping 12 matching lines...) Expand all Loading... |
3072 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 3067 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
3073 "failed to close down webrtc_core_audio_render_thread"); | 3068 "failed to close down webrtc_core_audio_render_thread"); |
3074 CloseHandle(_hPlayThread); | 3069 CloseHandle(_hPlayThread); |
3075 _hPlayThread = NULL; | 3070 _hPlayThread = NULL; |
3076 _playIsInitialized = false; | 3071 _playIsInitialized = false; |
3077 _playing = false; | 3072 _playing = false; |
3078 return -1; | 3073 return -1; |
3079 } | 3074 } |
3080 | 3075 |
3081 { | 3076 { |
3082 CriticalSectionScoped critScoped(&_critSect); | 3077 rtc::CritScope critScoped(&_critSect); |
3083 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 3078 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
3084 "webrtc_core_audio_render_thread is now closed"); | 3079 "webrtc_core_audio_render_thread is now closed"); |
3085 | 3080 |
3086 // to reset this event manually at each time we finish with it, | 3081 // to reset this event manually at each time we finish with it, |
3087 // in case that the render thread has exited before StopPlayout(), | 3082 // in case that the render thread has exited before StopPlayout(), |
3088 // this event might be caught by the new render thread within same VoE i
nstance. | 3083 // this event might be caught by the new render thread within same VoE i
nstance. |
3089 ResetEvent(_hShutdownRenderEvent); | 3084 ResetEvent(_hShutdownRenderEvent); |
3090 | 3085 |
3091 SAFE_RELEASE(_ptrClientOut); | 3086 SAFE_RELEASE(_ptrClientOut); |
3092 SAFE_RELEASE(_ptrRenderClient); | 3087 SAFE_RELEASE(_ptrRenderClient); |
(...skipping 23 matching lines...) Expand all Loading... |
3116 | 3111 |
3117 return 0; | 3112 return 0; |
3118 } | 3113 } |
3119 | 3114 |
3120 // ---------------------------------------------------------------------------- | 3115 // ---------------------------------------------------------------------------- |
3121 // PlayoutDelay | 3116 // PlayoutDelay |
3122 // ---------------------------------------------------------------------------- | 3117 // ---------------------------------------------------------------------------- |
3123 | 3118 |
3124 int32_t AudioDeviceWindowsCore::PlayoutDelay(uint16_t& delayMS) const | 3119 int32_t AudioDeviceWindowsCore::PlayoutDelay(uint16_t& delayMS) const |
3125 { | 3120 { |
3126 CriticalSectionScoped critScoped(&_critSect); | 3121 rtc::CritScope critScoped(&_critSect); |
3127 delayMS = static_cast<uint16_t>(_sndCardPlayDelay); | 3122 delayMS = static_cast<uint16_t>(_sndCardPlayDelay); |
3128 return 0; | 3123 return 0; |
3129 } | 3124 } |
3130 | 3125 |
3131 // ---------------------------------------------------------------------------- | 3126 // ---------------------------------------------------------------------------- |
3132 // RecordingDelay | 3127 // RecordingDelay |
3133 // ---------------------------------------------------------------------------- | 3128 // ---------------------------------------------------------------------------- |
3134 | 3129 |
3135 int32_t AudioDeviceWindowsCore::RecordingDelay(uint16_t& delayMS) const | 3130 int32_t AudioDeviceWindowsCore::RecordingDelay(uint16_t& delayMS) const |
3136 { | 3131 { |
3137 CriticalSectionScoped critScoped(&_critSect); | 3132 rtc::CritScope critScoped(&_critSect); |
3138 delayMS = static_cast<uint16_t>(_sndCardRecDelay); | 3133 delayMS = static_cast<uint16_t>(_sndCardRecDelay); |
3139 return 0; | 3134 return 0; |
3140 } | 3135 } |
3141 | 3136 |
3142 // ---------------------------------------------------------------------------- | 3137 // ---------------------------------------------------------------------------- |
3143 // Playing | 3138 // Playing |
3144 // ---------------------------------------------------------------------------- | 3139 // ---------------------------------------------------------------------------- |
3145 | 3140 |
3146 bool AudioDeviceWindowsCore::Playing() const | 3141 bool AudioDeviceWindowsCore::Playing() const |
3147 { | 3142 { |
3148 return (_playing); | 3143 return (_playing); |
3149 } | 3144 } |
3150 // ---------------------------------------------------------------------------- | 3145 // ---------------------------------------------------------------------------- |
3151 // SetPlayoutBuffer | 3146 // SetPlayoutBuffer |
3152 // ---------------------------------------------------------------------------- | 3147 // ---------------------------------------------------------------------------- |
3153 | 3148 |
3154 int32_t AudioDeviceWindowsCore::SetPlayoutBuffer(const AudioDeviceModule::Buffer
Type type, uint16_t sizeMS) | 3149 int32_t AudioDeviceWindowsCore::SetPlayoutBuffer(const AudioDeviceModule::Buffer
Type type, uint16_t sizeMS) |
3155 { | 3150 { |
3156 | 3151 |
3157 CriticalSectionScoped lock(&_critSect); | 3152 rtc::CritScope lock(&_critSect); |
3158 | 3153 |
3159 _playBufType = type; | 3154 _playBufType = type; |
3160 | 3155 |
3161 if (type == AudioDeviceModule::kFixedBufferSize) | 3156 if (type == AudioDeviceModule::kFixedBufferSize) |
3162 { | 3157 { |
3163 _playBufDelayFixed = sizeMS; | 3158 _playBufDelayFixed = sizeMS; |
3164 } | 3159 } |
3165 | 3160 |
3166 return 0; | 3161 return 0; |
3167 } | 3162 } |
3168 | 3163 |
3169 // ---------------------------------------------------------------------------- | 3164 // ---------------------------------------------------------------------------- |
3170 // PlayoutBuffer | 3165 // PlayoutBuffer |
3171 // ---------------------------------------------------------------------------- | 3166 // ---------------------------------------------------------------------------- |
3172 | 3167 |
3173 int32_t AudioDeviceWindowsCore::PlayoutBuffer(AudioDeviceModule::BufferType& typ
e, uint16_t& sizeMS) const | 3168 int32_t AudioDeviceWindowsCore::PlayoutBuffer(AudioDeviceModule::BufferType& typ
e, uint16_t& sizeMS) const |
3174 { | 3169 { |
3175 CriticalSectionScoped lock(&_critSect); | 3170 rtc::CritScope lock(&_critSect); |
3176 type = _playBufType; | 3171 type = _playBufType; |
3177 | 3172 |
3178 if (type == AudioDeviceModule::kFixedBufferSize) | 3173 if (type == AudioDeviceModule::kFixedBufferSize) |
3179 { | 3174 { |
3180 sizeMS = _playBufDelayFixed; | 3175 sizeMS = _playBufDelayFixed; |
3181 } | 3176 } |
3182 else | 3177 else |
3183 { | 3178 { |
3184 // Use same value as for PlayoutDelay | 3179 // Use same value as for PlayoutDelay |
3185 sizeMS = static_cast<uint16_t>(_sndCardPlayDelay); | 3180 sizeMS = static_cast<uint16_t>(_sndCardPlayDelay); |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3766 default: // unexpected error | 3761 default: // unexpected error |
3767 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, | 3762 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
3768 "Unknown wait termination on capture side"); | 3763 "Unknown wait termination on capture side"); |
3769 hr = -1; // To signal an error callback. | 3764 hr = -1; // To signal an error callback. |
3770 keepRecording = false; | 3765 keepRecording = false; |
3771 break; | 3766 break; |
3772 } | 3767 } |
3773 | 3768 |
3774 while (keepRecording) | 3769 while (keepRecording) |
3775 { | 3770 { |
3776 CriticalSectionScoped critScoped(&_critSect); | 3771 rtc::CritScope critScoped(&_critSect); |
3777 | 3772 |
3778 DWORD dwStatus = 0; | 3773 DWORD dwStatus = 0; |
3779 { | 3774 { |
3780 DMO_OUTPUT_DATA_BUFFER dmoBuffer = {0}; | 3775 DMO_OUTPUT_DATA_BUFFER dmoBuffer = {0}; |
3781 dmoBuffer.pBuffer = _mediaBuffer; | 3776 dmoBuffer.pBuffer = _mediaBuffer; |
3782 dmoBuffer.pBuffer->AddRef(); | 3777 dmoBuffer.pBuffer->AddRef(); |
3783 | 3778 |
3784 // Poll the DMO for AEC processed capture data. The DMO will | 3779 // Poll the DMO for AEC processed capture data. The DMO will |
3785 // copy available data to |dmoBuffer|, and should only return | 3780 // copy available data to |dmoBuffer|, and should only return |
3786 // 10 ms frames. The value of |dwStatus| should be ignored. | 3781 // 10 ms frames. The value of |dwStatus| should be ignored. |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5109 int key_down = 0; | 5104 int key_down = 0; |
5110 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) { | 5105 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) { |
5111 short res = GetAsyncKeyState(key); | 5106 short res = GetAsyncKeyState(key); |
5112 key_down |= res & 0x1; // Get the LSB | 5107 key_down |= res & 0x1; // Get the LSB |
5113 } | 5108 } |
5114 return (key_down > 0); | 5109 return (key_down > 0); |
5115 } | 5110 } |
5116 } // namespace webrtc | 5111 } // namespace webrtc |
5117 | 5112 |
5118 #endif // WEBRTC_WINDOWS_CORE_AUDIO_BUILD | 5113 #endif // WEBRTC_WINDOWS_CORE_AUDIO_BUILD |
OLD | NEW |