[email protected] | 36221c69 | 2013-05-02 23:45:47 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_ |
| 6 | #define CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_ |
| 7 | |
[email protected] | 36221c69 | 2013-05-02 23:45:47 | [diff] [blame] | 8 | #include "base/memory/ref_counted.h" |
| 9 | #include "chromeos/audio/audio_pref_observer.h" |
| 10 | #include "chromeos/chromeos_export.h" |
| 11 | |
[email protected] | 36221c69 | 2013-05-02 23:45:47 | [diff] [blame] | 12 | namespace chromeos { |
| 13 | |
[email protected] | 6fda9fb8 | 2013-06-20 21:57:38 | [diff] [blame] | 14 | struct AudioDevice; |
| 15 | |
[email protected] | 36221c69 | 2013-05-02 23:45:47 | [diff] [blame] | 16 | // Interface that handles audio preference related work, reads and writes |
| 17 | // audio preferences, and notifies AudioPrefObserver for audio preference |
| 18 | // changes. |
| 19 | class CHROMEOS_EXPORT AudioDevicesPrefHandler |
| 20 | : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> { |
| 21 | public: |
jamescook | 15015851 | 2014-12-19 02:55:00 | [diff] [blame] | 22 | // Integer because C++ does not allow static const double in header files. |
| 23 | static const int kDefaultOutputVolumePercent = 75; |
| 24 | static const int kDefaultHdmiOutputVolumePercent = 100; |
| 25 | |
[email protected] | 029a00c | 2013-05-07 00:44:58 | [diff] [blame] | 26 | // Gets the audio output volume value from prefs for a device. Since we can |
| 27 | // only have either a gain or a volume for a device (depending on whether it |
| 28 | // is input or output), we don't really care which value it is. |
[email protected] | 140a3145 | 2013-09-09 18:54:37 | [diff] [blame] | 29 | virtual double GetOutputVolumeValue(const AudioDevice* device) = 0; |
| 30 | virtual double GetInputGainValue(const AudioDevice* device) = 0; |
[email protected] | 029a00c | 2013-05-07 00:44:58 | [diff] [blame] | 31 | // Sets the audio volume or gain value to prefs for a device. |
[email protected] | 6fda9fb8 | 2013-06-20 21:57:38 | [diff] [blame] | 32 | virtual void SetVolumeGainValue(const AudioDevice& device, double value) = 0; |
[email protected] | 36221c69 | 2013-05-02 23:45:47 | [diff] [blame] | 33 | |
[email protected] | 029a00c | 2013-05-07 00:44:58 | [diff] [blame] | 34 | // Reads the audio mute value from prefs for a device. |
[email protected] | 6fda9fb8 | 2013-06-20 21:57:38 | [diff] [blame] | 35 | virtual bool GetMuteValue(const AudioDevice& device) = 0; |
[email protected] | 029a00c | 2013-05-07 00:44:58 | [diff] [blame] | 36 | // Sets the audio mute value to prefs for a device. |
[email protected] | 6fda9fb8 | 2013-06-20 21:57:38 | [diff] [blame] | 37 | virtual void SetMuteValue(const AudioDevice& device, bool mute_on) = 0; |
[email protected] | 36221c69 | 2013-05-02 23:45:47 | [diff] [blame] | 38 | |
jennyz | bd23674 | 2016-03-02 20:15:52 | [diff] [blame] | 39 | // Sets the device active state in prefs. |
| 40 | // Note: |activate_by_user| indicates whether |device| is set to active |
| 41 | // by user or by priority, and it only matters when |active| is true. |
| 42 | virtual void SetDeviceActive(const AudioDevice& device, |
| 43 | bool active, |
| 44 | bool activate_by_user) = 0; |
| 45 | // Returns false if it fails to get device active state from prefs. |
| 46 | // Otherwise, returns true, pass the active state data in |*active| |
| 47 | // and |*activate_by_user|. |
| 48 | // Note: |*activate_by_user| only matters when |*active| is true. |
| 49 | virtual bool GetDeviceActive(const AudioDevice& device, |
| 50 | bool* active, |
| 51 | bool* activate_by_user) = 0; |
hychao | fe100d54 | 2016-01-12 10:17:52 | [diff] [blame] | 52 | |
[email protected] | 36221c69 | 2013-05-02 23:45:47 | [diff] [blame] | 53 | // Reads the audio output allowed value from prefs. |
| 54 | virtual bool GetAudioOutputAllowedValue() = 0; |
| 55 | |
| 56 | // Adds an audio preference observer. |
| 57 | virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0; |
| 58 | // Removes an audio preference observer. |
| 59 | virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0; |
| 60 | |
[email protected] | 36221c69 | 2013-05-02 23:45:47 | [diff] [blame] | 61 | protected: |
| 62 | virtual ~AudioDevicesPrefHandler() {} |
| 63 | |
| 64 | private: |
| 65 | friend class base::RefCountedThreadSafe<AudioDevicesPrefHandler>; |
| 66 | }; |
| 67 | |
| 68 | } // namespace chromeos |
| 69 | |
| 70 | #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_ |