Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: chromeos/audio/audio_devices_pref_handler.h

Issue 1380103003: Store audio device's active state in preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_ 5 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_
6 #define CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_ 6 #define CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "chromeos/audio/audio_pref_observer.h" 9 #include "chromeos/audio/audio_pref_observer.h"
10 #include "chromeos/chromeos_export.h" 10 #include "chromeos/chromeos_export.h"
11 11
12 class PrefService; 12 class PrefService;
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 struct AudioDevice; 16 struct AudioDevice;
17 17
18 // Used to represent an audio device's state. This state should be updated
19 // to AUDIO_STATE_ACTIVE when it is selected as active or set to
20 // AUDIO_STATE_INACTIVE when selected to a different device. When the audio
21 // device is unplugged, its last active/inactive state should be stored.
22 // The default value of device state will be AUDIO_STATE_NOT_AVAILABLE if
23 // the device is not found in the pref settings.
24 enum AudioDeviceState {
25 AUDIO_STATE_ACTIVE,
Daniel Erat 2016/01/07 17:31:12 explicitly specify the numbers for these and docum
hychao 2016/01/11 07:02:32 Done.
26 AUDIO_STATE_INACTIVE,
27 AUDIO_STATE_NOT_AVAILABLE,
28 };
29
18 // Interface that handles audio preference related work, reads and writes 30 // Interface that handles audio preference related work, reads and writes
19 // audio preferences, and notifies AudioPrefObserver for audio preference 31 // audio preferences, and notifies AudioPrefObserver for audio preference
20 // changes. 32 // changes.
21 class CHROMEOS_EXPORT AudioDevicesPrefHandler 33 class CHROMEOS_EXPORT AudioDevicesPrefHandler
22 : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> { 34 : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> {
23 public: 35 public:
24 // Integer because C++ does not allow static const double in header files. 36 // Integer because C++ does not allow static const double in header files.
25 static const int kDefaultOutputVolumePercent = 75; 37 static const int kDefaultOutputVolumePercent = 75;
26 static const int kDefaultHdmiOutputVolumePercent = 100; 38 static const int kDefaultHdmiOutputVolumePercent = 100;
27 39
28 // Gets the audio output volume value from prefs for a device. Since we can 40 // Gets the audio output volume value from prefs for a device. Since we can
29 // only have either a gain or a volume for a device (depending on whether it 41 // only have either a gain or a volume for a device (depending on whether it
30 // is input or output), we don't really care which value it is. 42 // is input or output), we don't really care which value it is.
31 virtual double GetOutputVolumeValue(const AudioDevice* device) = 0; 43 virtual double GetOutputVolumeValue(const AudioDevice* device) = 0;
32 virtual double GetInputGainValue(const AudioDevice* device) = 0; 44 virtual double GetInputGainValue(const AudioDevice* device) = 0;
33 // Sets the audio volume or gain value to prefs for a device. 45 // Sets the audio volume or gain value to prefs for a device.
34 virtual void SetVolumeGainValue(const AudioDevice& device, double value) = 0; 46 virtual void SetVolumeGainValue(const AudioDevice& device, double value) = 0;
35 47
36 // Reads the audio mute value from prefs for a device. 48 // Reads the audio mute value from prefs for a device.
37 virtual bool GetMuteValue(const AudioDevice& device) = 0; 49 virtual bool GetMuteValue(const AudioDevice& device) = 0;
38 // Sets the audio mute value to prefs for a device. 50 // Sets the audio mute value to prefs for a device.
39 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) = 0; 51 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) = 0;
40 52
53 virtual AudioDeviceState GetDeviceState(
54 const AudioDevice &device) = 0;
55 virtual void SetDeviceState(const AudioDevice& device,
56 AudioDeviceState state) = 0;
57
41 // Reads the audio output allowed value from prefs. 58 // Reads the audio output allowed value from prefs.
42 virtual bool GetAudioOutputAllowedValue() = 0; 59 virtual bool GetAudioOutputAllowedValue() = 0;
43 60
44 // Adds an audio preference observer. 61 // Adds an audio preference observer.
45 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0; 62 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0;
46 // Removes an audio preference observer. 63 // Removes an audio preference observer.
47 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0; 64 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0;
48 65
49 protected: 66 protected:
50 virtual ~AudioDevicesPrefHandler() {} 67 virtual ~AudioDevicesPrefHandler() {}
51 68
52 private: 69 private:
53 friend class base::RefCountedThreadSafe<AudioDevicesPrefHandler>; 70 friend class base::RefCountedThreadSafe<AudioDevicesPrefHandler>;
54 }; 71 };
55 72
56 } // namespace chromeos 73 } // namespace chromeos
57 74
58 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_ 75 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698