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" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 uint64* current_active_node_id); | 262 uint64* current_active_node_id); |
263 | 263 |
264 // Returns true if the audio nodes change is caused by some non-active | 264 // Returns true if the audio nodes change is caused by some non-active |
265 // audio nodes unplugged. | 265 // audio nodes unplugged. |
266 bool NonActiveDeviceUnplugged(size_t old_devices_size, | 266 bool NonActiveDeviceUnplugged(size_t old_devices_size, |
267 size_t new_device_size, | 267 size_t new_device_size, |
268 uint64 current_active_node); | 268 uint64 current_active_node); |
269 | 269 |
270 // Returns true if there is any device change for for input or output, | 270 // Returns true if there is any device change for for input or output, |
271 // specified by |is_input|. | 271 // specified by |is_input|. |
272 bool HasDeviceChange(const AudioNodeList& new_nodes, bool is_input); | 272 // The new discovered nodes are returned in |new_discovered|. |
| 273 bool HasDeviceChange(const AudioNodeList& new_nodes, |
| 274 bool is_input, |
| 275 AudioNodeList* new_discovered); |
273 | 276 |
274 // Handles dbus callback for GetNodes. | 277 // Handles dbus callback for GetNodes. |
275 void HandleGetNodes(const chromeos::AudioNodeList& node_list, bool success); | 278 void HandleGetNodes(const chromeos::AudioNodeList& node_list, bool success); |
276 | 279 |
277 // Handles the dbus error callback. | 280 // Handles the dbus error callback. |
278 void HandleGetNodesError(const std::string& error_name, | 281 void HandleGetNodesError(const std::string& error_name, |
279 const std::string& error_msg); | 282 const std::string& error_msg); |
280 | 283 |
281 // Adds an active node. | 284 // Adds an active node. |
282 // If there is no active node, |node_id| will be switched to become the | 285 // If there is no active node, |node_id| will be switched to become the |
283 // primary active node. Otherwise, it will be added as an additional active | 286 // primary active node. Otherwise, it will be added as an additional active |
284 // node. | 287 // node. |
285 void AddActiveNode(uint64 node_id, bool notify); | 288 void AddActiveNode(uint64 node_id, bool notify); |
286 | 289 |
287 // Adds |node_id| into additional active nodes. | 290 // Adds |node_id| into additional active nodes. |
288 void AddAdditionalActiveNode(uint64 node_id, bool notify); | 291 void AddAdditionalActiveNode(uint64 node_id, bool notify); |
289 | 292 |
290 // Removes |node_id| from additional active nodes. | 293 // Removes |node_id| from additional active nodes. |
291 void RemoveActiveNodeInternal(uint64 node_id, bool notify); | 294 void RemoveActiveNodeInternal(uint64 node_id, bool notify); |
292 | 295 |
293 // Returns true if |device| is not found in audio_devices_, or it is found | 296 enum DeviceStatus { |
294 // but changed its |active| property. | 297 OLD_DEVICE, |
295 bool FoundNewOrChangedDevice(const AudioDevice& device); | 298 NEW_DEVICE, |
| 299 CHANGED_DEVICE, |
| 300 }; |
| 301 |
| 302 // Checks if |device| is a newly discovered, changed, or existing device for |
| 303 // the nodes sent from NodesChanged signal. |
| 304 DeviceStatus CheckDeviceStatus(const AudioDevice& device); |
296 | 305 |
297 void NotifyActiveNodeChanged(bool is_input); | 306 void NotifyActiveNodeChanged(bool is_input); |
298 | 307 |
299 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_; | 308 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_; |
300 ObserverList<AudioObserver> observers_; | 309 ObserverList<AudioObserver> observers_; |
301 | 310 |
302 // Audio data and state. | 311 // Audio data and state. |
303 AudioDeviceMap audio_devices_; | 312 AudioDeviceMap audio_devices_; |
304 | 313 |
305 AudioDevicePriorityQueue input_devices_pq_; | 314 AudioDevicePriorityQueue input_devices_pq_; |
(...skipping 14 matching lines...) Expand all Loading... |
320 bool log_errors_; | 329 bool log_errors_; |
321 | 330 |
322 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; | 331 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; |
323 | 332 |
324 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); | 333 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); |
325 }; | 334 }; |
326 | 335 |
327 } // namespace chromeos | 336 } // namespace chromeos |
328 | 337 |
329 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ | 338 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ |
OLD | NEW |