1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_MIXER_MANAGER_ALSA_LINUX_H 12 #define WEBRTC_AUDIO_DEVICE_AUDIO_MIXER_MANAGER_ALSA_LINUX_H 13 14 #include "webrtc/modules/audio_device/include/audio_device.h" 15 #include "webrtc/modules/audio_device/linux/alsasymboltable_linux.h" 16 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 17 #include "webrtc/typedefs.h" 18 19 #include <alsa/asoundlib.h> 20 21 namespace webrtc 22 { 23 24 class AudioMixerManagerLinuxALSA 25 { 26 public: 27 int32_t OpenSpeaker(char* deviceName); 28 int32_t OpenMicrophone(char* deviceName); 29 int32_t SetSpeakerVolume(uint32_t volume); 30 int32_t SpeakerVolume(uint32_t& volume) const; 31 int32_t MaxSpeakerVolume(uint32_t& maxVolume) const; 32 int32_t MinSpeakerVolume(uint32_t& minVolume) const; 33 int32_t SpeakerVolumeStepSize(uint16_t& stepSize) const; 34 int32_t SpeakerVolumeIsAvailable(bool& available); 35 int32_t SpeakerMuteIsAvailable(bool& available); 36 int32_t SetSpeakerMute(bool enable); 37 int32_t SpeakerMute(bool& enabled) const; 38 int32_t MicrophoneMuteIsAvailable(bool& available); 39 int32_t SetMicrophoneMute(bool enable); 40 int32_t MicrophoneMute(bool& enabled) const; 41 int32_t MicrophoneBoostIsAvailable(bool& available); 42 int32_t SetMicrophoneBoost(bool enable); 43 int32_t MicrophoneBoost(bool& enabled) const; 44 int32_t MicrophoneVolumeIsAvailable(bool& available); 45 int32_t SetMicrophoneVolume(uint32_t volume); 46 int32_t MicrophoneVolume(uint32_t& volume) const; 47 int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const; 48 int32_t MinMicrophoneVolume(uint32_t& minVolume) const; 49 int32_t MicrophoneVolumeStepSize(uint16_t& stepSize) const; 50 int32_t Close(); 51 int32_t CloseSpeaker(); 52 int32_t CloseMicrophone(); 53 bool SpeakerIsInitialized() const; 54 bool MicrophoneIsInitialized() const; 55 56 public: 57 AudioMixerManagerLinuxALSA(const int32_t id); 58 ~AudioMixerManagerLinuxALSA(); 59 60 private: 61 int32_t LoadMicMixerElement() const; 62 int32_t LoadSpeakerMixerElement() const; 63 void GetControlName(char *controlName, char* deviceName) const; 64 65 private: 66 CriticalSectionWrapper& _critSect; 67 int32_t _id; 68 mutable snd_mixer_t* _outputMixerHandle; 69 char _outputMixerStr[kAdmMaxDeviceNameSize]; 70 mutable snd_mixer_t* _inputMixerHandle; 71 char _inputMixerStr[kAdmMaxDeviceNameSize]; 72 mutable snd_mixer_elem_t* _outputMixerElement; 73 mutable snd_mixer_elem_t* _inputMixerElement; 74 }; 75 76 } 77 78 #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_MIXER_MANAGER_ALSA_LINUX_H_ 79