| 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 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 5 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| 6 #define CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 6 #define CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return (type == AUDIO_TYPE_HEADPHONE || | 52 return (type == AUDIO_TYPE_HEADPHONE || |
| 53 type == AUDIO_TYPE_INTERNAL_MIC || | 53 type == AUDIO_TYPE_INTERNAL_MIC || |
| 54 type == AUDIO_TYPE_MIC || | 54 type == AUDIO_TYPE_MIC || |
| 55 type == AUDIO_TYPE_USB || | 55 type == AUDIO_TYPE_USB || |
| 56 type == AUDIO_TYPE_BLUETOOTH || | 56 type == AUDIO_TYPE_BLUETOOTH || |
| 57 type == AUDIO_TYPE_HDMI || | 57 type == AUDIO_TYPE_HDMI || |
| 58 type == AUDIO_TYPE_INTERNAL_SPEAKER || | 58 type == AUDIO_TYPE_INTERNAL_SPEAKER || |
| 59 type == AUDIO_TYPE_LINEOUT); | 59 type == AUDIO_TYPE_LINEOUT); |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool is_input; | 62 bool is_input = false; |
| 63 | 63 |
| 64 // Id of this audio device. The legacy |id| is assigned to be unique everytime | 64 // Id of this audio device. The legacy |id| is assigned to be unique everytime |
| 65 // when each device got plugged, so that the same physical device will have | 65 // when each device got plugged, so that the same physical device will have |
| 66 // a different id after unplug then re-plug. | 66 // a different id after unplug then re-plug. |
| 67 // The |stable_device_id| is designed to be persistent across system reboot | 67 // The |stable_device_id| is designed to be persistent across system reboot |
| 68 // and plug/unplug for the same physical device. It is guaranteed that | 68 // and plug/unplug for the same physical device. It is guaranteed that |
| 69 // different type of hardware has different |stable_device_id|, but not | 69 // different type of hardware has different |stable_device_id|, but not |
| 70 // guaranteed to be different between the same kind of audio device, e.g | 70 // guaranteed to be different between the same kind of audio device, e.g |
| 71 // USB headset. |id| and |stable_device_id| can be used together to achieve | 71 // USB headset. |id| and |stable_device_id| can be used together to achieve |
| 72 // various goals. | 72 // various goals. |
| 73 uint64_t id; | 73 // Note that because algorithm used to determine |stable_device_id| changed in |
| 74 uint64_t stable_device_id; | 74 // system code, |stable_device_id_version| and |deprecated_stable_device_id| |
| 75 // have been introduced - to ensure backward compatibility until persisted |
| 76 // references to stable device ID have been updated where needed. |
| 77 // |stable_device_id_version| is the version of stable device ID set in |
| 78 // |stable_device_id|. If version is set to 2, |deprecated_stable_device_id| |
| 79 // will contain deprecated, v1 stable device id version. |
| 80 uint64_t id = 0; |
| 81 int stable_device_id_version = 0; |
| 82 uint64_t stable_device_id = 0; |
| 83 uint64_t deprecated_stable_device_id = 0; |
| 75 std::string display_name; | 84 std::string display_name; |
| 76 std::string device_name; | 85 std::string device_name; |
| 77 std::string mic_positions; | 86 std::string mic_positions; |
| 78 AudioDeviceType type; | 87 AudioDeviceType type = AUDIO_TYPE_OTHER; |
| 79 uint8_t priority; | 88 uint8_t priority = 0; |
| 80 bool active; | 89 bool active = false; |
| 81 uint64_t plugged_time; | 90 uint64_t plugged_time = 0; |
| 82 }; | 91 }; |
| 83 | 92 |
| 84 typedef std::vector<AudioDevice> AudioDeviceList; | 93 typedef std::vector<AudioDevice> AudioDeviceList; |
| 85 typedef std::map<uint64_t, AudioDevice> AudioDeviceMap; | 94 typedef std::map<uint64_t, AudioDevice> AudioDeviceMap; |
| 86 | 95 |
| 87 struct AudioDeviceCompare { | 96 struct AudioDeviceCompare { |
| 88 // Rules used to discern which device is higher, | 97 // Rules used to discern which device is higher, |
| 89 // 1.) Device Type: | 98 // 1.) Device Type: |
| 90 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers] | 99 // [Headphones/USB/Bluetooh > HDMI > Internal Speakers] |
| 91 // [External Mic/USB Mic/Bluetooth > Internal Mic] | 100 // [External Mic/USB Mic/Bluetooth > Internal Mic] |
| 92 // 2.) Device Plugged in Time: | 101 // 2.) Device Plugged in Time: |
| 93 // [Later > Earlier] | 102 // [Later > Earlier] |
| 94 bool operator()(const chromeos::AudioDevice& a, | 103 bool operator()(const chromeos::AudioDevice& a, |
| 95 const chromeos::AudioDevice& b) const { | 104 const chromeos::AudioDevice& b) const { |
| 96 if (a.priority < b.priority) { | 105 if (a.priority < b.priority) { |
| 97 return true; | 106 return true; |
| 98 } else if (b.priority < a.priority) { | 107 } else if (b.priority < a.priority) { |
| 99 return false; | 108 return false; |
| 100 } else if (a.plugged_time < b.plugged_time) { | 109 } else if (a.plugged_time < b.plugged_time) { |
| 101 return true; | 110 return true; |
| 102 } else { | 111 } else { |
| 103 return false; | 112 return false; |
| 104 } | 113 } |
| 105 } | 114 } |
| 106 }; | 115 }; |
| 107 | 116 |
| 108 } // namespace chromeos | 117 } // namespace chromeos |
| 109 | 118 |
| 110 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 119 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| OLD | NEW |