blob: 09bb7875af910daaed70cc96cbe40c39435ff6a3 [file] [log] [blame]
[email protected]36221c692013-05-02 23:45:471// 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]36221c692013-05-02 23:45:478#include "base/memory/ref_counted.h"
9#include "chromeos/audio/audio_pref_observer.h"
10#include "chromeos/chromeos_export.h"
11
[email protected]36221c692013-05-02 23:45:4712namespace chromeos {
13
[email protected]6fda9fb82013-06-20 21:57:3814struct AudioDevice;
15
[email protected]36221c692013-05-02 23:45:4716// Interface that handles audio preference related work, reads and writes
17// audio preferences, and notifies AudioPrefObserver for audio preference
18// changes.
19class CHROMEOS_EXPORT AudioDevicesPrefHandler
20 : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> {
21 public:
jamescook150158512014-12-19 02:55:0022 // 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]029a00c2013-05-07 00:44:5826 // 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]140a31452013-09-09 18:54:3729 virtual double GetOutputVolumeValue(const AudioDevice* device) = 0;
30 virtual double GetInputGainValue(const AudioDevice* device) = 0;
[email protected]029a00c2013-05-07 00:44:5831 // Sets the audio volume or gain value to prefs for a device.
[email protected]6fda9fb82013-06-20 21:57:3832 virtual void SetVolumeGainValue(const AudioDevice& device, double value) = 0;
[email protected]36221c692013-05-02 23:45:4733
[email protected]029a00c2013-05-07 00:44:5834 // Reads the audio mute value from prefs for a device.
[email protected]6fda9fb82013-06-20 21:57:3835 virtual bool GetMuteValue(const AudioDevice& device) = 0;
[email protected]029a00c2013-05-07 00:44:5836 // Sets the audio mute value to prefs for a device.
[email protected]6fda9fb82013-06-20 21:57:3837 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) = 0;
[email protected]36221c692013-05-02 23:45:4738
jennyzbd236742016-03-02 20:15:5239 // 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;
hychaofe100d542016-01-12 10:17:5252
[email protected]36221c692013-05-02 23:45:4753 // 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]36221c692013-05-02 23:45:4761 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_