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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 { | 527 { |
528 LOG(LS_ERROR) << "Error setting playback volume range: " | 528 LOG(LS_ERROR) << "Error setting playback volume range: " |
529 << snd_strerror(errVal); | 529 << snd_strerror(errVal); |
530 return -1; | 530 return -1; |
531 } | 531 } |
532 | 532 |
533 return 0; | 533 return 0; |
534 } | 534 } |
535 */ | 535 */ |
536 | 536 |
537 int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeStepSize( | |
538 uint16_t& stepSize) const | |
539 { | |
540 | |
541 if (_outputMixerHandle == NULL) | |
542 { | |
543 LOG(LS_WARNING) << "no avaliable output mixer exists"; | |
544 return -1; | |
545 } | |
546 | |
547 // The step size is always 1 for ALSA | |
548 stepSize = 1; | |
549 | |
550 return 0; | |
551 } | |
552 | |
553 int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeIsAvailable( | 537 int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeIsAvailable( |
554 bool& available) | 538 bool& available) |
555 { | 539 { |
556 if (_outputMixerElement == NULL) | 540 if (_outputMixerElement == NULL) |
557 { | 541 { |
558 LOG(LS_WARNING) << "no avaliable output mixer element exists"; | 542 LOG(LS_WARNING) << "no avaliable output mixer element exists"; |
559 return -1; | 543 return -1; |
560 } | 544 } |
561 | 545 |
562 available = LATE(snd_mixer_selem_has_playback_volume)(_outputMixerElement); | 546 available = LATE(snd_mixer_selem_has_playback_volume)(_outputMixerElement); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 << LATE(snd_strerror)(errVal); | 720 << LATE(snd_strerror)(errVal); |
737 return -1; | 721 return -1; |
738 } | 722 } |
739 | 723 |
740 // Note value = 0 (off) means muted | 724 // Note value = 0 (off) means muted |
741 enabled = (bool) !value; | 725 enabled = (bool) !value; |
742 | 726 |
743 return 0; | 727 return 0; |
744 } | 728 } |
745 | 729 |
746 int32_t AudioMixerManagerLinuxALSA::MicrophoneBoostIsAvailable( | |
747 bool& available) | |
748 { | |
749 if (_inputMixerHandle == NULL) | |
750 { | |
751 LOG(LS_WARNING) << "no avaliable input mixer exists"; | |
752 return -1; | |
753 } | |
754 | |
755 // Microphone boost cannot be enabled through ALSA Simple Mixer Interface | |
756 available = false; | |
757 | |
758 return 0; | |
759 } | |
760 | |
761 int32_t AudioMixerManagerLinuxALSA::SetMicrophoneBoost(bool enable) | |
762 { | |
763 LOG(LS_VERBOSE) << "AudioMixerManagerLinuxALSA::SetMicrophoneBoost(enable=" | |
764 << enable << ")"; | |
765 | |
766 rtc::CritScope lock(&_critSect); | |
767 | |
768 if (_inputMixerHandle == NULL) | |
769 { | |
770 LOG(LS_WARNING) << "no avaliable input mixer exists"; | |
771 return -1; | |
772 } | |
773 | |
774 // Ensure that the selected microphone destination has a valid mute control. | |
775 bool available(false); | |
776 MicrophoneMuteIsAvailable(available); | |
777 if (!available) | |
778 { | |
779 LOG(LS_WARNING) << "it is not possible to enable microphone boost"; | |
780 return -1; | |
781 } | |
782 | |
783 // It is assumed that the call above fails! | |
784 | |
785 return (0); | |
786 } | |
787 | |
788 int32_t AudioMixerManagerLinuxALSA::MicrophoneBoost(bool& enabled) const | |
789 { | |
790 | |
791 if (_inputMixerHandle == NULL) | |
792 { | |
793 LOG(LS_WARNING) << "no avaliable input mixer exists"; | |
794 return -1; | |
795 } | |
796 | |
797 // Microphone boost cannot be enabled on this platform! | |
798 enabled = false; | |
799 | |
800 return 0; | |
801 } | |
802 | |
803 int32_t AudioMixerManagerLinuxALSA::MicrophoneVolumeIsAvailable( | 730 int32_t AudioMixerManagerLinuxALSA::MicrophoneVolumeIsAvailable( |
804 bool& available) | 731 bool& available) |
805 { | 732 { |
806 if (_inputMixerElement == NULL) | 733 if (_inputMixerElement == NULL) |
807 { | 734 { |
808 LOG(LS_WARNING) << "no avaliable input mixer element exists"; | 735 LOG(LS_WARNING) << "no avaliable input mixer element exists"; |
809 return -1; | 736 return -1; |
810 } | 737 } |
811 | 738 |
812 available = LATE(snd_mixer_selem_has_capture_volume)(_inputMixerElement); | 739 available = LATE(snd_mixer_selem_has_capture_volume)(_inputMixerElement); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 { | 947 { |
1021 LOG(LS_ERROR) << "Error getting microphone volume range: " | 948 LOG(LS_ERROR) << "Error getting microphone volume range: " |
1022 << LATE(snd_strerror)(errVal); | 949 << LATE(snd_strerror)(errVal); |
1023 } | 950 } |
1024 | 951 |
1025 minVolume = static_cast<uint32_t> (minVol); | 952 minVolume = static_cast<uint32_t> (minVol); |
1026 | 953 |
1027 return 0; | 954 return 0; |
1028 } | 955 } |
1029 | 956 |
1030 int32_t AudioMixerManagerLinuxALSA::MicrophoneVolumeStepSize( | |
1031 uint16_t& stepSize) const | |
1032 { | |
1033 | |
1034 if (_inputMixerHandle == NULL) | |
1035 { | |
1036 LOG(LS_WARNING) << "no avaliable input mixer exists"; | |
1037 return -1; | |
1038 } | |
1039 | |
1040 // The step size is always 1 for ALSA | |
1041 stepSize = 1; | |
1042 | |
1043 return 0; | |
1044 } | |
1045 | |
1046 // ============================================================================ | 957 // ============================================================================ |
1047 // Private Methods | 958 // Private Methods |
1048 // ============================================================================ | 959 // ============================================================================ |
1049 | 960 |
1050 int32_t AudioMixerManagerLinuxALSA::LoadMicMixerElement() const | 961 int32_t AudioMixerManagerLinuxALSA::LoadMicMixerElement() const |
1051 { | 962 { |
1052 int errVal = LATE(snd_mixer_load)(_inputMixerHandle); | 963 int errVal = LATE(snd_mixer_load)(_inputMixerHandle); |
1053 if (errVal < 0) | 964 if (errVal < 0) |
1054 { | 965 { |
1055 LOG(LS_ERROR) << "snd_mixer_load(_inputMixerHandle), error: " | 966 LOG(LS_ERROR) << "snd_mixer_load(_inputMixerHandle), error: " |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 int nChar = (int) (pos2 - pos1); | 1108 int nChar = (int) (pos2 - pos1); |
1198 strncpy(&controlName[2], pos1, nChar); | 1109 strncpy(&controlName[2], pos1, nChar); |
1199 controlName[2 + nChar] = '\0'; | 1110 controlName[2 + nChar] = '\0'; |
1200 } else { | 1111 } else { |
1201 strcpy(controlName, deviceName); | 1112 strcpy(controlName, deviceName); |
1202 } | 1113 } |
1203 | 1114 |
1204 } | 1115 } |
1205 | 1116 |
1206 } | 1117 } |
OLD | NEW |