• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MAC_H_
12 #define AUDIO_DEVICE_AUDIO_MIXER_MANAGER_MAC_H_
13 
14 #include <CoreAudio/CoreAudio.h>
15 
16 #include "modules/audio_device/include/audio_device.h"
17 #include "rtc_base/logging.h"
18 #include "rtc_base/synchronization/mutex.h"
19 
20 namespace webrtc {
21 
22 class AudioMixerManagerMac {
23  public:
24   int32_t OpenSpeaker(AudioDeviceID deviceID) RTC_LOCKS_EXCLUDED(mutex_);
25   int32_t OpenMicrophone(AudioDeviceID deviceID) RTC_LOCKS_EXCLUDED(mutex_);
26   int32_t SetSpeakerVolume(uint32_t volume) RTC_LOCKS_EXCLUDED(mutex_);
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) RTC_LOCKS_EXCLUDED(mutex_);
33   int32_t SpeakerMute(bool& enabled) const;
34   int32_t StereoPlayoutIsAvailable(bool& available);
35   int32_t StereoRecordingIsAvailable(bool& available);
36   int32_t MicrophoneMuteIsAvailable(bool& available);
37   int32_t SetMicrophoneMute(bool enable) RTC_LOCKS_EXCLUDED(mutex_);
38   int32_t MicrophoneMute(bool& enabled) const;
39   int32_t MicrophoneVolumeIsAvailable(bool& available);
40   int32_t SetMicrophoneVolume(uint32_t volume) RTC_LOCKS_EXCLUDED(mutex_);
41   int32_t MicrophoneVolume(uint32_t& volume) const;
42   int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
43   int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
44   int32_t Close() RTC_LOCKS_EXCLUDED(mutex_);
45   int32_t CloseSpeaker() RTC_LOCKS_EXCLUDED(mutex_);
46   int32_t CloseMicrophone() RTC_LOCKS_EXCLUDED(mutex_);
47   bool SpeakerIsInitialized() const;
48   bool MicrophoneIsInitialized() const;
49 
50  public:
51   AudioMixerManagerMac();
52   ~AudioMixerManagerMac();
53 
54  private:
55   int32_t CloseSpeakerLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
56   int32_t CloseMicrophoneLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
57   static void logCAMsg(rtc::LoggingSeverity sev,
58                        const char* msg,
59                        const char* err);
60 
61  private:
62   Mutex mutex_;
63 
64   AudioDeviceID _inputDeviceID;
65   AudioDeviceID _outputDeviceID;
66 
67   uint16_t _noInputChannels;
68   uint16_t _noOutputChannels;
69 };
70 
71 }  // namespace webrtc
72 
73 #endif  // AUDIO_MIXER_MAC_H
74