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" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 return AUDIO_TYPE_POST_MIX_LOOPBACK; | 100 return AUDIO_TYPE_POST_MIX_LOOPBACK; |
101 else if (node_type.find("POST_DSP_LOOPBACK") != std::string::npos) | 101 else if (node_type.find("POST_DSP_LOOPBACK") != std::string::npos) |
102 return AUDIO_TYPE_POST_DSP_LOOPBACK; | 102 return AUDIO_TYPE_POST_DSP_LOOPBACK; |
103 else | 103 else |
104 return AUDIO_TYPE_OTHER; | 104 return AUDIO_TYPE_OTHER; |
105 } | 105 } |
106 | 106 |
107 AudioDevice::AudioDevice() | 107 AudioDevice::AudioDevice() |
108 : is_input(false), | 108 : is_input(false), |
109 id(0), | 109 id(0), |
110 stable_device_id(0), | |
110 display_name(""), | 111 display_name(""), |
111 type(AUDIO_TYPE_OTHER), | 112 type(AUDIO_TYPE_OTHER), |
112 priority(0), | 113 priority(0), |
113 active(false), | 114 active(false), |
114 plugged_time(0) { | 115 plugged_time(0) { |
115 } | 116 } |
116 | 117 |
117 AudioDevice::AudioDevice(const AudioNode& node) { | 118 AudioDevice::AudioDevice(const AudioNode& node) { |
118 is_input = node.is_input; | 119 is_input = node.is_input; |
119 id = node.id; | 120 id = node.id; |
121 stable_device_id = node.stable_device_id; | |
120 type = GetAudioType(node.type); | 122 type = GetAudioType(node.type); |
121 if (!node.name.empty() && node.name != "(default)") | 123 if (!node.name.empty() && node.name != "(default)") |
122 display_name = node.name; | 124 display_name = node.name; |
123 else | 125 else |
124 display_name = node.device_name; | 126 display_name = node.device_name; |
125 device_name = node.device_name; | 127 device_name = node.device_name; |
126 mic_positions = node.mic_positions; | 128 mic_positions = node.mic_positions; |
127 priority = GetDevicePriority(type, node.is_input); | 129 priority = GetDevicePriority(type, node.is_input); |
128 active = node.active; | 130 active = node.active; |
129 plugged_time = node.plugged_time; | 131 plugged_time = node.plugged_time; |
130 } | 132 } |
131 | 133 |
132 std::string AudioDevice::ToString() const { | 134 std::string AudioDevice::ToString() const { |
jennyz
2015/12/17 22:50:20
Please add stable_device_id.
hychao
2015/12/29 10:57:25
Done.
| |
133 std::string result; | 135 std::string result; |
134 base::StringAppendF(&result, | 136 base::StringAppendF(&result, |
135 "is_input = %s ", | 137 "is_input = %s ", |
136 is_input ? "true" : "false"); | 138 is_input ? "true" : "false"); |
137 base::StringAppendF(&result, | 139 base::StringAppendF(&result, |
138 "id = 0x%" PRIx64 " ", | 140 "id = 0x%" PRIx64 " ", |
139 id); | 141 id); |
140 base::StringAppendF(&result, | 142 base::StringAppendF(&result, |
141 "display_name = %s ", | 143 "display_name = %s ", |
142 display_name.c_str()); | 144 display_name.c_str()); |
143 base::StringAppendF(&result, | 145 base::StringAppendF(&result, |
144 "device_name = %s ", | 146 "device_name = %s ", |
145 device_name.c_str()); | 147 device_name.c_str()); |
146 base::StringAppendF(&result, | 148 base::StringAppendF(&result, |
147 "type = %s ", | 149 "type = %s ", |
148 GetTypeString(type).c_str()); | 150 GetTypeString(type).c_str()); |
149 base::StringAppendF(&result, | 151 base::StringAppendF(&result, |
150 "active = %s ", | 152 "active = %s ", |
151 active ? "true" : "false"); | 153 active ? "true" : "false"); |
152 base::StringAppendF(&result, | 154 base::StringAppendF(&result, |
153 "plugged_time= %s ", | 155 "plugged_time= %s ", |
154 base::Uint64ToString(plugged_time).c_str()); | 156 base::Uint64ToString(plugged_time).c_str()); |
155 base::StringAppendF(&result, "mic_positions = %s ", mic_positions.c_str()); | 157 base::StringAppendF(&result, "mic_positions = %s ", mic_positions.c_str()); |
156 | 158 |
157 return result; | 159 return result; |
158 } | 160 } |
159 | 161 |
160 } // namespace chromeos | 162 } // namespace chromeos |
OLD | NEW |