| 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/dbus/audio_node.h" | 5 #include "chromeos/dbus/audio_node.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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 | 14 |
| 15 AudioNode::AudioNode() | 15 AudioNode::AudioNode() {} |
| 16 : is_input(false), | |
| 17 id(0), | |
| 18 active(false), | |
| 19 plugged_time(0) { | |
| 20 } | |
| 21 | 16 |
| 22 AudioNode::AudioNode(bool is_input, | 17 AudioNode::AudioNode(bool is_input, |
| 23 uint64_t id, | 18 uint64_t id, |
| 24 uint64_t stable_device_id, | 19 bool has_v2_stable_device_id, |
| 20 uint64_t stable_device_id_v1, |
| 21 uint64_t stable_device_id_v2, |
| 25 std::string device_name, | 22 std::string device_name, |
| 26 std::string type, | 23 std::string type, |
| 27 std::string name, | 24 std::string name, |
| 28 bool active, | 25 bool active, |
| 29 uint64_t plugged_time) | 26 uint64_t plugged_time) |
| 30 : is_input(is_input), | 27 : is_input(is_input), |
| 31 id(id), | 28 id(id), |
| 32 stable_device_id(stable_device_id), | 29 has_v2_stable_device_id(has_v2_stable_device_id), |
| 30 stable_device_id_v1(stable_device_id_v1), |
| 31 stable_device_id_v2(stable_device_id_v2), |
| 33 device_name(device_name), | 32 device_name(device_name), |
| 34 type(type), | 33 type(type), |
| 35 name(name), | 34 name(name), |
| 36 active(active), | 35 active(active), |
| 37 plugged_time(plugged_time) {} | 36 plugged_time(plugged_time) {} |
| 38 | 37 |
| 39 AudioNode::AudioNode(const AudioNode& other) = default; | 38 AudioNode::AudioNode(const AudioNode& other) = default; |
| 40 | 39 |
| 41 AudioNode::~AudioNode() {} | 40 AudioNode::~AudioNode() {} |
| 42 | 41 |
| 43 std::string AudioNode::ToString() const { | 42 std::string AudioNode::ToString() const { |
| 44 std::string result; | 43 std::string result; |
| 45 base::StringAppendF(&result, | 44 base::StringAppendF(&result, |
| 46 "is_input = %s ", | 45 "is_input = %s ", |
| 47 is_input ? "true" : "false"); | 46 is_input ? "true" : "false"); |
| 48 base::StringAppendF(&result, | 47 base::StringAppendF(&result, |
| 49 "id = 0x%" PRIx64 " ", | 48 "id = 0x%" PRIx64 " ", |
| 50 id); | 49 id); |
| 51 base::StringAppendF(&result, "stable_device_id = 0x%" PRIx64 " ", | 50 base::StringAppendF(&result, "stable_device_id_version = %d", |
| 52 stable_device_id); | 51 StableDeviceIdVersion()); |
| 52 base::StringAppendF(&result, "stable_device_id_v1 = 0x%" PRIx64 " ", |
| 53 stable_device_id_v1); |
| 54 base::StringAppendF(&result, "stable_device_id_v2 = 0x%" PRIx64 " ", |
| 55 stable_device_id_v2); |
| 53 base::StringAppendF(&result, "device_name = %s ", device_name.c_str()); | 56 base::StringAppendF(&result, "device_name = %s ", device_name.c_str()); |
| 54 base::StringAppendF(&result, | 57 base::StringAppendF(&result, |
| 55 "type = %s ", | 58 "type = %s ", |
| 56 type.c_str()); | 59 type.c_str()); |
| 57 base::StringAppendF(&result, | 60 base::StringAppendF(&result, |
| 58 "name = %s ", | 61 "name = %s ", |
| 59 name.c_str()); | 62 name.c_str()); |
| 60 base::StringAppendF(&result, | 63 base::StringAppendF(&result, |
| 61 "active = %s ", | 64 "active = %s ", |
| 62 active ? "true" : "false"); | 65 active ? "true" : "false"); |
| 63 base::StringAppendF(&result, | 66 base::StringAppendF(&result, |
| 64 "plugged_time= %s ", | 67 "plugged_time= %s ", |
| 65 base::Uint64ToString(plugged_time).c_str()); | 68 base::Uint64ToString(plugged_time).c_str()); |
| 66 | 69 |
| 67 return result; | 70 return result; |
| 68 } | 71 } |
| 69 | 72 |
| 73 int AudioNode::StableDeviceIdVersion() const { |
| 74 return has_v2_stable_device_id ? 2 : 1; |
| 75 } |
| 76 |
| 77 uint64_t AudioNode::StableDeviceId() const { |
| 78 return has_v2_stable_device_id ? stable_device_id_v2 : stable_device_id_v1; |
| 79 } |
| 80 |
| 70 } // namespace chromeos | 81 } // namespace chromeos |
| OLD | NEW |