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_AUDIO_DEVICE_H_ | 5 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| 6 #define CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 6 #define CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 AUDIO_TYPE_USB, | 22 AUDIO_TYPE_USB, |
| 23 AUDIO_TYPE_BLUETOOTH, | 23 AUDIO_TYPE_BLUETOOTH, |
| 24 AUDIO_TYPE_HDMI, | 24 AUDIO_TYPE_HDMI, |
| 25 AUDIO_TYPE_INTERNAL_SPEAKER, | 25 AUDIO_TYPE_INTERNAL_SPEAKER, |
| 26 AUDIO_TYPE_INTERNAL_MIC, | 26 AUDIO_TYPE_INTERNAL_MIC, |
| 27 AUDIO_TYPE_KEYBOARD_MIC, | 27 AUDIO_TYPE_KEYBOARD_MIC, |
| 28 AUDIO_TYPE_OTHER, | 28 AUDIO_TYPE_OTHER, |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 struct CHROMEOS_EXPORT AudioDevice { | 31 struct CHROMEOS_EXPORT AudioDevice { |
| 32 AudioDevice(); | |
|
James Cook
2014/08/28 18:48:37
Thanks for fixing stuff like this.
| |
| 33 explicit AudioDevice(const AudioNode& node); | |
| 34 std::string ToString() const; | |
| 35 | |
| 36 // Converts between the string type sent via D-Bus and AudioDeviceType. | |
| 37 // Static so they can be used by tests. | |
| 38 static std::string GetTypeString(chromeos::AudioDeviceType type); | |
| 39 static chromeos::AudioDeviceType GetAudioType(const std::string& node_type); | |
| 40 | |
| 32 bool is_input; | 41 bool is_input; |
| 33 uint64 id; | 42 uint64 id; |
| 34 std::string display_name; | 43 std::string display_name; |
| 35 std::string device_name; | 44 std::string device_name; |
| 36 AudioDeviceType type; | 45 AudioDeviceType type; |
| 37 uint8 priority; | 46 uint8 priority; |
| 38 bool active; | 47 bool active; |
| 39 uint64 plugged_time; | 48 uint64 plugged_time; |
| 40 | |
| 41 AudioDevice(); | |
| 42 explicit AudioDevice(const AudioNode& node); | |
| 43 std::string ToString() const; | |
| 44 }; | 49 }; |
| 45 | 50 |
| 46 typedef std::vector<AudioDevice> AudioDeviceList; | 51 typedef std::vector<AudioDevice> AudioDeviceList; |
| 47 typedef std::map<uint64, AudioDevice> AudioDeviceMap; | 52 typedef std::map<uint64, AudioDevice> AudioDeviceMap; |
| 48 | 53 |
| 49 struct AudioDeviceCompare { | 54 struct AudioDeviceCompare { |
| 50 // Rules used to discern which device is higher, | 55 // Rules used to discern which device is higher, |
| 51 // 1.) Device Type: | 56 // 1.) Device Type: |
| 52 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers] | 57 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers] |
| 53 // [External Mic/USB Mic/Bluetooth > Internal Mic] | 58 // [External Mic/USB Mic/Bluetooth > Internal Mic] |
| 54 // 2.) Device Plugged in Time: | 59 // 2.) Device Plugged in Time: |
| 55 // [Later > Earlier] | 60 // [Later > Earlier] |
| 56 bool operator()(const chromeos::AudioDevice& a, | 61 bool operator()(const chromeos::AudioDevice& a, |
| 57 const chromeos::AudioDevice& b) const { | 62 const chromeos::AudioDevice& b) const { |
| 58 if (a.priority < b.priority) { | 63 if (a.priority < b.priority) { |
| 59 return true; | 64 return true; |
| 60 } else if (b.priority < a.priority) { | 65 } else if (b.priority < a.priority) { |
| 61 return false; | 66 return false; |
| 62 } else if (a.plugged_time < b.plugged_time) { | 67 } else if (a.plugged_time < b.plugged_time) { |
| 63 return true; | 68 return true; |
| 64 } else { | 69 } else { |
| 65 return false; | 70 return false; |
| 66 } | 71 } |
| 67 } | 72 } |
| 68 }; | 73 }; |
| 69 | 74 |
| 70 } // namespace chromeos | 75 } // namespace chromeos |
| 71 | 76 |
| 72 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 77 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| OLD | NEW |