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 <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <string> | 11 #include <string> |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
12 #include "base/basictypes.h" | |
13 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
14 #include "chromeos/dbus/audio_node.h" | 15 #include "chromeos/dbus/audio_node.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 // Ordered from the highest priority to the lowest. | 19 // Ordered from the highest priority to the lowest. |
19 enum AudioDeviceType { | 20 enum AudioDeviceType { |
20 AUDIO_TYPE_HEADPHONE, | 21 AUDIO_TYPE_HEADPHONE, |
21 AUDIO_TYPE_MIC, | 22 AUDIO_TYPE_MIC, |
22 AUDIO_TYPE_USB, | 23 AUDIO_TYPE_USB, |
(...skipping 26 matching lines...) Expand all Loading... |
49 return (type == AUDIO_TYPE_HEADPHONE || | 50 return (type == AUDIO_TYPE_HEADPHONE || |
50 type == AUDIO_TYPE_INTERNAL_MIC || | 51 type == AUDIO_TYPE_INTERNAL_MIC || |
51 type == AUDIO_TYPE_MIC || | 52 type == AUDIO_TYPE_MIC || |
52 type == AUDIO_TYPE_USB || | 53 type == AUDIO_TYPE_USB || |
53 type == AUDIO_TYPE_BLUETOOTH || | 54 type == AUDIO_TYPE_BLUETOOTH || |
54 type == AUDIO_TYPE_HDMI || | 55 type == AUDIO_TYPE_HDMI || |
55 type == AUDIO_TYPE_INTERNAL_SPEAKER); | 56 type == AUDIO_TYPE_INTERNAL_SPEAKER); |
56 } | 57 } |
57 | 58 |
58 bool is_input; | 59 bool is_input; |
59 uint64 id; | 60 uint64_t id; |
60 std::string display_name; | 61 std::string display_name; |
61 std::string device_name; | 62 std::string device_name; |
62 std::string mic_positions; | 63 std::string mic_positions; |
63 AudioDeviceType type; | 64 AudioDeviceType type; |
64 uint8 priority; | 65 uint8_t priority; |
65 bool active; | 66 bool active; |
66 uint64 plugged_time; | 67 uint64_t plugged_time; |
67 }; | 68 }; |
68 | 69 |
69 typedef std::vector<AudioDevice> AudioDeviceList; | 70 typedef std::vector<AudioDevice> AudioDeviceList; |
70 typedef std::map<uint64, AudioDevice> AudioDeviceMap; | 71 typedef std::map<uint64_t, AudioDevice> AudioDeviceMap; |
71 | 72 |
72 struct AudioDeviceCompare { | 73 struct AudioDeviceCompare { |
73 // Rules used to discern which device is higher, | 74 // Rules used to discern which device is higher, |
74 // 1.) Device Type: | 75 // 1.) Device Type: |
75 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers] | 76 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers] |
76 // [External Mic/USB Mic/Bluetooth > Internal Mic] | 77 // [External Mic/USB Mic/Bluetooth > Internal Mic] |
77 // 2.) Device Plugged in Time: | 78 // 2.) Device Plugged in Time: |
78 // [Later > Earlier] | 79 // [Later > Earlier] |
79 bool operator()(const chromeos::AudioDevice& a, | 80 bool operator()(const chromeos::AudioDevice& a, |
80 const chromeos::AudioDevice& b) const { | 81 const chromeos::AudioDevice& b) const { |
81 if (a.priority < b.priority) { | 82 if (a.priority < b.priority) { |
82 return true; | 83 return true; |
83 } else if (b.priority < a.priority) { | 84 } else if (b.priority < a.priority) { |
84 return false; | 85 return false; |
85 } else if (a.plugged_time < b.plugged_time) { | 86 } else if (a.plugged_time < b.plugged_time) { |
86 return true; | 87 return true; |
87 } else { | 88 } else { |
88 return false; | 89 return false; |
89 } | 90 } |
90 } | 91 } |
91 }; | 92 }; |
92 | 93 |
93 } // namespace chromeos | 94 } // namespace chromeos |
94 | 95 |
95 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 96 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
OLD | NEW |