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

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

Issue 14801002: Switch Audio Preferences to per device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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_CRAS_AUDIO_HANDLER_H_ 5 #ifndef CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_
6 #define CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ 6 #define CHROMEOS_AUDIO_CRAS_AUDIO_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 "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "chromeos/audio/audio_device.h" 12 #include "chromeos/audio/audio_device.h"
13 #include "chromeos/audio/audio_pref_observer.h" 13 #include "chromeos/audio/audio_pref_observer.h"
14 #include "chromeos/dbus/audio_node.h" 14 #include "chromeos/dbus/audio_node.h"
15 #include "chromeos/dbus/cras_audio_client.h" 15 #include "chromeos/dbus/cras_audio_client.h"
16 #include "chromeos/dbus/volume_state.h" 16 #include "chromeos/dbus/volume_state.h"
17 17
18 class PrefRegistrySimple; 18 class PrefRegistrySimple;
19 class PrefService; 19 class PrefService;
20 20
21 namespace chromeos { 21 namespace chromeos {
22 22
23 class AudioPrefHandler; 23 class AudioDevicesPrefHandler;
24 24
25 class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, 25 class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
26 public AudioPrefObserver { 26 public AudioPrefObserver {
27 public: 27 public:
28 class AudioObserver { 28 class AudioObserver {
29 public: 29 public:
30 // Called when output volume changed. 30 // Called when output volume changed.
31 virtual void OnOutputVolumeChanged(); 31 virtual void OnOutputVolumeChanged();
32 32
33 // Called when output mute state changed. 33 // Called when output mute state changed.
(...skipping 11 matching lines...) Expand all
45 // Called when active audio input node changed. 45 // Called when active audio input node changed.
46 virtual void OnActiveInputNodeChanged(); 46 virtual void OnActiveInputNodeChanged();
47 47
48 protected: 48 protected:
49 AudioObserver(); 49 AudioObserver();
50 virtual ~AudioObserver(); 50 virtual ~AudioObserver();
51 DISALLOW_COPY_AND_ASSIGN(AudioObserver); 51 DISALLOW_COPY_AND_ASSIGN(AudioObserver);
52 }; 52 };
53 53
54 // Sets the global instance. Must be called before any calls to Get(). 54 // Sets the global instance. Must be called before any calls to Get().
55 static void Initialize(scoped_refptr<AudioPrefHandler> audio_pref_handler); 55 static void Initialize(
56 scoped_refptr<AudioDevicesPrefHandler>audio_pref_handler);
Pam (message me for reviews) 2013/05/02 15:11:40 Please restore the space after the >
rkc 2013/05/02 18:46:09 Done.
56 57
57 // Sets the global instance for testing. 58 // Sets the global instance for testing.
58 static void InitializeForTesting(); 59 static void InitializeForTesting();
59 60
60 // Destroys the global instance. 61 // Destroys the global instance.
61 static void Shutdown(); 62 static void Shutdown();
62 63
63 // Returns true if the global instance is initialized. 64 // Returns true if the global instance is initialized.
64 static bool IsInitialized(); 65 static bool IsInitialized();
65 66
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // Mutes or unmutes audio input device. 111 // Mutes or unmutes audio input device.
111 virtual void SetInputMute(bool mute_on); 112 virtual void SetInputMute(bool mute_on);
112 113
113 // Sets the active audio output node to the node with |node_id|. 114 // Sets the active audio output node to the node with |node_id|.
114 virtual void SetActiveOutputNode(uint64 node_id); 115 virtual void SetActiveOutputNode(uint64 node_id);
115 116
116 // Sets the active audio input node to the node with |node_id|. 117 // Sets the active audio input node to the node with |node_id|.
117 virtual void SetActiveInputNode(uint64 node_id); 118 virtual void SetActiveInputNode(uint64 node_id);
118 119
119 protected: 120 protected:
120 explicit CrasAudioHandler(scoped_refptr<AudioPrefHandler> audio_pref_handler); 121 explicit CrasAudioHandler(
122 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler);
121 virtual ~CrasAudioHandler(); 123 virtual ~CrasAudioHandler();
122 124
123 private: 125 private:
124 // Overriden from CrasAudioHandler::Observer. 126 // Overriden from CrasAudioHandler::Observer.
125 virtual void AudioClientRestarted() OVERRIDE; 127 virtual void AudioClientRestarted() OVERRIDE;
126 virtual void OutputVolumeChanged(int volume) OVERRIDE; 128 virtual void OutputVolumeChanged(int volume) OVERRIDE;
127 virtual void OutputMuteChanged(bool mute_on) OVERRIDE; 129 virtual void OutputMuteChanged(bool mute_on) OVERRIDE;
128 virtual void InputMuteChanged(bool mute_on) OVERRIDE; 130 virtual void InputMuteChanged(bool mute_on) OVERRIDE;
129 virtual void NodesChanged() OVERRIDE; 131 virtual void NodesChanged() OVERRIDE;
130 virtual void ActiveOutputNodeChanged(uint64 node_id) OVERRIDE; 132 virtual void ActiveOutputNodeChanged(uint64 node_id) OVERRIDE;
131 virtual void ActiveInputNodeChanged(uint64 node_id) OVERRIDE; 133 virtual void ActiveInputNodeChanged(uint64 node_id) OVERRIDE;
132 134
133 // Overriden from AudioPrefObserver. 135 // Overriden from AudioPrefObserver.
134 virtual void OnAudioPolicyPrefChanged() OVERRIDE; 136 virtual void OnAudioPolicyPrefChanged() OVERRIDE;
135 137
136 // Sets up the initial audio device state based on audio policy and 138 // Sets up the audio device state based on audio policy and audio settings
137 // audio settings saved in prefs. 139 // saved in prefs.
138 void SetupInitialAudioState(); 140 void SetupAudioState();
139 141
140 // Applies the audio muting policies whenever the user logs in or policy 142 // Applies the audio muting policies whenever the user logs in or policy
141 // change notification is received. 143 // change notification is received.
142 void ApplyAudioPolicy(); 144 void ApplyAudioPolicy();
143 145
144 // Sets output volume to specified value and notifies observers. 146 // Sets output volume to specified value and notifies observers.
145 void SetOutputVolumeInternal(int volume); 147 void SetOutputVolumeInternal(int volume);
146 148
147 // Calling dbus to get nodes data. 149 // Calling dbus to get nodes data.
148 void GetNodes(); 150 void GetNodes();
149 151
150 // Handles dbus callback for GetNodes. 152 // Handles dbus callback for GetNodes.
151 void HandleGetNodes(const chromeos::AudioNodeList& node_list, bool success); 153 void HandleGetNodes(const chromeos::AudioNodeList& node_list, bool success);
152 154
153 scoped_refptr<AudioPrefHandler> audio_pref_handler_; 155 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_;
154 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; 156 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_;
155 ObserverList<AudioObserver> observers_; 157 ObserverList<AudioObserver> observers_;
156 158
157 // Audio data and state. 159 // Audio data and state.
158 AudioDeviceList audio_devices_; 160 AudioDeviceList audio_devices_;
159 VolumeState volume_state_; 161 VolumeState volume_state_;
160 bool output_mute_on_; 162 bool output_mute_on_;
161 bool input_mute_on_; 163 bool input_mute_on_;
162 int output_volume_; 164 int output_volume_;
163 uint64 active_output_node_id_; 165 uint64 active_output_node_id_;
164 uint64 active_input_node_id_; 166 uint64 active_input_node_id_;
165 bool has_alternative_input_; 167 bool has_alternative_input_;
166 bool has_alternative_output_; 168 bool has_alternative_output_;
167 169
168 bool output_mute_locked_; 170 bool output_mute_locked_;
169 bool input_mute_locked_; 171 bool input_mute_locked_;
170 172
171 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); 173 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler);
172 }; 174 };
173 175
174 } // namespace chromeos 176 } // namespace chromeos
175 177
176 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ 178 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698