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 #include "chromeos/audio/audio_device.h" | 5 #include "chromeos/audio/audio_device.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // Get the priority for a particular device type. The priority returned | 14 // Get the priority for a particular device type. The priority returned |
15 // will be between 0 to 3, the higher number meaning a higher priority. | 15 // will be between 0 to 3, the higher number meaning a higher priority. |
16 uint8 GetDevicePriority(chromeos::AudioDeviceType type) { | 16 uint8 GetDevicePriority(chromeos::AudioDeviceType type) { |
17 switch (type) { | 17 switch (type) { |
18 // Fall through. | 18 // Fall through. |
19 case chromeos::AUDIO_TYPE_HEADPHONE: | 19 case chromeos::AUDIO_TYPE_HEADPHONE: |
20 case chromeos::AUDIO_TYPE_MIC: | 20 case chromeos::AUDIO_TYPE_MIC: |
21 case chromeos::AUDIO_TYPE_USB: | 21 case chromeos::AUDIO_TYPE_USB: |
22 case chromeos::AUDIO_TYPE_BLUETOOTH: | 22 case chromeos::AUDIO_TYPE_BLUETOOTH: |
23 return 3; | 23 return 3; |
24 case chromeos::AUDIO_TYPE_HDMI: | 24 case chromeos::AUDIO_TYPE_HDMI: |
25 return 2; | 25 return 2; |
26 // Fall through. | 26 // Fall through. |
James Cook
2014/08/28 18:48:37
Not your bug, but what the heck are these "fall th
Daniel Erat
2014/08/28 23:27:57
beats me; deleted them
| |
27 case chromeos::AUDIO_TYPE_INTERNAL_SPEAKER: | 27 case chromeos::AUDIO_TYPE_INTERNAL_SPEAKER: |
28 case chromeos::AUDIO_TYPE_INTERNAL_MIC: | 28 case chromeos::AUDIO_TYPE_INTERNAL_MIC: |
29 return 1; | 29 return 1; |
30 // Fall through. | 30 // Fall through. |
31 case chromeos::AUDIO_TYPE_KEYBOARD_MIC: | 31 case chromeos::AUDIO_TYPE_KEYBOARD_MIC: |
32 case chromeos::AUDIO_TYPE_OTHER: | 32 case chromeos::AUDIO_TYPE_OTHER: |
33 default: | 33 default: |
34 return 0; | 34 return 0; |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 std::string GetTypeString(chromeos::AudioDeviceType type) { | 38 } // namespace |
39 | |
40 namespace chromeos { | |
41 | |
42 // static | |
43 std::string AudioDevice::GetTypeString(chromeos::AudioDeviceType type) { | |
39 switch (type) { | 44 switch (type) { |
40 case chromeos::AUDIO_TYPE_HEADPHONE: | 45 case chromeos::AUDIO_TYPE_HEADPHONE: |
James Cook
2014/08/28 18:48:36
none of these need "chromeos::" anymore
Also, you
Daniel Erat
2014/08/28 23:27:57
Done.
| |
41 return "HEADPHONE"; | 46 return "HEADPHONE"; |
Daniel Erat
2014/08/28 04:00:29
these strings seem like they should all be constan
jennyz
2014/08/28 17:42:49
Acknowledged.
| |
42 case chromeos::AUDIO_TYPE_MIC: | 47 case chromeos::AUDIO_TYPE_MIC: |
43 return "MIC"; | 48 return "MIC"; |
44 case chromeos::AUDIO_TYPE_USB: | 49 case chromeos::AUDIO_TYPE_USB: |
45 return "USB"; | 50 return "USB"; |
46 case chromeos::AUDIO_TYPE_BLUETOOTH: | 51 case chromeos::AUDIO_TYPE_BLUETOOTH: |
47 return "BLUETOOTH"; | 52 return "BLUETOOTH"; |
48 case chromeos::AUDIO_TYPE_HDMI: | 53 case chromeos::AUDIO_TYPE_HDMI: |
49 return "HDMI"; | 54 return "HDMI"; |
50 case chromeos::AUDIO_TYPE_INTERNAL_SPEAKER: | 55 case chromeos::AUDIO_TYPE_INTERNAL_SPEAKER: |
51 return "INTERNAL_SPEAKER"; | 56 return "INTERNAL_SPEAKER"; |
52 case chromeos::AUDIO_TYPE_INTERNAL_MIC: | 57 case chromeos::AUDIO_TYPE_INTERNAL_MIC: |
53 return "INTERNAL_MIC"; | 58 return "INTERNAL_MIC"; |
54 case chromeos::AUDIO_TYPE_KEYBOARD_MIC: | 59 case chromeos::AUDIO_TYPE_KEYBOARD_MIC: |
55 return "KEYBOARD_MIC"; | 60 return "KEYBOARD_MIC"; |
56 case chromeos::AUDIO_TYPE_OTHER: | 61 case chromeos::AUDIO_TYPE_OTHER: |
57 default: | 62 default: |
58 return "OTHER"; | 63 return "OTHER"; |
59 } | 64 } |
60 } | 65 } |
61 | 66 |
62 chromeos::AudioDeviceType GetAudioType(const std::string& node_type) { | 67 // static |
68 chromeos::AudioDeviceType AudioDevice::GetAudioType( | |
69 const std::string& node_type) { | |
63 if (node_type.find("HEADPHONE") != std::string::npos) | 70 if (node_type.find("HEADPHONE") != std::string::npos) |
64 return chromeos::AUDIO_TYPE_HEADPHONE; | 71 return chromeos::AUDIO_TYPE_HEADPHONE; |
65 else if (node_type.find("INTERNAL_MIC") != std::string::npos) | 72 else if (node_type.find("INTERNAL_MIC") != std::string::npos) |
66 return chromeos::AUDIO_TYPE_INTERNAL_MIC; | 73 return chromeos::AUDIO_TYPE_INTERNAL_MIC; |
67 else if (node_type.find("KEYBOARD_MIC") != std::string::npos) | 74 else if (node_type.find("KEYBOARD_MIC") != std::string::npos) |
68 return chromeos::AUDIO_TYPE_KEYBOARD_MIC; | 75 return chromeos::AUDIO_TYPE_KEYBOARD_MIC; |
69 else if (node_type.find("MIC") != std::string::npos) | 76 else if (node_type.find("MIC") != std::string::npos) |
70 return chromeos::AUDIO_TYPE_MIC; | 77 return chromeos::AUDIO_TYPE_MIC; |
71 else if (node_type.find("USB") != std::string::npos) | 78 else if (node_type.find("USB") != std::string::npos) |
72 return chromeos::AUDIO_TYPE_USB; | 79 return chromeos::AUDIO_TYPE_USB; |
73 else if (node_type.find("BLUETOOTH") != std::string::npos) | 80 else if (node_type.find("BLUETOOTH") != std::string::npos) |
74 return chromeos::AUDIO_TYPE_BLUETOOTH; | 81 return chromeos::AUDIO_TYPE_BLUETOOTH; |
75 else if (node_type.find("HDMI") != std::string::npos) | 82 else if (node_type.find("HDMI") != std::string::npos) |
76 return chromeos::AUDIO_TYPE_HDMI; | 83 return chromeos::AUDIO_TYPE_HDMI; |
77 else if (node_type.find("INTERNAL_SPEAKER") != std::string::npos) | 84 else if (node_type.find("INTERNAL_SPEAKER") != std::string::npos) |
78 return chromeos::AUDIO_TYPE_INTERNAL_SPEAKER; | 85 return chromeos::AUDIO_TYPE_INTERNAL_SPEAKER; |
79 else | 86 else |
80 return chromeos::AUDIO_TYPE_OTHER; | 87 return chromeos::AUDIO_TYPE_OTHER; |
81 } | 88 } |
82 | 89 |
83 } // namespace | |
84 | |
85 namespace chromeos { | |
86 | |
87 AudioDevice::AudioDevice() | 90 AudioDevice::AudioDevice() |
88 : is_input(false), | 91 : is_input(false), |
89 id(0), | 92 id(0), |
90 display_name(""), | 93 display_name(""), |
91 type(AUDIO_TYPE_OTHER), | 94 type(AUDIO_TYPE_OTHER), |
92 priority(0), | 95 priority(0), |
93 active(false), | 96 active(false), |
94 plugged_time(0) { | 97 plugged_time(0) { |
95 } | 98 } |
96 | 99 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 "active = %s ", | 132 "active = %s ", |
130 active ? "true" : "false"); | 133 active ? "true" : "false"); |
131 base::StringAppendF(&result, | 134 base::StringAppendF(&result, |
132 "plugged_time= %s ", | 135 "plugged_time= %s ", |
133 base::Uint64ToString(plugged_time).c_str()); | 136 base::Uint64ToString(plugged_time).c_str()); |
134 | 137 |
135 return result; | 138 return result; |
136 } | 139 } |
137 | 140 |
138 } // namespace chromeos | 141 } // namespace chromeos |
OLD | NEW |