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

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 5 years, 2 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/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "chromeos/audio/audio_pref_observer.h" 10 #include "chromeos/audio/audio_pref_observer.h"
11 #include "chromeos/chromeos_export.h" 11 #include "chromeos/chromeos_export.h"
12 12
13 class PrefService; 13 class PrefService;
14 14
15 namespace chromeos { 15 namespace chromeos {
16 16
17 struct AudioDevice; 17 struct AudioDevice;
18 18
19 // Used to represent an audio device's state. This state should be updated
20 // to AUDIO_STATE_ACTIVE when it is selected as active or set to
21 // AUDIO_STATE_INACTIVE when selected to a different device. When the audio
22 // device is unplugged, its last active/inactive state should be stored.
23 // At the first time an audio device got plugged, use AUDIO_STATE_NOT_AVAILABLE
24 // as its default state value.
jennyz 2015/12/17 22:50:21 Any specific reason to use AUDIO_STATE_NOT_AVAILAB
hychao 2015/12/29 10:57:25 Updated as you suggested in another comment. Thank
25 enum AudioDeviceState {
26 AUDIO_STATE_ACTIVE,
27 AUDIO_STATE_INACTIVE,
28 AUDIO_STATE_NOT_AVAILABLE,
29 };
30
19 // Interface that handles audio preference related work, reads and writes 31 // Interface that handles audio preference related work, reads and writes
20 // audio preferences, and notifies AudioPrefObserver for audio preference 32 // audio preferences, and notifies AudioPrefObserver for audio preference
21 // changes. 33 // changes.
22 class CHROMEOS_EXPORT AudioDevicesPrefHandler 34 class CHROMEOS_EXPORT AudioDevicesPrefHandler
23 : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> { 35 : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> {
24 public: 36 public:
25 // Integer because C++ does not allow static const double in header files. 37 // Integer because C++ does not allow static const double in header files.
26 static const int kDefaultOutputVolumePercent = 75; 38 static const int kDefaultOutputVolumePercent = 75;
27 static const int kDefaultHdmiOutputVolumePercent = 100; 39 static const int kDefaultHdmiOutputVolumePercent = 100;
28 40
29 // Gets the audio output volume value from prefs for a device. Since we can 41 // Gets the audio output volume value from prefs for a device. Since we can
30 // only have either a gain or a volume for a device (depending on whether it 42 // only have either a gain or a volume for a device (depending on whether it
31 // is input or output), we don't really care which value it is. 43 // is input or output), we don't really care which value it is.
32 virtual double GetOutputVolumeValue(const AudioDevice* device) = 0; 44 virtual double GetOutputVolumeValue(const AudioDevice* device) = 0;
33 virtual double GetInputGainValue(const AudioDevice* device) = 0; 45 virtual double GetInputGainValue(const AudioDevice* device) = 0;
34 // Sets the audio volume or gain value to prefs for a device. 46 // Sets the audio volume or gain value to prefs for a device.
35 virtual void SetVolumeGainValue(const AudioDevice& device, double value) = 0; 47 virtual void SetVolumeGainValue(const AudioDevice& device, double value) = 0;
36 48
37 // Reads the audio mute value from prefs for a device. 49 // Reads the audio mute value from prefs for a device.
38 virtual bool GetMuteValue(const AudioDevice& device) = 0; 50 virtual bool GetMuteValue(const AudioDevice& device) = 0;
39 // Sets the audio mute value to prefs for a device. 51 // Sets the audio mute value to prefs for a device.
40 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) = 0; 52 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) = 0;
41 53
54 virtual AudioDeviceState GetDeviceState(
55 const AudioDevice &device) = 0;
56 virtual void SetDeviceState(const AudioDevice& device,
57 AudioDeviceState state) = 0;
58
42 // Reads the audio output allowed value from prefs. 59 // Reads the audio output allowed value from prefs.
43 virtual bool GetAudioOutputAllowedValue() = 0; 60 virtual bool GetAudioOutputAllowedValue() = 0;
44 61
45 // Adds an audio preference observer. 62 // Adds an audio preference observer.
46 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0; 63 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0;
47 // Removes an audio preference observer. 64 // Removes an audio preference observer.
48 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0; 65 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0;
49 66
50 protected: 67 protected:
51 virtual ~AudioDevicesPrefHandler() {} 68 virtual ~AudioDevicesPrefHandler() {}
52 69
53 private: 70 private:
54 friend class base::RefCountedThreadSafe<AudioDevicesPrefHandler>; 71 friend class base::RefCountedThreadSafe<AudioDevicesPrefHandler>;
55 }; 72 };
56 73
57 } // namespace chromeos 74 } // namespace chromeos
58 75
59 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_ 76 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698