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 AUDIO_DEVICE_AUDIO_MIXER_MANAGER_ALSA_LINUX_H_ 12 #define AUDIO_DEVICE_AUDIO_MIXER_MANAGER_ALSA_LINUX_H_ 13 14 #include <alsa/asoundlib.h> 15 16 #include "modules/audio_device/include/audio_device.h" 17 #include "modules/audio_device/linux/alsasymboltable_linux.h" 18 #include "rtc_base/synchronization/mutex.h" 19 20 namespace webrtc { 21 22 class AudioMixerManagerLinuxALSA { 23 public: 24 int32_t OpenSpeaker(char* deviceName); 25 int32_t OpenMicrophone(char* deviceName); 26 int32_t SetSpeakerVolume(uint32_t volume); 27 int32_t SpeakerVolume(uint32_t& volume) const; 28 int32_t MaxSpeakerVolume(uint32_t& maxVolume) const; 29 int32_t MinSpeakerVolume(uint32_t& minVolume) const; 30 int32_t SpeakerVolumeIsAvailable(bool& available); 31 int32_t SpeakerMuteIsAvailable(bool& available); 32 int32_t SetSpeakerMute(bool enable); 33 int32_t SpeakerMute(bool& enabled) const; 34 int32_t MicrophoneMuteIsAvailable(bool& available); 35 int32_t SetMicrophoneMute(bool enable); 36 int32_t MicrophoneMute(bool& enabled) const; 37 int32_t MicrophoneVolumeIsAvailable(bool& available); 38 int32_t SetMicrophoneVolume(uint32_t volume); 39 int32_t MicrophoneVolume(uint32_t& volume) const; 40 int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const; 41 int32_t MinMicrophoneVolume(uint32_t& minVolume) const; 42 int32_t Close(); 43 int32_t CloseSpeaker(); 44 int32_t CloseMicrophone(); 45 bool SpeakerIsInitialized() const; 46 bool MicrophoneIsInitialized() const; 47 48 public: 49 AudioMixerManagerLinuxALSA(); 50 ~AudioMixerManagerLinuxALSA(); 51 52 private: 53 int32_t LoadMicMixerElement() const; 54 int32_t LoadSpeakerMixerElement() const; 55 void GetControlName(char* controlName, char* deviceName) const; 56 57 private: 58 Mutex mutex_; 59 mutable snd_mixer_t* _outputMixerHandle; 60 char _outputMixerStr[kAdmMaxDeviceNameSize]; 61 mutable snd_mixer_t* _inputMixerHandle; 62 char _inputMixerStr[kAdmMaxDeviceNameSize]; 63 mutable snd_mixer_elem_t* _outputMixerElement; 64 mutable snd_mixer_elem_t* _inputMixerElement; 65 }; 66 67 } // namespace webrtc 68 69 #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_MIXER_MANAGER_ALSA_LINUX_H_ 70