Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 156 protected: | 158 protected: |
| 157 explicit CrasAudioHandler( | 159 explicit CrasAudioHandler( |
| 158 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); | 160 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); |
| 159 virtual ~CrasAudioHandler(); | 161 virtual ~CrasAudioHandler(); |
| 160 | 162 |
| 161 private: | 163 private: |
| 162 // Overriden from CrasAudioClient::Observer. | 164 // CrasAudioClient::Observer overrides. |
| 163 virtual void AudioClientRestarted() OVERRIDE; | 165 virtual void AudioClientRestarted() OVERRIDE; |
| 164 virtual void NodesChanged() OVERRIDE; | 166 virtual void NodesChanged() OVERRIDE; |
| 165 virtual void ActiveOutputNodeChanged(uint64 node_id) OVERRIDE; | 167 virtual void ActiveOutputNodeChanged(uint64 node_id) OVERRIDE; |
| 166 virtual void ActiveInputNodeChanged(uint64 node_id) OVERRIDE; | 168 virtual void ActiveInputNodeChanged(uint64 node_id) OVERRIDE; |
| 167 | 169 |
| 168 // Overriden from AudioPrefObserver. | 170 // AudioPrefObserver overrides. |
| 169 virtual void OnAudioPolicyPrefChanged() OVERRIDE; | 171 virtual void OnAudioPolicyPrefChanged() OVERRIDE; |
| 170 | 172 |
| 173 // SessionManagerClient::Observer overrides. | |
| 174 virtual void EmitLoginPromptVisibleCalled() OVERRIDE; | |
| 175 | |
| 171 // Sets the active audio output/input node to the node with |node_id|. | 176 // Sets the active audio output/input node to the node with |node_id|. |
| 172 void SetActiveOutputNode(uint64 node_id); | 177 void SetActiveOutputNode(uint64 node_id); |
| 173 void SetActiveInputNode(uint64 node_id); | 178 void SetActiveInputNode(uint64 node_id); |
| 174 | 179 |
| 175 // Sets up the audio device state based on audio policy and audio settings | 180 // Sets up the audio device state based on audio policy and audio settings |
| 176 // saved in prefs. | 181 // saved in prefs. |
| 177 void SetupAudioInputState(); | 182 void SetupAudioInputState(); |
| 178 void SetupAudioOutputState(); | 183 void SetupAudioOutputState(); |
| 179 | 184 |
| 180 const AudioDevice* GetDeviceFromId(uint64 device_id) const; | 185 const AudioDevice* GetDeviceFromId(uint64 device_id) const; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 size_t new_device_size, | 224 size_t new_device_size, |
| 220 uint64 current_active_node); | 225 uint64 current_active_node); |
| 221 | 226 |
| 222 // Returns true if there is any device change for for input or output, | 227 // Returns true if there is any device change for for input or output, |
| 223 // specified by |is_input|. | 228 // specified by |is_input|. |
| 224 bool HasDeviceChange(const AudioNodeList& new_nodes, bool is_input); | 229 bool HasDeviceChange(const AudioNodeList& new_nodes, bool is_input); |
| 225 | 230 |
| 226 // Handles dbus callback for GetNodes. | 231 // Handles dbus callback for GetNodes. |
| 227 void HandleGetNodes(const chromeos::AudioNodeList& node_list, bool success); | 232 void HandleGetNodes(const chromeos::AudioNodeList& node_list, bool success); |
| 228 | 233 |
| 234 // Handles the dbus error callback. | |
| 235 void HandleGetNodesError(const std::string& error_name, | |
| 236 const std::string& error_msg); | |
| 237 | |
| 229 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_; | 238 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_; |
| 230 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; | 239 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; |
| 231 ObserverList<AudioObserver> observers_; | 240 ObserverList<AudioObserver> observers_; |
| 232 | 241 |
| 233 // Audio data and state. | 242 // Audio data and state. |
| 234 AudioDeviceMap audio_devices_; | 243 AudioDeviceMap audio_devices_; |
| 235 | 244 |
| 236 AudioDevicePriorityQueue input_devices_pq_; | 245 AudioDevicePriorityQueue input_devices_pq_; |
| 237 AudioDevicePriorityQueue output_devices_pq_; | 246 AudioDevicePriorityQueue output_devices_pq_; |
| 238 | 247 |
| 239 bool output_mute_on_; | 248 bool output_mute_on_; |
| 240 bool input_mute_on_; | 249 bool input_mute_on_; |
| 241 int output_volume_; | 250 int output_volume_; |
| 242 int input_gain_; | 251 int input_gain_; |
| 243 uint64 active_output_node_id_; | 252 uint64 active_output_node_id_; |
| 244 uint64 active_input_node_id_; | 253 uint64 active_input_node_id_; |
| 245 bool has_alternative_input_; | 254 bool has_alternative_input_; |
| 246 bool has_alternative_output_; | 255 bool has_alternative_output_; |
| 247 | 256 |
| 248 bool output_mute_locked_; | 257 bool output_mute_locked_; |
| 249 bool input_mute_locked_; | 258 bool input_mute_locked_; |
| 250 | 259 |
| 260 bool enable_log_; | |
|
Daniel Erat
2013/09/12 21:10:05
nit: add a brief comment like:
// Failures are no
jennyz
2013/09/12 22:34:45
Done.
| |
| 261 | |
| 251 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); | 262 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); |
| 252 }; | 263 }; |
| 253 | 264 |
| 254 } // namespace chromeos | 265 } // namespace chromeos |
| 255 | 266 |
| 256 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ | 267 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ |
| OLD | NEW |