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 #include "chromeos/audio/audio_device.h" | 5 #include "chromeos/audio/audio_device.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Get the priority for a particular device type. The priority returned | 16 // Get the priority for a particular device type. The priority returned |
17 // will be between 0 to 3, the higher number meaning a higher priority. | 17 // will be between 0 to 3, the higher number meaning a higher priority. |
18 uint8 GetDevicePriority(AudioDeviceType type) { | 18 uint8 GetDevicePriority(AudioDeviceType type, bool is_input) { |
| 19 // Lower the priority of bluetooth mic to prevent unexpected bad eperience |
| 20 // to user because of bluetooth audio profile switching. Make priority to |
| 21 // zero so this mic will never be automatically chosen. |
| 22 if (type == AUDIO_TYPE_BLUETOOTH && is_input) |
| 23 return 0; |
19 switch (type) { | 24 switch (type) { |
20 case AUDIO_TYPE_HEADPHONE: | 25 case AUDIO_TYPE_HEADPHONE: |
21 case AUDIO_TYPE_MIC: | 26 case AUDIO_TYPE_MIC: |
22 case AUDIO_TYPE_USB: | 27 case AUDIO_TYPE_USB: |
23 case AUDIO_TYPE_BLUETOOTH: | 28 case AUDIO_TYPE_BLUETOOTH: |
24 return 3; | 29 return 3; |
25 case AUDIO_TYPE_HDMI: | 30 case AUDIO_TYPE_HDMI: |
26 return 2; | 31 return 2; |
27 case AUDIO_TYPE_INTERNAL_SPEAKER: | 32 case AUDIO_TYPE_INTERNAL_SPEAKER: |
28 case AUDIO_TYPE_INTERNAL_MIC: | 33 case AUDIO_TYPE_INTERNAL_MIC: |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 116 |
112 AudioDevice::AudioDevice(const AudioNode& node) { | 117 AudioDevice::AudioDevice(const AudioNode& node) { |
113 is_input = node.is_input; | 118 is_input = node.is_input; |
114 id = node.id; | 119 id = node.id; |
115 type = GetAudioType(node.type); | 120 type = GetAudioType(node.type); |
116 if (!node.name.empty() && node.name != "(default)") | 121 if (!node.name.empty() && node.name != "(default)") |
117 display_name = node.name; | 122 display_name = node.name; |
118 else | 123 else |
119 display_name = node.device_name; | 124 display_name = node.device_name; |
120 device_name = node.device_name; | 125 device_name = node.device_name; |
121 priority = GetDevicePriority(type); | 126 priority = GetDevicePriority(type, node.is_input); |
122 active = node.active; | 127 active = node.active; |
123 plugged_time = node.plugged_time; | 128 plugged_time = node.plugged_time; |
124 } | 129 } |
125 | 130 |
126 std::string AudioDevice::ToString() const { | 131 std::string AudioDevice::ToString() const { |
127 std::string result; | 132 std::string result; |
128 base::StringAppendF(&result, | 133 base::StringAppendF(&result, |
129 "is_input = %s ", | 134 "is_input = %s ", |
130 is_input ? "true" : "false"); | 135 is_input ? "true" : "false"); |
131 base::StringAppendF(&result, | 136 base::StringAppendF(&result, |
(...skipping 12 matching lines...) Expand all Loading... |
144 "active = %s ", | 149 "active = %s ", |
145 active ? "true" : "false"); | 150 active ? "true" : "false"); |
146 base::StringAppendF(&result, | 151 base::StringAppendF(&result, |
147 "plugged_time= %s ", | 152 "plugged_time= %s ", |
148 base::Uint64ToString(plugged_time).c_str()); | 153 base::Uint64ToString(plugged_time).c_str()); |
149 | 154 |
150 return result; | 155 return result; |
151 } | 156 } |
152 | 157 |
153 } // namespace chromeos | 158 } // namespace chromeos |
OLD | NEW |