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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICE_H_
6 #define CHROMEOS_AUDIO_AUDIO_DEVICE_H_
12 #include "base/basictypes.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/audio_node.h"
18 // Ordered from the highest priority to the lowest.
19 enum AudioDeviceType
{
25 AUDIO_TYPE_INTERNAL_SPEAKER
,
26 AUDIO_TYPE_INTERNAL_MIC
,
27 AUDIO_TYPE_KEYBOARD_MIC
,
32 struct CHROMEOS_EXPORT AudioDevice
{
34 explicit AudioDevice(const AudioNode
& node
);
35 std::string
ToString() const;
37 // Converts between the string type sent via D-Bus and AudioDeviceType.
38 // Static so they can be used by tests.
39 static std::string
GetTypeString(chromeos::AudioDeviceType type
);
40 static chromeos::AudioDeviceType
GetAudioType(const std::string
& node_type
);
44 std::string display_name
;
45 std::string device_name
;
52 typedef std::vector
<AudioDevice
> AudioDeviceList
;
53 typedef std::map
<uint64
, AudioDevice
> AudioDeviceMap
;
55 struct AudioDeviceCompare
{
56 // Rules used to discern which device is higher,
58 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers]
59 // [External Mic/USB Mic/Bluetooth > Internal Mic]
60 // 2.) Device Plugged in Time:
62 bool operator()(const chromeos::AudioDevice
& a
,
63 const chromeos::AudioDevice
& b
) const {
64 if (a
.priority
< b
.priority
) {
66 } else if (b
.priority
< a
.priority
) {
68 } else if (a
.plugged_time
< b
.plugged_time
) {
76 } // namespace chromeos
78 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_