summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/audio_node.cc
blob: e025e9dd2ee3ea69a555de6b80c0f9cf13ee71ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chromeos/dbus/audio_node.h"

#include "base/format_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"

namespace chromeos {

AudioNode::AudioNode()
    : is_input(false),
      id(0),
      active(false),
      plugged_time(0) {
}

AudioNode::AudioNode(bool is_input,
                     uint64 id,
                     std::string device_name,
                     std::string type,
                     std::string name,
                     bool active,
                     uint64 plugged_time)
    : is_input(is_input),
      id(id),
      device_name(device_name),
      type(type),
      name(name),
      active(active),
      plugged_time(plugged_time) {
}

std::string AudioNode::ToString() const {
  std::string result;
  base::StringAppendF(&result,
                      "is_input = %s ",
                      is_input ? "true" : "false");
  base::StringAppendF(&result,
                      "id = 0x%" PRIx64 " ",
                      id);
  base::StringAppendF(&result,
                      "device_name = %s ",
                      device_name.c_str());
  base::StringAppendF(&result,
                      "type = %s ",
                      type.c_str());
  base::StringAppendF(&result,
                      "name = %s ",
                      name.c_str());
  base::StringAppendF(&result,
                      "active = %s ",
                      active ? "true" : "false");
  base::StringAppendF(&result,
                      "plugged_time= %s ",
                      base::Uint64ToString(plugged_time).c_str());

  return result;
}

}  // namespace chromeos