Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chromeos / audio / audio_device.h
blob31e45fdcbbe062e4deddce7cc4399e8d34ca9a9a
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_OTHER,
31 struct CHROMEOS_EXPORT AudioDevice {
32 bool is_input;
33 uint64 id;
34 std::string display_name;
35 std::string device_name;
36 AudioDeviceType type;
37 uint8 priority;
38 bool active;
39 uint64 plugged_time;
41 AudioDevice();
42 explicit AudioDevice(const AudioNode& node);
43 std::string ToString() const;
46 typedef std::vector<AudioDevice> AudioDeviceList;
47 typedef std::map<uint64, AudioDevice> AudioDeviceMap;
49 struct AudioDeviceCompare {
50 // Rules used to discern which device is higher,
51 // 1.) Device Type:
52 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers]
53 // [External Mic/USB Mic/Bluetooth > Internal Mic]
54 // 2.) Device Plugged in Time:
55 // [Later > Earlier]
56 bool operator()(const chromeos::AudioDevice& a,
57 const chromeos::AudioDevice& b) const {
58 if (a.priority < b.priority) {
59 return true;
60 } else if (b.priority < a.priority) {
61 return false;
62 } else if (a.plugged_time < b.plugged_time) {
63 return true;
64 } else {
65 return false;
70 } // namespace chromeos
72 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_