Update V8 to version 4.4.28.
[chromium-blink-merge.git] / chromeos / audio / audio_device.h
blob6ca1eb0bc8f2125b554b296fe228272fa207f189
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_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/audio_node.h"
16 namespace chromeos {
18 // Ordered from the highest priority to the lowest.
19 enum AudioDeviceType {
20 AUDIO_TYPE_HEADPHONE,
21 AUDIO_TYPE_MIC,
22 AUDIO_TYPE_USB,
23 AUDIO_TYPE_BLUETOOTH,
24 AUDIO_TYPE_HDMI,
25 AUDIO_TYPE_INTERNAL_SPEAKER,
26 AUDIO_TYPE_INTERNAL_MIC,
27 AUDIO_TYPE_KEYBOARD_MIC,
28 AUDIO_TYPE_AOKR,
29 AUDIO_TYPE_OTHER,
32 struct CHROMEOS_EXPORT AudioDevice {
33 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);
42 bool is_input;
43 uint64 id;
44 std::string display_name;
45 std::string device_name;
46 AudioDeviceType type;
47 uint8 priority;
48 bool active;
49 uint64 plugged_time;
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,
57 // 1.) Device Type:
58 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers]
59 // [External Mic/USB Mic/Bluetooth > Internal Mic]
60 // 2.) Device Plugged in Time:
61 // [Later > Earlier]
62 bool operator()(const chromeos::AudioDevice& a,
63 const chromeos::AudioDevice& b) const {
64 if (a.priority < b.priority) {
65 return true;
66 } else if (b.priority < a.priority) {
67 return false;
68 } else if (a.plugged_time < b.plugged_time) {
69 return true;
70 } else {
71 return false;
76 } // namespace chromeos
78 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_