| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 else if (node_type.find("LINEOUT") != std::string::npos) | 108 else if (node_type.find("LINEOUT") != std::string::npos) |
| 109 return AUDIO_TYPE_LINEOUT; | 109 return AUDIO_TYPE_LINEOUT; |
| 110 else if (node_type.find("POST_MIX_LOOPBACK") != std::string::npos) | 110 else if (node_type.find("POST_MIX_LOOPBACK") != std::string::npos) |
| 111 return AUDIO_TYPE_POST_MIX_LOOPBACK; | 111 return AUDIO_TYPE_POST_MIX_LOOPBACK; |
| 112 else if (node_type.find("POST_DSP_LOOPBACK") != std::string::npos) | 112 else if (node_type.find("POST_DSP_LOOPBACK") != std::string::npos) |
| 113 return AUDIO_TYPE_POST_DSP_LOOPBACK; | 113 return AUDIO_TYPE_POST_DSP_LOOPBACK; |
| 114 else | 114 else |
| 115 return AUDIO_TYPE_OTHER; | 115 return AUDIO_TYPE_OTHER; |
| 116 } | 116 } |
| 117 | 117 |
| 118 AudioDevice::AudioDevice() | 118 AudioDevice::AudioDevice() {} |
| 119 : is_input(false), | |
| 120 id(0), | |
| 121 stable_device_id(0), | |
| 122 display_name(""), | |
| 123 type(AUDIO_TYPE_OTHER), | |
| 124 priority(0), | |
| 125 active(false), | |
| 126 plugged_time(0) {} | |
| 127 | 119 |
| 128 AudioDevice::AudioDevice(const AudioNode& node) { | 120 AudioDevice::AudioDevice(const AudioNode& node) { |
| 129 is_input = node.is_input; | 121 is_input = node.is_input; |
| 130 id = node.id; | 122 id = node.id; |
| 131 stable_device_id = node.stable_device_id; | 123 stable_device_id_version = node.StableDeviceIdVersion(); |
| 124 stable_device_id = node.StableDeviceId(); |
| 125 if (stable_device_id_version == 2) |
| 126 deprecated_stable_device_id = node.stable_device_id_v1; |
| 132 type = GetAudioType(node.type); | 127 type = GetAudioType(node.type); |
| 133 if (!node.name.empty() && node.name != "(default)") | 128 if (!node.name.empty() && node.name != "(default)") |
| 134 display_name = node.name; | 129 display_name = node.name; |
| 135 else | 130 else |
| 136 display_name = node.device_name; | 131 display_name = node.device_name; |
| 137 device_name = node.device_name; | 132 device_name = node.device_name; |
| 138 mic_positions = node.mic_positions; | 133 mic_positions = node.mic_positions; |
| 139 priority = GetDevicePriority(type, node.is_input); | 134 priority = GetDevicePriority(type, node.is_input); |
| 140 active = node.active; | 135 active = node.active; |
| 141 plugged_time = node.plugged_time; | 136 plugged_time = node.plugged_time; |
| 142 } | 137 } |
| 143 | 138 |
| 144 AudioDevice::AudioDevice(const AudioDevice& other) = default; | 139 AudioDevice::AudioDevice(const AudioDevice& other) = default; |
| 145 | 140 |
| 146 std::string AudioDevice::ToString() const { | 141 std::string AudioDevice::ToString() const { |
| 142 if (stable_device_id_version == 0) { |
| 143 return "Null device"; |
| 144 } |
| 145 |
| 147 std::string result; | 146 std::string result; |
| 148 base::StringAppendF(&result, | 147 base::StringAppendF(&result, |
| 149 "is_input = %s ", | 148 "is_input = %s ", |
| 150 is_input ? "true" : "false"); | 149 is_input ? "true" : "false"); |
| 151 base::StringAppendF(&result, | 150 base::StringAppendF(&result, |
| 152 "id = 0x%" PRIx64 " ", | 151 "id = 0x%" PRIx64 " ", |
| 153 id); | 152 id); |
| 154 base::StringAppendF(&result, | 153 base::StringAppendF(&result, "stable_device_id_version = %d", |
| 155 "stable_device_id = 0x%" PRIx64 " ", | 154 stable_device_id_version); |
| 155 base::StringAppendF(&result, "stable_device_id = 0x%" PRIx64 " ", |
| 156 stable_device_id); | 156 stable_device_id); |
| 157 base::StringAppendF(&result, | 157 base::StringAppendF(&result, "deprecated_stable_device_id = 0x%" PRIx64 " ", |
| 158 "display_name = %s ", | 158 deprecated_stable_device_id); |
| 159 display_name.c_str()); | 159 base::StringAppendF(&result, "display_name = %s ", display_name.c_str()); |
| 160 base::StringAppendF(&result, | 160 base::StringAppendF(&result, |
| 161 "device_name = %s ", | 161 "device_name = %s ", |
| 162 device_name.c_str()); | 162 device_name.c_str()); |
| 163 base::StringAppendF(&result, | 163 base::StringAppendF(&result, |
| 164 "type = %s ", | 164 "type = %s ", |
| 165 GetTypeString(type).c_str()); | 165 GetTypeString(type).c_str()); |
| 166 base::StringAppendF(&result, | 166 base::StringAppendF(&result, |
| 167 "active = %s ", | 167 "active = %s ", |
| 168 active ? "true" : "false"); | 168 active ? "true" : "false"); |
| 169 base::StringAppendF(&result, | 169 base::StringAppendF(&result, |
| 170 "plugged_time= %s ", | 170 "plugged_time= %s ", |
| 171 base::Uint64ToString(plugged_time).c_str()); | 171 base::Uint64ToString(plugged_time).c_str()); |
| 172 base::StringAppendF(&result, "mic_positions = %s ", mic_positions.c_str()); | 172 base::StringAppendF(&result, "mic_positions = %s ", mic_positions.c_str()); |
| 173 | 173 |
| 174 return result; | 174 return result; |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace chromeos | 177 } // namespace chromeos |
| OLD | NEW |