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

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

Issue 23444057: Reduce chrome cras dbus call logs during device rebooting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename EnableLog Created 7 years, 3 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 <queue> 8 #include <queue>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chromeos/audio/audio_device.h" 14 #include "chromeos/audio/audio_device.h"
15 #include "chromeos/audio/audio_pref_observer.h" 15 #include "chromeos/audio/audio_pref_observer.h"
16 #include "chromeos/dbus/audio_node.h" 16 #include "chromeos/dbus/audio_node.h"
17 #include "chromeos/dbus/cras_audio_client.h" 17 #include "chromeos/dbus/cras_audio_client.h"
18 #include "chromeos/dbus/session_manager_client.h"
18 #include "chromeos/dbus/volume_state.h" 19 #include "chromeos/dbus/volume_state.h"
19 20
20 class PrefRegistrySimple; 21 class PrefRegistrySimple;
21 class PrefService; 22 class PrefService;
22 23
23 namespace chromeos { 24 namespace chromeos {
24 25
25 class AudioDevicesPrefHandler; 26 class AudioDevicesPrefHandler;
26 27
27 class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, 28 class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
28 public AudioPrefObserver { 29 public AudioPrefObserver,
30 public SessionManagerClient::Observer {
29 public: 31 public:
30 typedef std::priority_queue<AudioDevice, 32 typedef std::priority_queue<AudioDevice,
31 std::vector<AudioDevice>, 33 std::vector<AudioDevice>,
32 AudioDeviceCompare> AudioDevicePriorityQueue; 34 AudioDeviceCompare> AudioDevicePriorityQueue;
33 35
34 class AudioObserver { 36 class AudioObserver {
35 public: 37 public:
36 // Called when output volume changed. 38 // Called when output volume changed.
37 virtual void OnOutputVolumeChanged(); 39 virtual void OnOutputVolumeChanged();
38 40
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 148
147 // Switches active audio device to |device|. 149 // Switches active audio device to |device|.
148 virtual void SwitchToDevice(const AudioDevice& device); 150 virtual void SwitchToDevice(const AudioDevice& device);
149 151
150 // Sets volume/gain level for a device. 152 // Sets volume/gain level for a device.
151 virtual void SetVolumeGainPercentForDevice(uint64 device_id, int value); 153 virtual void SetVolumeGainPercentForDevice(uint64 device_id, int value);
152 154
153 // Sets the mute for device. 155 // Sets the mute for device.
154 virtual void SetMuteForDevice(uint64 device_id, bool mute_on); 156 virtual void SetMuteForDevice(uint64 device_id, bool mute_on);
155 157
158 // Enables error logging.
159 virtual void LogErrors();
160
156 protected: 161 protected:
157 explicit CrasAudioHandler( 162 explicit CrasAudioHandler(
158 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); 163 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler);
159 virtual ~CrasAudioHandler(); 164 virtual ~CrasAudioHandler();
160 165
161 private: 166 private:
162 // Overriden from CrasAudioClient::Observer. 167 // CrasAudioClient::Observer overrides.
163 virtual void AudioClientRestarted() OVERRIDE; 168 virtual void AudioClientRestarted() OVERRIDE;
164 virtual void NodesChanged() OVERRIDE; 169 virtual void NodesChanged() OVERRIDE;
165 virtual void ActiveOutputNodeChanged(uint64 node_id) OVERRIDE; 170 virtual void ActiveOutputNodeChanged(uint64 node_id) OVERRIDE;
166 virtual void ActiveInputNodeChanged(uint64 node_id) OVERRIDE; 171 virtual void ActiveInputNodeChanged(uint64 node_id) OVERRIDE;
167 172
168 // Overriden from AudioPrefObserver. 173 // AudioPrefObserver overrides.
169 virtual void OnAudioPolicyPrefChanged() OVERRIDE; 174 virtual void OnAudioPolicyPrefChanged() OVERRIDE;
170 175
176 // SessionManagerClient::Observer overrides.
177 virtual void EmitLoginPromptVisibleCalled() OVERRIDE;
178
171 // Sets the active audio output/input node to the node with |node_id|. 179 // Sets the active audio output/input node to the node with |node_id|.
172 void SetActiveOutputNode(uint64 node_id); 180 void SetActiveOutputNode(uint64 node_id);
173 void SetActiveInputNode(uint64 node_id); 181 void SetActiveInputNode(uint64 node_id);
174 182
175 // Sets up the audio device state based on audio policy and audio settings 183 // Sets up the audio device state based on audio policy and audio settings
176 // saved in prefs. 184 // saved in prefs.
177 void SetupAudioInputState(); 185 void SetupAudioInputState();
178 void SetupAudioOutputState(); 186 void SetupAudioOutputState();
179 187
180 const AudioDevice* GetDeviceFromId(uint64 device_id) const; 188 const AudioDevice* GetDeviceFromId(uint64 device_id) const;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 size_t new_device_size, 227 size_t new_device_size,
220 uint64 current_active_node); 228 uint64 current_active_node);
221 229
222 // Returns true if there is any device change for for input or output, 230 // Returns true if there is any device change for for input or output,
223 // specified by |is_input|. 231 // specified by |is_input|.
224 bool HasDeviceChange(const AudioNodeList& new_nodes, bool is_input); 232 bool HasDeviceChange(const AudioNodeList& new_nodes, bool is_input);
225 233
226 // Handles dbus callback for GetNodes. 234 // Handles dbus callback for GetNodes.
227 void HandleGetNodes(const chromeos::AudioNodeList& node_list, bool success); 235 void HandleGetNodes(const chromeos::AudioNodeList& node_list, bool success);
228 236
237 // Handles the dbus error callback.
238 void HandleGetNodesError(const std::string& error_name,
239 const std::string& error_msg);
240
229 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_; 241 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_;
230 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; 242 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_;
231 ObserverList<AudioObserver> observers_; 243 ObserverList<AudioObserver> observers_;
232 244
233 // Audio data and state. 245 // Audio data and state.
234 AudioDeviceMap audio_devices_; 246 AudioDeviceMap audio_devices_;
235 247
236 AudioDevicePriorityQueue input_devices_pq_; 248 AudioDevicePriorityQueue input_devices_pq_;
237 AudioDevicePriorityQueue output_devices_pq_; 249 AudioDevicePriorityQueue output_devices_pq_;
238 250
239 bool output_mute_on_; 251 bool output_mute_on_;
240 bool input_mute_on_; 252 bool input_mute_on_;
241 int output_volume_; 253 int output_volume_;
242 int input_gain_; 254 int input_gain_;
243 uint64 active_output_node_id_; 255 uint64 active_output_node_id_;
244 uint64 active_input_node_id_; 256 uint64 active_input_node_id_;
245 bool has_alternative_input_; 257 bool has_alternative_input_;
246 bool has_alternative_output_; 258 bool has_alternative_output_;
247 259
248 bool output_mute_locked_; 260 bool output_mute_locked_;
249 bool input_mute_locked_; 261 bool input_mute_locked_;
250 262
263 // Failures are not logged at startup, since CRAS may not be running yet.
264 bool log_errors_;
265
251 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); 266 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler);
252 }; 267 };
253 268
254 } // namespace chromeos 269 } // namespace chromeos
255 270
256 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ 271 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/audio/audio_service_chromeos.cc ('k') | chromeos/audio/cras_audio_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698