| 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 13 matching lines...) Expand all Loading... |
| 24 #ifndef WAVE_MAPPED_kDefaultCommunicationDevice | 24 #ifndef WAVE_MAPPED_kDefaultCommunicationDevice |
| 25 #define WAVE_MAPPED_kDefaultCommunicationDevice 0x0010 | 25 #define WAVE_MAPPED_kDefaultCommunicationDevice 0x0010 |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace webrtc { | 28 namespace webrtc { |
| 29 | 29 |
| 30 // ============================================================================ | 30 // ============================================================================ |
| 31 // CONSTRUCTION/DESTRUCTION | 31 // CONSTRUCTION/DESTRUCTION |
| 32 // ============================================================================ | 32 // ============================================================================ |
| 33 | 33 |
| 34 AudioMixerManager::AudioMixerManager(const int32_t id) : | 34 AudioMixerManager::AudioMixerManager(const int32_t id) |
| 35 _critSect(*CriticalSectionWrapper::CreateCriticalSection()), | 35 : _critSect(*CriticalSectionWrapper::CreateCriticalSection()), |
| 36 _id(id), | 36 _id(id), |
| 37 _inputMixerHandle(NULL), | 37 _inputMixerHandle(nullptr), |
| 38 _outputMixerHandle(NULL) | 38 _outputMixerHandle(nullptr) { |
| 39 { | 39 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s constructed", |
| 40 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s constructed", __FUNCT
ION__); | 40 __FUNCTION__); |
| 41 ClearSpeakerState(); | 41 ClearSpeakerState(); |
| 42 ClearMicrophoneState(); | 42 ClearMicrophoneState(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 AudioMixerManager::~AudioMixerManager() | 45 AudioMixerManager::~AudioMixerManager() |
| 46 { | 46 { |
| 47 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s destructed", __FUNCTI
ON__); | 47 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s destructed", __FUNCTI
ON__); |
| 48 | 48 |
| 49 Close(); | 49 Close(); |
| 50 | 50 |
| 51 delete &_critSect; | 51 delete &_critSect; |
| 52 } | 52 } |
| 53 | 53 |
| 54 // ============================================================================ | 54 // ============================================================================ |
| 55 // PUBLIC METHODS | 55 // PUBLIC METHODS |
| 56 // ============================================================================ | 56 // ============================================================================ |
| 57 | 57 |
| 58 // ---------------------------------------------------------------------------- | 58 // ---------------------------------------------------------------------------- |
| 59 // Close | 59 // Close |
| 60 // ---------------------------------------------------------------------------- | 60 // ---------------------------------------------------------------------------- |
| 61 | 61 |
| 62 int32_t AudioMixerManager::Close() | 62 int32_t AudioMixerManager::Close() |
| 63 { | 63 { |
| 64 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); | 64 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); |
| 65 | 65 |
| 66 CriticalSectionScoped lock(&_critSect); | 66 CriticalSectionScoped lock(&_critSect); |
| 67 | 67 |
| 68 if (_outputMixerHandle != NULL) | 68 if (_outputMixerHandle != nullptr) { |
| 69 { | 69 mixerClose(_outputMixerHandle); |
| 70 mixerClose(_outputMixerHandle); | 70 _outputMixerHandle = nullptr; |
| 71 _outputMixerHandle = NULL; | |
| 72 } | 71 } |
| 73 if (_inputMixerHandle != NULL) | 72 if (_inputMixerHandle != nullptr) { |
| 74 { | 73 mixerClose(_inputMixerHandle); |
| 75 mixerClose(_inputMixerHandle); | 74 _inputMixerHandle = nullptr; |
| 76 _inputMixerHandle = NULL; | |
| 77 } | 75 } |
| 78 return 0; | 76 return 0; |
| 79 | 77 |
| 80 } | 78 } |
| 81 | 79 |
| 82 // ---------------------------------------------------------------------------- | 80 // ---------------------------------------------------------------------------- |
| 83 // CloseSpeaker | 81 // CloseSpeaker |
| 84 // ---------------------------------------------------------------------------- | 82 // ---------------------------------------------------------------------------- |
| 85 | 83 |
| 86 int32_t AudioMixerManager::CloseSpeaker() | 84 int32_t AudioMixerManager::CloseSpeaker() |
| 87 { | 85 { |
| 88 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); | 86 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); |
| 89 | 87 |
| 90 CriticalSectionScoped lock(&_critSect); | 88 CriticalSectionScoped lock(&_critSect); |
| 91 | 89 |
| 92 if (_outputMixerHandle == NULL) | 90 if (_outputMixerHandle == nullptr) { |
| 93 { | 91 return -1; |
| 94 return -1; | |
| 95 } | 92 } |
| 96 | 93 |
| 97 ClearSpeakerState(_outputMixerID); | 94 ClearSpeakerState(_outputMixerID); |
| 98 | 95 |
| 99 mixerClose(_outputMixerHandle); | 96 mixerClose(_outputMixerHandle); |
| 100 _outputMixerHandle = NULL; | 97 _outputMixerHandle = nullptr; |
| 101 | 98 |
| 102 return 0; | 99 return 0; |
| 103 } | 100 } |
| 104 | 101 |
| 105 // ---------------------------------------------------------------------------- | 102 // ---------------------------------------------------------------------------- |
| 106 // CloseMicrophone | 103 // CloseMicrophone |
| 107 // ---------------------------------------------------------------------------- | 104 // ---------------------------------------------------------------------------- |
| 108 | 105 |
| 109 int32_t AudioMixerManager::CloseMicrophone() | 106 int32_t AudioMixerManager::CloseMicrophone() |
| 110 { | 107 { |
| 111 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); | 108 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); |
| 112 | 109 |
| 113 CriticalSectionScoped lock(&_critSect); | 110 CriticalSectionScoped lock(&_critSect); |
| 114 | 111 |
| 115 if (_inputMixerHandle == NULL) | 112 if (_inputMixerHandle == nullptr) { |
| 116 { | 113 return -1; |
| 117 return -1; | |
| 118 } | 114 } |
| 119 | 115 |
| 120 ClearMicrophoneState(_inputMixerID); | 116 ClearMicrophoneState(_inputMixerID); |
| 121 | 117 |
| 122 mixerClose(_inputMixerHandle); | 118 mixerClose(_inputMixerHandle); |
| 123 _inputMixerHandle = NULL; | 119 _inputMixerHandle = nullptr; |
| 124 | 120 |
| 125 return 0; | 121 return 0; |
| 126 } | 122 } |
| 127 | 123 |
| 128 // ---------------------------------------------------------------------------- | 124 // ---------------------------------------------------------------------------- |
| 129 // EnumerateAll | 125 // EnumerateAll |
| 130 // ---------------------------------------------------------------------------- | 126 // ---------------------------------------------------------------------------- |
| 131 | 127 |
| 132 int32_t AudioMixerManager::EnumerateAll() | 128 int32_t AudioMixerManager::EnumerateAll() |
| 133 { | 129 { |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 } | 573 } |
| 578 else if (device == AudioDeviceModule::kDefaultCommunicationDevice) | 574 else if (device == AudioDeviceModule::kDefaultCommunicationDevice) |
| 579 { | 575 { |
| 580 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::Ope
nSpeaker(kDefaultCommunicationDevice)"); | 576 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::Ope
nSpeaker(kDefaultCommunicationDevice)"); |
| 581 } | 577 } |
| 582 | 578 |
| 583 CriticalSectionScoped lock(&_critSect); | 579 CriticalSectionScoped lock(&_critSect); |
| 584 | 580 |
| 585 // Close any existing output mixer handle | 581 // Close any existing output mixer handle |
| 586 // | 582 // |
| 587 if (_outputMixerHandle != NULL) | 583 if (_outputMixerHandle != nullptr) { |
| 588 { | 584 mixerClose(_outputMixerHandle); |
| 589 mixerClose(_outputMixerHandle); | 585 _outputMixerHandle = nullptr; |
| 590 _outputMixerHandle = NULL; | |
| 591 } | 586 } |
| 592 | 587 |
| 593 MMRESULT res = MMSYSERR_NOERROR; | 588 MMRESULT res = MMSYSERR_NOERROR; |
| 594 WAVEFORMATEX waveFormat; | 589 WAVEFORMATEX waveFormat; |
| 595 HWAVEOUT hWaveOut(NULL); | 590 HWAVEOUT hWaveOut(nullptr); |
| 596 | 591 |
| 597 waveFormat.wFormatTag = WAVE_FORMAT_PCM ; | 592 waveFormat.wFormatTag = WAVE_FORMAT_PCM ; |
| 598 waveFormat.nChannels = 2; | 593 waveFormat.nChannels = 2; |
| 599 waveFormat.nSamplesPerSec = 48000; | 594 waveFormat.nSamplesPerSec = 48000; |
| 600 waveFormat.wBitsPerSample = 16; | 595 waveFormat.wBitsPerSample = 16; |
| 601 waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSampl
e / 8; | 596 waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSampl
e / 8; |
| 602 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl
ign; | 597 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl
ign; |
| 603 waveFormat.cbSize = 0; | 598 waveFormat.cbSize = 0; |
| 604 | 599 |
| 605 // We need a waveform-audio output handle for the currently selected output
device. | 600 // We need a waveform-audio output handle for the currently selected output
device. |
| 606 // This handle will then give us the corresponding mixer identifier. Once th
e mixer | 601 // This handle will then give us the corresponding mixer identifier. Once th
e mixer |
| 607 // ID is known, it is possible to open the output mixer. | 602 // ID is known, it is possible to open the output mixer. |
| 608 // | 603 // |
| 609 if (device == AudioDeviceModule::kDefaultCommunicationDevice) | 604 if (device == AudioDeviceModule::kDefaultCommunicationDevice) |
| 610 { | 605 { |
| 611 // check if it is possible to open the default communication device (sup
ported on Windows 7) | 606 // check if it is possible to open the default communication device (sup
ported on Windows 7) |
| 612 res = waveOutOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | | 607 res = waveOutOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0, |
| 613 WAVE_MAPPED_kDefaultCommunicationDevice | WAVE_FORMAT_QUERY); | 608 CALLBACK_NULL | |
| 609 WAVE_MAPPED_kDefaultCommunicationDevice | |
| 610 WAVE_FORMAT_QUERY); |
| 614 if (MMSYSERR_NOERROR == res) | 611 if (MMSYSERR_NOERROR == res) |
| 615 { | 612 { |
| 616 // if so, open the default communication device for real | 613 // if so, open the default communication device for real |
| 617 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CALLBAC
K_NULL | WAVE_MAPPED_kDefaultCommunicationDevice); | 614 res = waveOutOpen( |
| 615 &hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, |
| 616 CALLBACK_NULL | WAVE_MAPPED_kDefaultCommunicationDevice); |
| 618 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default co
mmunication device"); | 617 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default co
mmunication device"); |
| 619 } | 618 } |
| 620 else | 619 else |
| 621 { | 620 { |
| 622 // use default device since default communication device was not ava
liable | 621 // use default device since default communication device was not ava
liable |
| 623 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CALLBAC
K_NULL); | 622 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, |
| 623 CALLBACK_NULL); |
| 624 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 624 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
| 625 "unable to open default communication device => using default in
stead"); | 625 "unable to open default communication device => using default in
stead"); |
| 626 } | 626 } |
| 627 } | 627 } |
| 628 else if (device == AudioDeviceModule::kDefaultDevice) | 628 else if (device == AudioDeviceModule::kDefaultDevice) |
| 629 { | 629 { |
| 630 // open default device since it has been requested | 630 // open default device since it has been requested |
| 631 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NU
LL); | 631 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, |
| 632 CALLBACK_NULL); |
| 632 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default output
device"); | 633 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default output
device"); |
| 633 } | 634 } |
| 634 | 635 |
| 635 if (MMSYSERR_NOERROR != res) | 636 if (MMSYSERR_NOERROR != res) |
| 636 { | 637 { |
| 637 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutOpen() faile
d (err=%d)", res); | 638 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutOpen() faile
d (err=%d)", res); |
| 638 TraceWaveOutError(res); | 639 TraceWaveOutError(res); |
| 639 } | 640 } |
| 640 | 641 |
| 641 UINT mixerId(0); | 642 UINT mixerId(0); |
| 642 HMIXER hMixer(NULL); | 643 HMIXER hMixer(nullptr); |
| 643 | 644 |
| 644 // Retrieve the device identifier for a mixer device associated with the | 645 // Retrieve the device identifier for a mixer device associated with the |
| 645 // aquired waveform-audio output handle. | 646 // aquired waveform-audio output handle. |
| 646 // | 647 // |
| 647 res = mixerGetID((HMIXEROBJ)hWaveOut, &mixerId, MIXER_OBJECTF_HWAVEOUT); | 648 res = mixerGetID((HMIXEROBJ)hWaveOut, &mixerId, MIXER_OBJECTF_HWAVEOUT); |
| 648 if (MMSYSERR_NOERROR != res) | 649 if (MMSYSERR_NOERROR != res) |
| 649 { | 650 { |
| 650 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerGetID(MIXER_OB
JECTF_HWAVEOUT) failed (err=%d)", res); | 651 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerGetID(MIXER_OB
JECTF_HWAVEOUT) failed (err=%d)", res); |
| 651 // identification failed => use default mixer identifier (=0) | 652 // identification failed => use default mixer identifier (=0) |
| 652 mixerId = 0; | 653 mixerId = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 673 if (MMSYSERR_NOERROR != res) | 674 if (MMSYSERR_NOERROR != res) |
| 674 { | 675 { |
| 675 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerOpen() failed
(err=%d)", res); | 676 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerOpen() failed
(err=%d)", res); |
| 676 } | 677 } |
| 677 | 678 |
| 678 // Store the output mixer handle and active mixer identifier | 679 // Store the output mixer handle and active mixer identifier |
| 679 // | 680 // |
| 680 _outputMixerHandle = hMixer; | 681 _outputMixerHandle = hMixer; |
| 681 _outputMixerID = mixerId; | 682 _outputMixerID = mixerId; |
| 682 | 683 |
| 683 if (_outputMixerHandle != NULL) | 684 if (_outputMixerHandle != nullptr) { |
| 684 { | 685 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
| 685 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "the output mixer devic
e is now open (0x%x)", _outputMixerHandle); | 686 "the output mixer device is now open (0x%x)", |
| 687 _outputMixerHandle); |
| 686 } | 688 } |
| 687 | 689 |
| 688 return 0; | 690 return 0; |
| 689 } | 691 } |
| 690 | 692 |
| 691 // ---------------------------------------------------------------------------- | 693 // ---------------------------------------------------------------------------- |
| 692 // OpenSpeaker II(II) | 694 // OpenSpeaker II(II) |
| 693 // | 695 // |
| 694 // Verifies that the mixer contains a valid speaker destination line. | 696 // Verifies that the mixer contains a valid speaker destination line. |
| 695 // Avoids opening the mixer if valid control has not been found. | 697 // Avoids opening the mixer if valid control has not been found. |
| 696 // ---------------------------------------------------------------------------- | 698 // ---------------------------------------------------------------------------- |
| 697 | 699 |
| 698 int32_t AudioMixerManager::OpenSpeaker(uint16_t index) | 700 int32_t AudioMixerManager::OpenSpeaker(uint16_t index) |
| 699 { | 701 { |
| 700 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::OpenSpe
aker(index=%d)", index); | 702 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::OpenSpe
aker(index=%d)", index); |
| 701 | 703 |
| 702 CriticalSectionScoped lock(&_critSect); | 704 CriticalSectionScoped lock(&_critSect); |
| 703 | 705 |
| 704 // Close any existing output mixer handle | 706 // Close any existing output mixer handle |
| 705 // | 707 // |
| 706 if (_outputMixerHandle != NULL) | 708 if (_outputMixerHandle != nullptr) { |
| 707 { | 709 mixerClose(_outputMixerHandle); |
| 708 mixerClose(_outputMixerHandle); | 710 _outputMixerHandle = nullptr; |
| 709 _outputMixerHandle = NULL; | |
| 710 } | 711 } |
| 711 | 712 |
| 712 MMRESULT res; | 713 MMRESULT res; |
| 713 WAVEFORMATEX waveFormat; | 714 WAVEFORMATEX waveFormat; |
| 714 HWAVEOUT hWaveOut(NULL); | 715 HWAVEOUT hWaveOut(nullptr); |
| 715 | 716 |
| 716 const UINT deviceID(index); // use index parameter as device identifier | 717 const UINT deviceID(index); // use index parameter as device identifier |
| 717 | 718 |
| 718 waveFormat.wFormatTag = WAVE_FORMAT_PCM ; | 719 waveFormat.wFormatTag = WAVE_FORMAT_PCM ; |
| 719 waveFormat.nChannels = 2; | 720 waveFormat.nChannels = 2; |
| 720 waveFormat.nSamplesPerSec = 48000; | 721 waveFormat.nSamplesPerSec = 48000; |
| 721 waveFormat.wBitsPerSample = 16; | 722 waveFormat.wBitsPerSample = 16; |
| 722 waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSampl
e / 8; | 723 waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSampl
e / 8; |
| 723 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl
ign; | 724 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl
ign; |
| 724 waveFormat.cbSize = 0; | 725 waveFormat.cbSize = 0; |
| 725 | 726 |
| 726 // We need a waveform-audio output handle for the currently selected output
device. | 727 // We need a waveform-audio output handle for the currently selected output
device. |
| 727 // This handle will then give us the corresponding mixer identifier. Once th
e mixer | 728 // This handle will then give us the corresponding mixer identifier. Once th
e mixer |
| 728 // ID is known, it is possible to open the output mixer. | 729 // ID is known, it is possible to open the output mixer. |
| 729 // | 730 // |
| 730 res = waveOutOpen(&hWaveOut, deviceID, &waveFormat, 0, 0, CALLBACK_NULL); | 731 res = waveOutOpen(&hWaveOut, deviceID, &waveFormat, 0, 0, CALLBACK_NULL); |
| 731 if (MMSYSERR_NOERROR != res) | 732 if (MMSYSERR_NOERROR != res) |
| 732 { | 733 { |
| 733 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutOpen(deviceI
D=%u) failed (err=%d)", index, res); | 734 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutOpen(deviceI
D=%u) failed (err=%d)", index, res); |
| 734 TraceWaveOutError(res); | 735 TraceWaveOutError(res); |
| 735 } | 736 } |
| 736 | 737 |
| 737 UINT mixerId(0); | 738 UINT mixerId(0); |
| 738 HMIXER hMixer(NULL); | 739 HMIXER hMixer(nullptr); |
| 739 | 740 |
| 740 // Retrieve the device identifier for a mixer device associated with the | 741 // Retrieve the device identifier for a mixer device associated with the |
| 741 // aquired waveform-audio output handle. | 742 // aquired waveform-audio output handle. |
| 742 // | 743 // |
| 743 res = mixerGetID((HMIXEROBJ)hWaveOut, &mixerId, MIXER_OBJECTF_HWAVEOUT); | 744 res = mixerGetID((HMIXEROBJ)hWaveOut, &mixerId, MIXER_OBJECTF_HWAVEOUT); |
| 744 if (MMSYSERR_NOERROR != res) | 745 if (MMSYSERR_NOERROR != res) |
| 745 { | 746 { |
| 746 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerGetID(MIXER_OB
JECTF_HWAVEOUT) failed (err=%d)", res); | 747 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerGetID(MIXER_OB
JECTF_HWAVEOUT) failed (err=%d)", res); |
| 747 // identification failed => use default mixer identifier (=0) | 748 // identification failed => use default mixer identifier (=0) |
| 748 mixerId = 0; | 749 mixerId = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 769 if (MMSYSERR_NOERROR != res) | 770 if (MMSYSERR_NOERROR != res) |
| 770 { | 771 { |
| 771 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerOpen() failed
(err=%d)", res); | 772 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerOpen() failed
(err=%d)", res); |
| 772 } | 773 } |
| 773 | 774 |
| 774 // Store the output mixer handle and active mixer identifier | 775 // Store the output mixer handle and active mixer identifier |
| 775 // | 776 // |
| 776 _outputMixerHandle = hMixer; | 777 _outputMixerHandle = hMixer; |
| 777 _outputMixerID = mixerId; | 778 _outputMixerID = mixerId; |
| 778 | 779 |
| 779 if (_outputMixerHandle != NULL) | 780 if (_outputMixerHandle != nullptr) { |
| 780 { | 781 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
| 781 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "the output mixer devic
e is now open (0x%x)", _outputMixerHandle); | 782 "the output mixer device is now open (0x%x)", |
| 783 _outputMixerHandle); |
| 782 } | 784 } |
| 783 | 785 |
| 784 return 0; | 786 return 0; |
| 785 } | 787 } |
| 786 | 788 |
| 787 // ---------------------------------------------------------------------------- | 789 // ---------------------------------------------------------------------------- |
| 788 // OpenMicrophone I(II) | 790 // OpenMicrophone I(II) |
| 789 // | 791 // |
| 790 // Verifies that the mixer contains a valid wave-in destination line. | 792 // Verifies that the mixer contains a valid wave-in destination line. |
| 791 // Avoids opening the mixer if valid control has not been found. | 793 // Avoids opening the mixer if valid control has not been found. |
| 792 // ---------------------------------------------------------------------------- | 794 // ---------------------------------------------------------------------------- |
| 793 | 795 |
| 794 int32_t AudioMixerManager::OpenMicrophone(AudioDeviceModule::WindowsDeviceType d
evice) | 796 int32_t AudioMixerManager::OpenMicrophone(AudioDeviceModule::WindowsDeviceType d
evice) |
| 795 { | 797 { |
| 796 if (device == AudioDeviceModule::kDefaultDevice) | 798 if (device == AudioDeviceModule::kDefaultDevice) |
| 797 { | 799 { |
| 798 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::Ope
nMicrophone(kDefaultDevice)"); | 800 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::Ope
nMicrophone(kDefaultDevice)"); |
| 799 } | 801 } |
| 800 else if (device == AudioDeviceModule::kDefaultCommunicationDevice) | 802 else if (device == AudioDeviceModule::kDefaultCommunicationDevice) |
| 801 { | 803 { |
| 802 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::Ope
nMicrophone(kDefaultCommunicationDevice)"); | 804 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::Ope
nMicrophone(kDefaultCommunicationDevice)"); |
| 803 } | 805 } |
| 804 | 806 |
| 805 CriticalSectionScoped lock(&_critSect); | 807 CriticalSectionScoped lock(&_critSect); |
| 806 | 808 |
| 807 // Close any existing output mixer handle | 809 // Close any existing output mixer handle |
| 808 // | 810 // |
| 809 if (_inputMixerHandle != NULL) | 811 if (_inputMixerHandle != nullptr) { |
| 810 { | 812 mixerClose(_inputMixerHandle); |
| 811 mixerClose(_inputMixerHandle); | 813 _inputMixerHandle = nullptr; |
| 812 _inputMixerHandle = NULL; | |
| 813 } | 814 } |
| 814 | 815 |
| 815 MMRESULT res = MMSYSERR_NOERROR; | 816 MMRESULT res = MMSYSERR_NOERROR; |
| 816 WAVEFORMATEX waveFormat; | 817 WAVEFORMATEX waveFormat; |
| 817 HWAVEIN hWaveIn(NULL); | 818 HWAVEIN hWaveIn(nullptr); |
| 818 | 819 |
| 819 waveFormat.wFormatTag = WAVE_FORMAT_PCM ; | 820 waveFormat.wFormatTag = WAVE_FORMAT_PCM ; |
| 820 waveFormat.nChannels = 1; | 821 waveFormat.nChannels = 1; |
| 821 waveFormat.nSamplesPerSec = 48000; | 822 waveFormat.nSamplesPerSec = 48000; |
| 822 waveFormat.wBitsPerSample = 16; | 823 waveFormat.wBitsPerSample = 16; |
| 823 waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSampl
e / 8; | 824 waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSampl
e / 8; |
| 824 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl
ign; | 825 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl
ign; |
| 825 waveFormat.cbSize = 0 ; | 826 waveFormat.cbSize = 0 ; |
| 826 | 827 |
| 827 // We need a waveform-audio input handle for the currently selected input de
vice. | 828 // We need a waveform-audio input handle for the currently selected input de
vice. |
| 828 // This handle will then give us the corresponding mixer identifier. Once th
e mixer | 829 // This handle will then give us the corresponding mixer identifier. Once th
e mixer |
| 829 // ID is known, it is possible to open the input mixer. | 830 // ID is known, it is possible to open the input mixer. |
| 830 // | 831 // |
| 831 if (device == AudioDeviceModule::kDefaultCommunicationDevice) | 832 if (device == AudioDeviceModule::kDefaultCommunicationDevice) |
| 832 { | 833 { |
| 833 // check if it is possible to open the default communication device (sup
ported on Windows 7) | 834 // check if it is possible to open the default communication device (sup
ported on Windows 7) |
| 834 res = waveInOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | | 835 res = |
| 835 WAVE_MAPPED_kDefaultCommunicationDevice | WAVE_FORMAT_QUERY); | 836 waveInOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0, |
| 837 CALLBACK_NULL | WAVE_MAPPED_kDefaultCommunicationDevice | |
| 838 WAVE_FORMAT_QUERY); |
| 836 if (MMSYSERR_NOERROR == res) | 839 if (MMSYSERR_NOERROR == res) |
| 837 { | 840 { |
| 838 // if so, open the default communication device for real | 841 // if so, open the default communication device for real |
| 839 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_
NULL | WAVE_MAPPED_kDefaultCommunicationDevice); | 842 res = waveInOpen( |
| 843 &hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, |
| 844 CALLBACK_NULL | WAVE_MAPPED_kDefaultCommunicationDevice); |
| 840 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default co
mmunication device"); | 845 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default co
mmunication device"); |
| 841 } | 846 } |
| 842 else | 847 else |
| 843 { | 848 { |
| 844 // use default device since default communication device was not ava
liable | 849 // use default device since default communication device was not ava
liable |
| 845 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_
NULL); | 850 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, |
| 851 CALLBACK_NULL); |
| 846 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 852 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
| 847 "unable to open default communication device => using default in
stead"); | 853 "unable to open default communication device => using default in
stead"); |
| 848 } | 854 } |
| 849 } | 855 } |
| 850 else if (device == AudioDeviceModule::kDefaultDevice) | 856 else if (device == AudioDeviceModule::kDefaultDevice) |
| 851 { | 857 { |
| 852 // open default device since it has been requested | 858 // open default device since it has been requested |
| 853 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL
); | 859 res = |
| 860 waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL); |
| 854 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default input
device"); | 861 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default input
device"); |
| 855 } | 862 } |
| 856 | 863 |
| 857 if (MMSYSERR_NOERROR != res) | 864 if (MMSYSERR_NOERROR != res) |
| 858 { | 865 { |
| 859 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInOpen() failed
(err=%d)", res); | 866 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInOpen() failed
(err=%d)", res); |
| 860 TraceWaveInError(res); | 867 TraceWaveInError(res); |
| 861 } | 868 } |
| 862 | 869 |
| 863 UINT mixerId(0); | 870 UINT mixerId(0); |
| 864 HMIXER hMixer(NULL); | 871 HMIXER hMixer(nullptr); |
| 865 | 872 |
| 866 // Retrieve the device identifier for a mixer device associated with the | 873 // Retrieve the device identifier for a mixer device associated with the |
| 867 // aquired waveform-audio input handle. | 874 // aquired waveform-audio input handle. |
| 868 // | 875 // |
| 869 res = mixerGetID((HMIXEROBJ)hWaveIn, &mixerId, MIXER_OBJECTF_HWAVEIN); | 876 res = mixerGetID((HMIXEROBJ)hWaveIn, &mixerId, MIXER_OBJECTF_HWAVEIN); |
| 870 if (MMSYSERR_NOERROR != res) | 877 if (MMSYSERR_NOERROR != res) |
| 871 { | 878 { |
| 872 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerGetID(MIXER_OB
JECTF_HWAVEIN) failed (err=%d)", res); | 879 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerGetID(MIXER_OB
JECTF_HWAVEIN) failed (err=%d)", res); |
| 873 // identification failed => use default mixer identifier (=0) | 880 // identification failed => use default mixer identifier (=0) |
| 874 mixerId = 0; | 881 mixerId = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 895 if (MMSYSERR_NOERROR != res) | 902 if (MMSYSERR_NOERROR != res) |
| 896 { | 903 { |
| 897 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerOpen() failed
(err=%d)", res); | 904 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerOpen() failed
(err=%d)", res); |
| 898 } | 905 } |
| 899 | 906 |
| 900 // Store the input mixer handle and active mixer identifier | 907 // Store the input mixer handle and active mixer identifier |
| 901 // | 908 // |
| 902 _inputMixerHandle = hMixer; | 909 _inputMixerHandle = hMixer; |
| 903 _inputMixerID = mixerId; | 910 _inputMixerID = mixerId; |
| 904 | 911 |
| 905 if (_inputMixerHandle != NULL) | 912 if (_inputMixerHandle != nullptr) { |
| 906 { | 913 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
| 907 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "the input mixer device
is now open (0x%x)", _inputMixerHandle); | 914 "the input mixer device is now open (0x%x)", |
| 915 _inputMixerHandle); |
| 908 } | 916 } |
| 909 | 917 |
| 910 return 0; | 918 return 0; |
| 911 } | 919 } |
| 912 | 920 |
| 913 // ---------------------------------------------------------------------------- | 921 // ---------------------------------------------------------------------------- |
| 914 // OpenMicrophone II(II) | 922 // OpenMicrophone II(II) |
| 915 // | 923 // |
| 916 // Verifies that the mixer contains a valid wave-in destination line. | 924 // Verifies that the mixer contains a valid wave-in destination line. |
| 917 // Avoids opening the mixer if valid control has not been found. | 925 // Avoids opening the mixer if valid control has not been found. |
| 918 // ---------------------------------------------------------------------------- | 926 // ---------------------------------------------------------------------------- |
| 919 | 927 |
| 920 int32_t AudioMixerManager::OpenMicrophone(uint16_t index) | 928 int32_t AudioMixerManager::OpenMicrophone(uint16_t index) |
| 921 { | 929 { |
| 922 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::OpenMic
rophone(index=%d)", index); | 930 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::OpenMic
rophone(index=%d)", index); |
| 923 | 931 |
| 924 CriticalSectionScoped lock(&_critSect); | 932 CriticalSectionScoped lock(&_critSect); |
| 925 | 933 |
| 926 // Close any existing input mixer handle | 934 // Close any existing input mixer handle |
| 927 // | 935 // |
| 928 if (_inputMixerHandle != NULL) | 936 if (_inputMixerHandle != nullptr) { |
| 929 { | 937 mixerClose(_inputMixerHandle); |
| 930 mixerClose(_inputMixerHandle); | 938 _inputMixerHandle = nullptr; |
| 931 _inputMixerHandle = NULL; | |
| 932 } | 939 } |
| 933 | 940 |
| 934 MMRESULT res; | 941 MMRESULT res; |
| 935 WAVEFORMATEX waveFormat; | 942 WAVEFORMATEX waveFormat; |
| 936 HWAVEIN hWaveIn(NULL); | 943 HWAVEIN hWaveIn(nullptr); |
| 937 | 944 |
| 938 const UINT deviceID(index); // use index parameter as device identifier | 945 const UINT deviceID(index); // use index parameter as device identifier |
| 939 | 946 |
| 940 waveFormat.wFormatTag = WAVE_FORMAT_PCM ; | 947 waveFormat.wFormatTag = WAVE_FORMAT_PCM ; |
| 941 waveFormat.nChannels = 1; | 948 waveFormat.nChannels = 1; |
| 942 waveFormat.nSamplesPerSec = 48000; | 949 waveFormat.nSamplesPerSec = 48000; |
| 943 waveFormat.wBitsPerSample = 16; | 950 waveFormat.wBitsPerSample = 16; |
| 944 waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSampl
e / 8; | 951 waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSampl
e / 8; |
| 945 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl
ign; | 952 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl
ign; |
| 946 waveFormat.cbSize = 0; | 953 waveFormat.cbSize = 0; |
| 947 | 954 |
| 948 // We need a waveform-audio input handle for the currently selected input de
vice. | 955 // We need a waveform-audio input handle for the currently selected input de
vice. |
| 949 // This handle will then give us the corresponding mixer identifier. Once th
e mixer | 956 // This handle will then give us the corresponding mixer identifier. Once th
e mixer |
| 950 // ID is known, it is possible to open the input mixer. | 957 // ID is known, it is possible to open the input mixer. |
| 951 // | 958 // |
| 952 res = waveInOpen(&hWaveIn, deviceID, &waveFormat, 0, 0, CALLBACK_NULL); | 959 res = waveInOpen(&hWaveIn, deviceID, &waveFormat, 0, 0, CALLBACK_NULL); |
| 953 if (MMSYSERR_NOERROR != res) | 960 if (MMSYSERR_NOERROR != res) |
| 954 { | 961 { |
| 955 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInOpen(deviceID
=%u) failed (err=%d)", index, res); | 962 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInOpen(deviceID
=%u) failed (err=%d)", index, res); |
| 956 TraceWaveInError(res); | 963 TraceWaveInError(res); |
| 957 } | 964 } |
| 958 | 965 |
| 959 UINT mixerId(0); | 966 UINT mixerId(0); |
| 960 HMIXER hMixer(NULL); | 967 HMIXER hMixer(nullptr); |
| 961 | 968 |
| 962 // Retrieve the device identifier for a mixer device associated with the | 969 // Retrieve the device identifier for a mixer device associated with the |
| 963 // aquired waveform-audio input handle. | 970 // aquired waveform-audio input handle. |
| 964 // | 971 // |
| 965 res = mixerGetID((HMIXEROBJ)hWaveIn, &mixerId, MIXER_OBJECTF_HWAVEIN); | 972 res = mixerGetID((HMIXEROBJ)hWaveIn, &mixerId, MIXER_OBJECTF_HWAVEIN); |
| 966 if (MMSYSERR_NOERROR != res) | 973 if (MMSYSERR_NOERROR != res) |
| 967 { | 974 { |
| 968 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerGetID(MIXER_OB
JECTF_HWAVEIN) failed (err=%d)", res); | 975 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerGetID(MIXER_OB
JECTF_HWAVEIN) failed (err=%d)", res); |
| 969 // identification failed => use default mixer identifier (=0) | 976 // identification failed => use default mixer identifier (=0) |
| 970 mixerId = 0; | 977 mixerId = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 991 if (MMSYSERR_NOERROR != res) | 998 if (MMSYSERR_NOERROR != res) |
| 992 { | 999 { |
| 993 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerOpen() failed
(err=%d)", res); | 1000 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "mixerOpen() failed
(err=%d)", res); |
| 994 } | 1001 } |
| 995 | 1002 |
| 996 // Store the input mixer handle and active mixer identifier | 1003 // Store the input mixer handle and active mixer identifier |
| 997 // | 1004 // |
| 998 _inputMixerHandle = hMixer; | 1005 _inputMixerHandle = hMixer; |
| 999 _inputMixerID = mixerId; | 1006 _inputMixerID = mixerId; |
| 1000 | 1007 |
| 1001 if (_inputMixerHandle != NULL) | 1008 if (_inputMixerHandle != nullptr) { |
| 1002 { | 1009 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
| 1003 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "the input mixer device
is now open (0x%x)", _inputMixerHandle); | 1010 "the input mixer device is now open (0x%x)", |
| 1011 _inputMixerHandle); |
| 1004 } | 1012 } |
| 1005 | 1013 |
| 1006 return 0; | 1014 return 0; |
| 1007 } | 1015 } |
| 1008 | 1016 |
| 1009 // ---------------------------------------------------------------------------- | 1017 // ---------------------------------------------------------------------------- |
| 1010 // SpeakerIsInitialized | 1018 // SpeakerIsInitialized |
| 1011 // ---------------------------------------------------------------------------- | 1019 // ---------------------------------------------------------------------------- |
| 1012 | 1020 |
| 1013 bool AudioMixerManager::SpeakerIsInitialized() const | 1021 bool AudioMixerManager::SpeakerIsInitialized() const |
| 1014 { | 1022 { |
| 1015 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s", __FUNCTION__); | 1023 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s", __FUNCTION__); |
| 1016 | 1024 |
| 1017 return (_outputMixerHandle != NULL); | 1025 return (_outputMixerHandle != nullptr); |
| 1018 } | 1026 } |
| 1019 | 1027 |
| 1020 // ---------------------------------------------------------------------------- | 1028 // ---------------------------------------------------------------------------- |
| 1021 // MicrophoneIsInitialized | 1029 // MicrophoneIsInitialized |
| 1022 // ---------------------------------------------------------------------------- | 1030 // ---------------------------------------------------------------------------- |
| 1023 | 1031 |
| 1024 bool AudioMixerManager::MicrophoneIsInitialized() const | 1032 bool AudioMixerManager::MicrophoneIsInitialized() const |
| 1025 { | 1033 { |
| 1026 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s", __FUNCTION__); | 1034 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s", __FUNCTION__); |
| 1027 | 1035 |
| 1028 return (_inputMixerHandle != NULL); | 1036 return (_inputMixerHandle != nullptr); |
| 1029 } | 1037 } |
| 1030 | 1038 |
| 1031 // ---------------------------------------------------------------------------- | 1039 // ---------------------------------------------------------------------------- |
| 1032 // SetSpeakerVolume | 1040 // SetSpeakerVolume |
| 1033 // ---------------------------------------------------------------------------- | 1041 // ---------------------------------------------------------------------------- |
| 1034 | 1042 |
| 1035 int32_t AudioMixerManager::SetSpeakerVolume(uint32_t volume) | 1043 int32_t AudioMixerManager::SetSpeakerVolume(uint32_t volume) |
| 1036 { | 1044 { |
| 1037 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::SetSpea
kerVolume(volume=%u)", volume); | 1045 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::SetSpea
kerVolume(volume=%u)", volume); |
| 1038 | 1046 |
| 1039 CriticalSectionScoped lock(&_critSect); | 1047 CriticalSectionScoped lock(&_critSect); |
| 1040 | 1048 |
| 1041 if (_outputMixerHandle == NULL) | 1049 if (_outputMixerHandle == nullptr) { |
| 1042 { | 1050 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1043 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1051 "no avaliable output mixer exists"); |
| 1044 return -1; | 1052 return -1; |
| 1045 } | 1053 } |
| 1046 | 1054 |
| 1047 const UINT mixerID(_outputMixerID); | 1055 const UINT mixerID(_outputMixerID); |
| 1048 const DWORD dwControlID(_speakerState[_outputMixerID].dwVolumeControlID); | 1056 const DWORD dwControlID(_speakerState[_outputMixerID].dwVolumeControlID); |
| 1049 DWORD dwValue(volume); | 1057 DWORD dwValue(volume); |
| 1050 | 1058 |
| 1051 // Set one unsigned control value for a specified volume-control identifier | 1059 // Set one unsigned control value for a specified volume-control identifier |
| 1052 // | 1060 // |
| 1053 if (!SetUnsignedControlValue(mixerID, dwControlID, dwValue)) | 1061 if (!SetUnsignedControlValue(mixerID, dwControlID, dwValue)) |
| 1054 { | 1062 { |
| 1055 return -1; | 1063 return -1; |
| 1056 } | 1064 } |
| 1057 | 1065 |
| 1058 return (0); | 1066 return (0); |
| 1059 } | 1067 } |
| 1060 | 1068 |
| 1061 // ---------------------------------------------------------------------------- | 1069 // ---------------------------------------------------------------------------- |
| 1062 // SpeakerVolume | 1070 // SpeakerVolume |
| 1063 // | 1071 // |
| 1064 // Note that (MIXERCONTROL_CONTROLTYPE_VOLUME & MIXERCONTROL_CT_UNITS_MASK) | 1072 // Note that (MIXERCONTROL_CONTROLTYPE_VOLUME & MIXERCONTROL_CT_UNITS_MASK) |
| 1065 // always equals MIXERCONTROL_CT_UNITS_UNSIGNED; | 1073 // always equals MIXERCONTROL_CT_UNITS_UNSIGNED; |
| 1066 // ---------------------------------------------------------------------------- | 1074 // ---------------------------------------------------------------------------- |
| 1067 | 1075 |
| 1068 int32_t AudioMixerManager::SpeakerVolume(uint32_t& volume) const | 1076 int32_t AudioMixerManager::SpeakerVolume(uint32_t& volume) const |
| 1069 { | 1077 { |
| 1070 | 1078 if (_outputMixerHandle == nullptr) { |
| 1071 if (_outputMixerHandle == NULL) | 1079 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1072 { | 1080 "no avaliable output mixer exists"); |
| 1073 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1081 return -1; |
| 1074 return -1; | |
| 1075 } | 1082 } |
| 1076 | 1083 |
| 1077 const UINT mixerID(_outputMixerID); | 1084 const UINT mixerID(_outputMixerID); |
| 1078 const DWORD dwControlID(_speakerState[_outputMixerID].dwVolumeControlID); | 1085 const DWORD dwControlID(_speakerState[_outputMixerID].dwVolumeControlID); |
| 1079 DWORD dwValue(0); | 1086 DWORD dwValue(0); |
| 1080 | 1087 |
| 1081 // Retrieve one unsigned control value for a specified volume-control identi
fier | 1088 // Retrieve one unsigned control value for a specified volume-control identi
fier |
| 1082 // | 1089 // |
| 1083 if (!GetUnsignedControlValue(mixerID, dwControlID, dwValue)) | 1090 if (!GetUnsignedControlValue(mixerID, dwControlID, dwValue)) |
| 1084 { | 1091 { |
| 1085 return -1; | 1092 return -1; |
| 1086 } | 1093 } |
| 1087 | 1094 |
| 1088 volume = dwValue; | 1095 volume = dwValue; |
| 1089 | 1096 |
| 1090 return 0; | 1097 return 0; |
| 1091 } | 1098 } |
| 1092 | 1099 |
| 1093 // ---------------------------------------------------------------------------- | 1100 // ---------------------------------------------------------------------------- |
| 1094 // MaxSpeakerVolume | 1101 // MaxSpeakerVolume |
| 1095 // | 1102 // |
| 1096 // Note that (MIXERCONTROL_CONTROLTYPE_VOLUME & MIXERCONTROL_CT_UNITS_MASK) | 1103 // Note that (MIXERCONTROL_CONTROLTYPE_VOLUME & MIXERCONTROL_CT_UNITS_MASK) |
| 1097 // always equals MIXERCONTROL_CT_UNITS_UNSIGNED | 1104 // always equals MIXERCONTROL_CT_UNITS_UNSIGNED |
| 1098 // ---------------------------------------------------------------------------- | 1105 // ---------------------------------------------------------------------------- |
| 1099 | 1106 |
| 1100 int32_t AudioMixerManager::MaxSpeakerVolume(uint32_t& maxVolume) const | 1107 int32_t AudioMixerManager::MaxSpeakerVolume(uint32_t& maxVolume) const |
| 1101 { | 1108 { |
| 1102 | 1109 if (_outputMixerHandle == nullptr) { |
| 1103 if (_outputMixerHandle == NULL) | 1110 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1104 { | 1111 "no avaliable output mixer exists"); |
| 1105 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1112 return -1; |
| 1106 return -1; | |
| 1107 } | 1113 } |
| 1108 | 1114 |
| 1109 const UINT mixerID(_outputMixerID); | 1115 const UINT mixerID(_outputMixerID); |
| 1110 const DWORD dwControlID(_speakerState[_outputMixerID].dwVolumeControlID); | 1116 const DWORD dwControlID(_speakerState[_outputMixerID].dwVolumeControlID); |
| 1111 MIXERCONTROL mixerControl; | 1117 MIXERCONTROL mixerControl; |
| 1112 | 1118 |
| 1113 // Retrieve one control line for a specified volume-control identifier | 1119 // Retrieve one control line for a specified volume-control identifier |
| 1114 // | 1120 // |
| 1115 if (!GetLineControl(mixerID, dwControlID, mixerControl)) | 1121 if (!GetLineControl(mixerID, dwControlID, mixerControl)) |
| 1116 { | 1122 { |
| 1117 return -1; | 1123 return -1; |
| 1118 } | 1124 } |
| 1119 | 1125 |
| 1120 maxVolume = mixerControl.Bounds.dwMaximum; | 1126 maxVolume = mixerControl.Bounds.dwMaximum; |
| 1121 | 1127 |
| 1122 return 0; | 1128 return 0; |
| 1123 } | 1129 } |
| 1124 | 1130 |
| 1125 // ---------------------------------------------------------------------------- | 1131 // ---------------------------------------------------------------------------- |
| 1126 // MinSpeakerVolume | 1132 // MinSpeakerVolume |
| 1127 // ---------------------------------------------------------------------------- | 1133 // ---------------------------------------------------------------------------- |
| 1128 | 1134 |
| 1129 int32_t AudioMixerManager::MinSpeakerVolume(uint32_t& minVolume) const | 1135 int32_t AudioMixerManager::MinSpeakerVolume(uint32_t& minVolume) const |
| 1130 { | 1136 { |
| 1131 | 1137 if (_outputMixerHandle == nullptr) { |
| 1132 if (_outputMixerHandle == NULL) | 1138 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1133 { | 1139 "no avaliable output mixer exists"); |
| 1134 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1140 return -1; |
| 1135 return -1; | |
| 1136 } | 1141 } |
| 1137 | 1142 |
| 1138 const UINT mixerID(_outputMixerID); | 1143 const UINT mixerID(_outputMixerID); |
| 1139 const DWORD dwControlID(_speakerState[_outputMixerID].dwVolumeControlID); | 1144 const DWORD dwControlID(_speakerState[_outputMixerID].dwVolumeControlID); |
| 1140 MIXERCONTROL mixerControl; | 1145 MIXERCONTROL mixerControl; |
| 1141 | 1146 |
| 1142 // Retrieve one control line for a specified volume-control identifier | 1147 // Retrieve one control line for a specified volume-control identifier |
| 1143 // | 1148 // |
| 1144 if (!GetLineControl(mixerID, dwControlID, mixerControl)) | 1149 if (!GetLineControl(mixerID, dwControlID, mixerControl)) |
| 1145 { | 1150 { |
| 1146 return -1; | 1151 return -1; |
| 1147 } | 1152 } |
| 1148 | 1153 |
| 1149 minVolume = mixerControl.Bounds.dwMinimum; | 1154 minVolume = mixerControl.Bounds.dwMinimum; |
| 1150 | 1155 |
| 1151 return 0; | 1156 return 0; |
| 1152 } | 1157 } |
| 1153 | 1158 |
| 1154 // ---------------------------------------------------------------------------- | 1159 // ---------------------------------------------------------------------------- |
| 1155 // SpeakerVolumeStepSize | 1160 // SpeakerVolumeStepSize |
| 1156 // ---------------------------------------------------------------------------- | 1161 // ---------------------------------------------------------------------------- |
| 1157 | 1162 |
| 1158 int32_t AudioMixerManager::SpeakerVolumeStepSize(uint16_t& stepSize) const | 1163 int32_t AudioMixerManager::SpeakerVolumeStepSize(uint16_t& stepSize) const |
| 1159 { | 1164 { |
| 1160 | 1165 if (_outputMixerHandle == nullptr) { |
| 1161 if (_outputMixerHandle == NULL) | 1166 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1162 { | 1167 "no avaliable output mixer exists"); |
| 1163 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1168 return -1; |
| 1164 return -1; | |
| 1165 } | 1169 } |
| 1166 | 1170 |
| 1167 const UINT mixerID(_outputMixerID); | 1171 const UINT mixerID(_outputMixerID); |
| 1168 MIXERCONTROL mixerControl; | 1172 MIXERCONTROL mixerControl; |
| 1169 | 1173 |
| 1170 // Retrieve one control line for a specified volume-control identifier | 1174 // Retrieve one control line for a specified volume-control identifier |
| 1171 // | 1175 // |
| 1172 if (!GetLineControl(mixerID, _speakerState[mixerID].dwVolumeControlID, mixer
Control)) | 1176 if (!GetLineControl(mixerID, _speakerState[mixerID].dwVolumeControlID, mixer
Control)) |
| 1173 { | 1177 { |
| 1174 return -1; | 1178 return -1; |
| 1175 } | 1179 } |
| 1176 | 1180 |
| 1177 stepSize = static_cast<uint16_t> (mixerControl.Metrics.cSteps); | 1181 stepSize = static_cast<uint16_t> (mixerControl.Metrics.cSteps); |
| 1178 | 1182 |
| 1179 return 0; | 1183 return 0; |
| 1180 } | 1184 } |
| 1181 | 1185 |
| 1182 // ---------------------------------------------------------------------------- | 1186 // ---------------------------------------------------------------------------- |
| 1183 // SpeakerVolumeIsAvailable | 1187 // SpeakerVolumeIsAvailable |
| 1184 // ---------------------------------------------------------------------------- | 1188 // ---------------------------------------------------------------------------- |
| 1185 | 1189 |
| 1186 int32_t AudioMixerManager::SpeakerVolumeIsAvailable(bool& available) | 1190 int32_t AudioMixerManager::SpeakerVolumeIsAvailable(bool& available) |
| 1187 { | 1191 { |
| 1188 if (_outputMixerHandle == NULL) | 1192 if (_outputMixerHandle == nullptr) { |
| 1189 { | 1193 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1190 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1194 "no avaliable output mixer exists"); |
| 1191 return -1; | 1195 return -1; |
| 1192 } | 1196 } |
| 1193 | 1197 |
| 1194 available = _speakerState[_outputMixerID].volumeControlIsValid; | 1198 available = _speakerState[_outputMixerID].volumeControlIsValid; |
| 1195 | 1199 |
| 1196 return 0; | 1200 return 0; |
| 1197 } | 1201 } |
| 1198 | 1202 |
| 1199 // ---------------------------------------------------------------------------- | 1203 // ---------------------------------------------------------------------------- |
| 1200 // SpeakerMuteIsAvailable | 1204 // SpeakerMuteIsAvailable |
| 1201 // ---------------------------------------------------------------------------- | 1205 // ---------------------------------------------------------------------------- |
| 1202 | 1206 |
| 1203 int32_t AudioMixerManager::SpeakerMuteIsAvailable(bool& available) | 1207 int32_t AudioMixerManager::SpeakerMuteIsAvailable(bool& available) |
| 1204 { | 1208 { |
| 1205 if (_outputMixerHandle == NULL) | 1209 if (_outputMixerHandle == nullptr) { |
| 1206 { | 1210 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1207 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1211 "no avaliable output mixer exists"); |
| 1208 return -1; | 1212 return -1; |
| 1209 } | 1213 } |
| 1210 | 1214 |
| 1211 available = _speakerState[_outputMixerID].muteControlIsValid; | 1215 available = _speakerState[_outputMixerID].muteControlIsValid; |
| 1212 | 1216 |
| 1213 return 0; | 1217 return 0; |
| 1214 } | 1218 } |
| 1215 | 1219 |
| 1216 // ---------------------------------------------------------------------------- | 1220 // ---------------------------------------------------------------------------- |
| 1217 // SetSpeakerMute | 1221 // SetSpeakerMute |
| 1218 // | 1222 // |
| 1219 // This mute function works a master mute for the output speaker. | 1223 // This mute function works a master mute for the output speaker. |
| 1220 // ---------------------------------------------------------------------------- | 1224 // ---------------------------------------------------------------------------- |
| 1221 | 1225 |
| 1222 int32_t AudioMixerManager::SetSpeakerMute(bool enable) | 1226 int32_t AudioMixerManager::SetSpeakerMute(bool enable) |
| 1223 { | 1227 { |
| 1224 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::SetSpea
kerMute(enable=%u)", enable); | 1228 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::SetSpea
kerMute(enable=%u)", enable); |
| 1225 | 1229 |
| 1226 CriticalSectionScoped lock(&_critSect); | 1230 CriticalSectionScoped lock(&_critSect); |
| 1227 | 1231 |
| 1228 if (_outputMixerHandle == NULL) | 1232 if (_outputMixerHandle == nullptr) { |
| 1229 { | 1233 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1230 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1234 "no avaliable output mixer exists"); |
| 1231 return -1; | 1235 return -1; |
| 1232 } | 1236 } |
| 1233 | 1237 |
| 1234 // Ensure that the selected speaker destination has a valid mute control. | 1238 // Ensure that the selected speaker destination has a valid mute control. |
| 1235 // If so, its identifier was stored during the enumeration phase which must | 1239 // If so, its identifier was stored during the enumeration phase which must |
| 1236 // have taken place since the output mixer handle exists. | 1240 // have taken place since the output mixer handle exists. |
| 1237 // | 1241 // |
| 1238 if (!_speakerState[_outputMixerID].muteControlIsValid) | 1242 if (!_speakerState[_outputMixerID].muteControlIsValid) |
| 1239 { | 1243 { |
| 1240 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "it is not possible
to mute this speaker line"); | 1244 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "it is not possible
to mute this speaker line"); |
| 1241 return -1; | 1245 return -1; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1252 | 1256 |
| 1253 return (0); | 1257 return (0); |
| 1254 } | 1258 } |
| 1255 | 1259 |
| 1256 // ---------------------------------------------------------------------------- | 1260 // ---------------------------------------------------------------------------- |
| 1257 // SpeakerMute | 1261 // SpeakerMute |
| 1258 // ---------------------------------------------------------------------------- | 1262 // ---------------------------------------------------------------------------- |
| 1259 | 1263 |
| 1260 int32_t AudioMixerManager::SpeakerMute(bool& enabled) const | 1264 int32_t AudioMixerManager::SpeakerMute(bool& enabled) const |
| 1261 { | 1265 { |
| 1262 | 1266 if (_outputMixerHandle == nullptr) { |
| 1263 if (_outputMixerHandle == NULL) | 1267 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1264 { | 1268 "no avaliable output mixer exists"); |
| 1265 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable output
mixer exists"); | 1269 return -1; |
| 1266 return -1; | |
| 1267 } | 1270 } |
| 1268 | 1271 |
| 1269 // Ensure that the selected speaker destination has a valid mute control. | 1272 // Ensure that the selected speaker destination has a valid mute control. |
| 1270 // If so, its identifier was stored during the enumeration phase which must | 1273 // If so, its identifier was stored during the enumeration phase which must |
| 1271 // have taken place since the output mixer handle exists. | 1274 // have taken place since the output mixer handle exists. |
| 1272 // | 1275 // |
| 1273 if (!_speakerState[_outputMixerID].muteControlIsValid) | 1276 if (!_speakerState[_outputMixerID].muteControlIsValid) |
| 1274 { | 1277 { |
| 1275 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "it is not possible
to mute this speaker line"); | 1278 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "it is not possible
to mute this speaker line"); |
| 1276 return -1; | 1279 return -1; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1290 | 1293 |
| 1291 return 0; | 1294 return 0; |
| 1292 } | 1295 } |
| 1293 | 1296 |
| 1294 // ---------------------------------------------------------------------------- | 1297 // ---------------------------------------------------------------------------- |
| 1295 // MicrophoneMuteIsAvailable | 1298 // MicrophoneMuteIsAvailable |
| 1296 // ---------------------------------------------------------------------------- | 1299 // ---------------------------------------------------------------------------- |
| 1297 | 1300 |
| 1298 int32_t AudioMixerManager::MicrophoneMuteIsAvailable(bool& available) | 1301 int32_t AudioMixerManager::MicrophoneMuteIsAvailable(bool& available) |
| 1299 { | 1302 { |
| 1300 if (_inputMixerHandle == NULL) | 1303 if (_inputMixerHandle == nullptr) { |
| 1301 { | 1304 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1302 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1305 "no avaliable input mixer exists"); |
| 1303 return -1; | 1306 return -1; |
| 1304 } | 1307 } |
| 1305 | 1308 |
| 1306 available = _microphoneState[_inputMixerID].muteControlIsValid; | 1309 available = _microphoneState[_inputMixerID].muteControlIsValid; |
| 1307 | 1310 |
| 1308 return 0; | 1311 return 0; |
| 1309 } | 1312 } |
| 1310 | 1313 |
| 1311 // ---------------------------------------------------------------------------- | 1314 // ---------------------------------------------------------------------------- |
| 1312 // SetMicrophoneMute | 1315 // SetMicrophoneMute |
| 1313 // | 1316 // |
| 1314 // This mute function works a master mute for the input microphone. | 1317 // This mute function works a master mute for the input microphone. |
| 1315 // ---------------------------------------------------------------------------- | 1318 // ---------------------------------------------------------------------------- |
| 1316 | 1319 |
| 1317 int32_t AudioMixerManager::SetMicrophoneMute(bool enable) | 1320 int32_t AudioMixerManager::SetMicrophoneMute(bool enable) |
| 1318 { | 1321 { |
| 1319 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::SetMicr
ophoneMute(enable=%u)", enable); | 1322 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::SetMicr
ophoneMute(enable=%u)", enable); |
| 1320 | 1323 |
| 1321 CriticalSectionScoped lock(&_critSect); | 1324 CriticalSectionScoped lock(&_critSect); |
| 1322 | 1325 |
| 1323 if (_inputMixerHandle == NULL) | 1326 if (_inputMixerHandle == nullptr) { |
| 1324 { | 1327 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1325 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1328 "no avaliable input mixer exists"); |
| 1326 return -1; | 1329 return -1; |
| 1327 } | 1330 } |
| 1328 | 1331 |
| 1329 // Ensure that the selected wave-in destinationhas a valid mute control. | 1332 // Ensure that the selected wave-in destinationhas a valid mute control. |
| 1330 // If so, its identifier was stored during the enumeration phase which must | 1333 // If so, its identifier was stored during the enumeration phase which must |
| 1331 // have taken place since the input mixer handle exists. | 1334 // have taken place since the input mixer handle exists. |
| 1332 // | 1335 // |
| 1333 if (!_microphoneState[_inputMixerID].muteControlIsValid) | 1336 if (!_microphoneState[_inputMixerID].muteControlIsValid) |
| 1334 { | 1337 { |
| 1335 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "it is not possible
to mute this microphone line"); | 1338 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "it is not possible
to mute this microphone line"); |
| 1336 return -1; | 1339 return -1; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1347 | 1350 |
| 1348 return (0); | 1351 return (0); |
| 1349 } | 1352 } |
| 1350 | 1353 |
| 1351 // ---------------------------------------------------------------------------- | 1354 // ---------------------------------------------------------------------------- |
| 1352 // MicrophoneMute | 1355 // MicrophoneMute |
| 1353 // ---------------------------------------------------------------------------- | 1356 // ---------------------------------------------------------------------------- |
| 1354 | 1357 |
| 1355 int32_t AudioMixerManager::MicrophoneMute(bool& enabled) const | 1358 int32_t AudioMixerManager::MicrophoneMute(bool& enabled) const |
| 1356 { | 1359 { |
| 1357 | 1360 if (_inputMixerHandle == nullptr) { |
| 1358 if (_inputMixerHandle == NULL) | 1361 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1359 { | 1362 "no avaliable input mixer exists"); |
| 1360 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1363 return -1; |
| 1361 return -1; | |
| 1362 } | 1364 } |
| 1363 | 1365 |
| 1364 // Ensure that the selected wave-in destinationhas a valid mute control. | 1366 // Ensure that the selected wave-in destinationhas a valid mute control. |
| 1365 // If so, its identifier was stored during the enumeration phase which must | 1367 // If so, its identifier was stored during the enumeration phase which must |
| 1366 // have taken place since the input mixer handle exists. | 1368 // have taken place since the input mixer handle exists. |
| 1367 // | 1369 // |
| 1368 if (!_microphoneState[_inputMixerID].muteControlIsValid) | 1370 if (!_microphoneState[_inputMixerID].muteControlIsValid) |
| 1369 { | 1371 { |
| 1370 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "it is not possible
to mute this microphone line"); | 1372 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "it is not possible
to mute this microphone line"); |
| 1371 return -1; | 1373 return -1; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1385 | 1387 |
| 1386 return 0; | 1388 return 0; |
| 1387 } | 1389 } |
| 1388 | 1390 |
| 1389 // ---------------------------------------------------------------------------- | 1391 // ---------------------------------------------------------------------------- |
| 1390 // MicrophoneBoostIsAvailable | 1392 // MicrophoneBoostIsAvailable |
| 1391 // ---------------------------------------------------------------------------- | 1393 // ---------------------------------------------------------------------------- |
| 1392 | 1394 |
| 1393 int32_t AudioMixerManager::MicrophoneBoostIsAvailable(bool& available) | 1395 int32_t AudioMixerManager::MicrophoneBoostIsAvailable(bool& available) |
| 1394 { | 1396 { |
| 1395 if (_inputMixerHandle == NULL) | 1397 if (_inputMixerHandle == nullptr) { |
| 1396 { | 1398 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1397 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1399 "no avaliable input mixer exists"); |
| 1398 return -1; | 1400 return -1; |
| 1399 } | 1401 } |
| 1400 | 1402 |
| 1401 available = _microphoneState[_inputMixerID].onOffControlIsValid; | 1403 available = _microphoneState[_inputMixerID].onOffControlIsValid; |
| 1402 | 1404 |
| 1403 return 0; | 1405 return 0; |
| 1404 } | 1406 } |
| 1405 | 1407 |
| 1406 // ---------------------------------------------------------------------------- | 1408 // ---------------------------------------------------------------------------- |
| 1407 // SetMicrophoneBoost | 1409 // SetMicrophoneBoost |
| 1408 // ---------------------------------------------------------------------------- | 1410 // ---------------------------------------------------------------------------- |
| 1409 | 1411 |
| 1410 int32_t AudioMixerManager::SetMicrophoneBoost(bool enable) | 1412 int32_t AudioMixerManager::SetMicrophoneBoost(bool enable) |
| 1411 { | 1413 { |
| 1412 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::SetMicr
ophoneBoost(enable=%u)", enable); | 1414 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioMixerManager::SetMicr
ophoneBoost(enable=%u)", enable); |
| 1413 | 1415 |
| 1414 CriticalSectionScoped lock(&_critSect); | 1416 CriticalSectionScoped lock(&_critSect); |
| 1415 | 1417 |
| 1416 if (_inputMixerHandle == NULL) | 1418 if (_inputMixerHandle == nullptr) { |
| 1417 { | 1419 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1418 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1420 "no avaliable input mixer exists"); |
| 1419 return -1; | 1421 return -1; |
| 1420 } | 1422 } |
| 1421 | 1423 |
| 1422 // Ensure that the selected wave-in destination has a valid boost (on/off) c
ontrol. | 1424 // Ensure that the selected wave-in destination has a valid boost (on/off) c
ontrol. |
| 1423 // If so, its identifier was stored during the enumeration phase which must | 1425 // If so, its identifier was stored during the enumeration phase which must |
| 1424 // have taken place since the input mixer handle exists. | 1426 // have taken place since the input mixer handle exists. |
| 1425 // | 1427 // |
| 1426 if (!_microphoneState[_inputMixerID].onOffControlIsValid) | 1428 if (!_microphoneState[_inputMixerID].onOffControlIsValid) |
| 1427 { | 1429 { |
| 1428 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no boost control ex
ists for this wave-in line"); | 1430 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no boost control ex
ists for this wave-in line"); |
| 1429 return -1; | 1431 return -1; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1440 | 1442 |
| 1441 return (0); | 1443 return (0); |
| 1442 } | 1444 } |
| 1443 | 1445 |
| 1444 // ---------------------------------------------------------------------------- | 1446 // ---------------------------------------------------------------------------- |
| 1445 // MicrophoneBoost | 1447 // MicrophoneBoost |
| 1446 // ---------------------------------------------------------------------------- | 1448 // ---------------------------------------------------------------------------- |
| 1447 | 1449 |
| 1448 int32_t AudioMixerManager::MicrophoneBoost(bool& enabled) const | 1450 int32_t AudioMixerManager::MicrophoneBoost(bool& enabled) const |
| 1449 { | 1451 { |
| 1450 | 1452 if (_inputMixerHandle == nullptr) { |
| 1451 if (_inputMixerHandle == NULL) | 1453 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1452 { | 1454 "no avaliable input mixer exists"); |
| 1453 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1455 return -1; |
| 1454 return -1; | |
| 1455 } | 1456 } |
| 1456 | 1457 |
| 1457 // Ensure that the selected wave-in destination has a valid boost (on/off) c
ontrol. | 1458 // Ensure that the selected wave-in destination has a valid boost (on/off) c
ontrol. |
| 1458 // If so, its identifier was stored during the enumeration phase which must | 1459 // If so, its identifier was stored during the enumeration phase which must |
| 1459 // have taken place since the input mixer handle exists. | 1460 // have taken place since the input mixer handle exists. |
| 1460 // | 1461 // |
| 1461 if (!_microphoneState[_inputMixerID].onOffControlIsValid) | 1462 if (!_microphoneState[_inputMixerID].onOffControlIsValid) |
| 1462 { | 1463 { |
| 1463 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no boost control ex
ists for this wave-in line"); | 1464 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no boost control ex
ists for this wave-in line"); |
| 1464 return -1; | 1465 return -1; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1478 | 1479 |
| 1479 return 0; | 1480 return 0; |
| 1480 } | 1481 } |
| 1481 | 1482 |
| 1482 // ---------------------------------------------------------------------------- | 1483 // ---------------------------------------------------------------------------- |
| 1483 // MicrophoneVolumeIsAvailable | 1484 // MicrophoneVolumeIsAvailable |
| 1484 // ---------------------------------------------------------------------------- | 1485 // ---------------------------------------------------------------------------- |
| 1485 | 1486 |
| 1486 int32_t AudioMixerManager::MicrophoneVolumeIsAvailable(bool& available) | 1487 int32_t AudioMixerManager::MicrophoneVolumeIsAvailable(bool& available) |
| 1487 { | 1488 { |
| 1488 if (_inputMixerHandle == NULL) | 1489 if (_inputMixerHandle == nullptr) { |
| 1489 { | 1490 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1490 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1491 "no avaliable input mixer exists"); |
| 1491 return -1; | 1492 return -1; |
| 1492 } | 1493 } |
| 1493 | 1494 |
| 1494 available = _microphoneState[_inputMixerID].volumeControlIsValid; | 1495 available = _microphoneState[_inputMixerID].volumeControlIsValid; |
| 1495 | 1496 |
| 1496 return 0; | 1497 return 0; |
| 1497 } | 1498 } |
| 1498 | 1499 |
| 1499 // ---------------------------------------------------------------------------- | 1500 // ---------------------------------------------------------------------------- |
| 1500 // SetMicrophoneVolume | 1501 // SetMicrophoneVolume |
| 1501 // ---------------------------------------------------------------------------- | 1502 // ---------------------------------------------------------------------------- |
| 1502 | 1503 |
| 1503 int32_t AudioMixerManager::SetMicrophoneVolume(uint32_t volume) | 1504 int32_t AudioMixerManager::SetMicrophoneVolume(uint32_t volume) |
| 1504 { | 1505 { |
| 1505 CriticalSectionScoped lock(&_critSect); | 1506 CriticalSectionScoped lock(&_critSect); |
| 1506 | 1507 |
| 1507 if (_inputMixerHandle == NULL) | 1508 if (_inputMixerHandle == nullptr) { |
| 1508 { | 1509 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1509 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1510 "no avaliable input mixer exists"); |
| 1510 return -1; | 1511 return -1; |
| 1511 } | 1512 } |
| 1512 | 1513 |
| 1513 const UINT mixerID(_inputMixerID); | 1514 const UINT mixerID(_inputMixerID); |
| 1514 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); | 1515 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); |
| 1515 DWORD dwValue(volume); | 1516 DWORD dwValue(volume); |
| 1516 | 1517 |
| 1517 // Set one unsigned control value for a specified volume-control identifier | 1518 // Set one unsigned control value for a specified volume-control identifier |
| 1518 // | 1519 // |
| 1519 if (!SetUnsignedControlValue(mixerID, dwControlID, dwValue)) | 1520 if (!SetUnsignedControlValue(mixerID, dwControlID, dwValue)) |
| 1520 { | 1521 { |
| 1521 return -1; | 1522 return -1; |
| 1522 } | 1523 } |
| 1523 | 1524 |
| 1524 return (0); | 1525 return (0); |
| 1525 } | 1526 } |
| 1526 | 1527 |
| 1527 // ---------------------------------------------------------------------------- | 1528 // ---------------------------------------------------------------------------- |
| 1528 // MicrophoneVolume | 1529 // MicrophoneVolume |
| 1529 // ---------------------------------------------------------------------------- | 1530 // ---------------------------------------------------------------------------- |
| 1530 | 1531 |
| 1531 int32_t AudioMixerManager::MicrophoneVolume(uint32_t& volume) const | 1532 int32_t AudioMixerManager::MicrophoneVolume(uint32_t& volume) const |
| 1532 { | 1533 { |
| 1533 CriticalSectionScoped lock(&_critSect); | 1534 CriticalSectionScoped lock(&_critSect); |
| 1534 | 1535 |
| 1535 if (_inputMixerHandle == NULL) | 1536 if (_inputMixerHandle == nullptr) { |
| 1536 { | 1537 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1537 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1538 "no avaliable input mixer exists"); |
| 1538 return -1; | 1539 return -1; |
| 1539 } | 1540 } |
| 1540 | 1541 |
| 1541 const UINT mixerID(_inputMixerID); | 1542 const UINT mixerID(_inputMixerID); |
| 1542 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); | 1543 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); |
| 1543 DWORD dwValue(0); | 1544 DWORD dwValue(0); |
| 1544 | 1545 |
| 1545 // Retrieve one unsigned control value for a specified volume-control identi
fier | 1546 // Retrieve one unsigned control value for a specified volume-control identi
fier |
| 1546 // | 1547 // |
| 1547 if (!GetUnsignedControlValue(mixerID, dwControlID, dwValue)) | 1548 if (!GetUnsignedControlValue(mixerID, dwControlID, dwValue)) |
| 1548 { | 1549 { |
| 1549 return -1; | 1550 return -1; |
| 1550 } | 1551 } |
| 1551 | 1552 |
| 1552 volume = dwValue; | 1553 volume = dwValue; |
| 1553 | 1554 |
| 1554 return 0; | 1555 return 0; |
| 1555 } | 1556 } |
| 1556 | 1557 |
| 1557 // ---------------------------------------------------------------------------- | 1558 // ---------------------------------------------------------------------------- |
| 1558 // MaxMicrophoneVolume | 1559 // MaxMicrophoneVolume |
| 1559 // ---------------------------------------------------------------------------- | 1560 // ---------------------------------------------------------------------------- |
| 1560 | 1561 |
| 1561 int32_t AudioMixerManager::MaxMicrophoneVolume(uint32_t& maxVolume) const | 1562 int32_t AudioMixerManager::MaxMicrophoneVolume(uint32_t& maxVolume) const |
| 1562 { | 1563 { |
| 1563 WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "%s", __FUNCTION__); | 1564 WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "%s", __FUNCTION__); |
| 1564 | 1565 |
| 1565 if (_inputMixerHandle == NULL) | 1566 if (_inputMixerHandle == nullptr) { |
| 1566 { | 1567 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1567 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1568 "no avaliable input mixer exists"); |
| 1568 return -1; | 1569 return -1; |
| 1569 } | 1570 } |
| 1570 | 1571 |
| 1571 const UINT mixerID(_inputMixerID); | 1572 const UINT mixerID(_inputMixerID); |
| 1572 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); | 1573 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); |
| 1573 MIXERCONTROL mixerControl; | 1574 MIXERCONTROL mixerControl; |
| 1574 | 1575 |
| 1575 // Retrieve one control line for a specified volume-control identifier | 1576 // Retrieve one control line for a specified volume-control identifier |
| 1576 // | 1577 // |
| 1577 if (!GetLineControl(mixerID, dwControlID, mixerControl)) | 1578 if (!GetLineControl(mixerID, dwControlID, mixerControl)) |
| 1578 { | 1579 { |
| 1579 return -1; | 1580 return -1; |
| 1580 } | 1581 } |
| 1581 | 1582 |
| 1582 maxVolume = mixerControl.Bounds.dwMaximum; | 1583 maxVolume = mixerControl.Bounds.dwMaximum; |
| 1583 | 1584 |
| 1584 return 0; | 1585 return 0; |
| 1585 } | 1586 } |
| 1586 | 1587 |
| 1587 // ---------------------------------------------------------------------------- | 1588 // ---------------------------------------------------------------------------- |
| 1588 // MinMicrophoneVolume | 1589 // MinMicrophoneVolume |
| 1589 // ---------------------------------------------------------------------------- | 1590 // ---------------------------------------------------------------------------- |
| 1590 | 1591 |
| 1591 int32_t AudioMixerManager::MinMicrophoneVolume(uint32_t& minVolume) const | 1592 int32_t AudioMixerManager::MinMicrophoneVolume(uint32_t& minVolume) const |
| 1592 { | 1593 { |
| 1593 | 1594 if (_inputMixerHandle == nullptr) { |
| 1594 if (_inputMixerHandle == NULL) | 1595 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1595 { | 1596 "no avaliable input mixer exists"); |
| 1596 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1597 return -1; |
| 1597 return -1; | |
| 1598 } | 1598 } |
| 1599 | 1599 |
| 1600 const UINT mixerID(_inputMixerID); | 1600 const UINT mixerID(_inputMixerID); |
| 1601 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); | 1601 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); |
| 1602 MIXERCONTROL mixerControl; | 1602 MIXERCONTROL mixerControl; |
| 1603 | 1603 |
| 1604 // Retrieve one control line for a specified volume-control identifier | 1604 // Retrieve one control line for a specified volume-control identifier |
| 1605 // | 1605 // |
| 1606 if (!GetLineControl(mixerID, dwControlID, mixerControl)) | 1606 if (!GetLineControl(mixerID, dwControlID, mixerControl)) |
| 1607 { | 1607 { |
| 1608 return -1; | 1608 return -1; |
| 1609 } | 1609 } |
| 1610 | 1610 |
| 1611 minVolume = mixerControl.Bounds.dwMinimum; | 1611 minVolume = mixerControl.Bounds.dwMinimum; |
| 1612 | 1612 |
| 1613 return 0; | 1613 return 0; |
| 1614 } | 1614 } |
| 1615 | 1615 |
| 1616 // ---------------------------------------------------------------------------- | 1616 // ---------------------------------------------------------------------------- |
| 1617 // MicrophoneVolumeStepSize | 1617 // MicrophoneVolumeStepSize |
| 1618 // ---------------------------------------------------------------------------- | 1618 // ---------------------------------------------------------------------------- |
| 1619 | 1619 |
| 1620 int32_t AudioMixerManager::MicrophoneVolumeStepSize(uint16_t& stepSize) const | 1620 int32_t AudioMixerManager::MicrophoneVolumeStepSize(uint16_t& stepSize) const |
| 1621 { | 1621 { |
| 1622 | 1622 if (_inputMixerHandle == nullptr) { |
| 1623 if (_inputMixerHandle == NULL) | 1623 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
| 1624 { | 1624 "no avaliable input mixer exists"); |
| 1625 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no avaliable input
mixer exists"); | 1625 return -1; |
| 1626 return -1; | |
| 1627 } | 1626 } |
| 1628 | 1627 |
| 1629 const UINT mixerID(_inputMixerID); | 1628 const UINT mixerID(_inputMixerID); |
| 1630 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); | 1629 const DWORD dwControlID(_microphoneState[_inputMixerID].dwVolumeControlID); |
| 1631 MIXERCONTROL mixerControl; | 1630 MIXERCONTROL mixerControl; |
| 1632 | 1631 |
| 1633 // Retrieve one control line for a specified volume-control identifier | 1632 // Retrieve one control line for a specified volume-control identifier |
| 1634 // | 1633 // |
| 1635 if (!GetLineControl(mixerID, dwControlID, mixerControl)) | 1634 if (!GetLineControl(mixerID, dwControlID, mixerControl)) |
| 1636 { | 1635 { |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2716 if (WideCharToMultiByte(CP_UTF8, 0, src, -1, _str, kStrLen, 0, 0) == 0) | 2715 if (WideCharToMultiByte(CP_UTF8, 0, src, -1, _str, kStrLen, 0, 0) == 0) |
| 2717 memset(_str, 0, kStrLen); | 2716 memset(_str, 0, kStrLen); |
| 2718 } | 2717 } |
| 2719 return _str; | 2718 return _str; |
| 2720 #else | 2719 #else |
| 2721 return const_cast<char*>(src); | 2720 return const_cast<char*>(src); |
| 2722 #endif | 2721 #endif |
| 2723 } | 2722 } |
| 2724 | 2723 |
| 2725 } // namespace webrtc | 2724 } // namespace webrtc |
| OLD | NEW |