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

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: Fix string format 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
« no previous file with comments | « chromeos/audio/audio_device.cc ('k') | chromeos/audio/audio_devices_pref_handler_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Note that these states enum can't be renumbered or it would break existing
25 // preference.
26 enum AudioDeviceState {
27 AUDIO_STATE_ACTIVE = 0,
28 AUDIO_STATE_INACTIVE = 1,
29 AUDIO_STATE_NOT_AVAILABLE = 2,
30 };
31
18 // Interface that handles audio preference related work, reads and writes 32 // Interface that handles audio preference related work, reads and writes
19 // audio preferences, and notifies AudioPrefObserver for audio preference 33 // audio preferences, and notifies AudioPrefObserver for audio preference
20 // changes. 34 // changes.
21 class CHROMEOS_EXPORT AudioDevicesPrefHandler 35 class CHROMEOS_EXPORT AudioDevicesPrefHandler
22 : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> { 36 : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> {
23 public: 37 public:
24 // Integer because C++ does not allow static const double in header files. 38 // Integer because C++ does not allow static const double in header files.
25 static const int kDefaultOutputVolumePercent = 75; 39 static const int kDefaultOutputVolumePercent = 75;
26 static const int kDefaultHdmiOutputVolumePercent = 100; 40 static const int kDefaultHdmiOutputVolumePercent = 100;
27 41
28 // Gets the audio output volume value from prefs for a device. Since we can 42 // 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 43 // 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. 44 // is input or output), we don't really care which value it is.
31 virtual double GetOutputVolumeValue(const AudioDevice* device) = 0; 45 virtual double GetOutputVolumeValue(const AudioDevice* device) = 0;
32 virtual double GetInputGainValue(const AudioDevice* device) = 0; 46 virtual double GetInputGainValue(const AudioDevice* device) = 0;
33 // Sets the audio volume or gain value to prefs for a device. 47 // Sets the audio volume or gain value to prefs for a device.
34 virtual void SetVolumeGainValue(const AudioDevice& device, double value) = 0; 48 virtual void SetVolumeGainValue(const AudioDevice& device, double value) = 0;
35 49
36 // Reads the audio mute value from prefs for a device. 50 // Reads the audio mute value from prefs for a device.
37 virtual bool GetMuteValue(const AudioDevice& device) = 0; 51 virtual bool GetMuteValue(const AudioDevice& device) = 0;
38 // Sets the audio mute value to prefs for a device. 52 // Sets the audio mute value to prefs for a device.
39 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) = 0; 53 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) = 0;
40 54
55 virtual AudioDeviceState GetDeviceState(const AudioDevice& device) = 0;
56 virtual void SetDeviceState(const AudioDevice& device,
57 AudioDeviceState state) = 0;
58
41 // Reads the audio output allowed value from prefs. 59 // Reads the audio output allowed value from prefs.
42 virtual bool GetAudioOutputAllowedValue() = 0; 60 virtual bool GetAudioOutputAllowedValue() = 0;
43 61
44 // Adds an audio preference observer. 62 // Adds an audio preference observer.
45 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0; 63 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0;
46 // Removes an audio preference observer. 64 // Removes an audio preference observer.
47 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0; 65 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0;
48 66
49 protected: 67 protected:
50 virtual ~AudioDevicesPrefHandler() {} 68 virtual ~AudioDevicesPrefHandler() {}
51 69
52 private: 70 private:
53 friend class base::RefCountedThreadSafe<AudioDevicesPrefHandler>; 71 friend class base::RefCountedThreadSafe<AudioDevicesPrefHandler>;
54 }; 72 };
55 73
56 } // namespace chromeos 74 } // namespace chromeos
57 75
58 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_ 76 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_
OLDNEW
« no previous file with comments | « chromeos/audio/audio_device.cc ('k') | chromeos/audio/audio_devices_pref_handler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698