Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chromeos/audio/audio_device.cc

Issue 2609863007: Add new mic types (Closed)
Patch Set: Add comment to explain why rear mic has lower priority Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/audio/audio_device.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 16 matching lines...) Expand all
27 case AUDIO_TYPE_HEADPHONE: 27 case AUDIO_TYPE_HEADPHONE:
28 case AUDIO_TYPE_LINEOUT: 28 case AUDIO_TYPE_LINEOUT:
29 case AUDIO_TYPE_MIC: 29 case AUDIO_TYPE_MIC:
30 case AUDIO_TYPE_USB: 30 case AUDIO_TYPE_USB:
31 case AUDIO_TYPE_BLUETOOTH: 31 case AUDIO_TYPE_BLUETOOTH:
32 return 3; 32 return 3;
33 case AUDIO_TYPE_HDMI: 33 case AUDIO_TYPE_HDMI:
34 return 2; 34 return 2;
35 case AUDIO_TYPE_INTERNAL_SPEAKER: 35 case AUDIO_TYPE_INTERNAL_SPEAKER:
36 case AUDIO_TYPE_INTERNAL_MIC: 36 case AUDIO_TYPE_INTERNAL_MIC:
37 case AUDIO_TYPE_FRONT_MIC:
37 return 1; 38 return 1;
39 // Rear mic should have priority lower than front mic to prevent poor
40 // quality input caused by accidental selecting to rear side mic.
41 case AUDIO_TYPE_REAR_MIC:
38 case AUDIO_TYPE_KEYBOARD_MIC: 42 case AUDIO_TYPE_KEYBOARD_MIC:
39 case AUDIO_TYPE_HOTWORD: 43 case AUDIO_TYPE_HOTWORD:
40 case AUDIO_TYPE_POST_MIX_LOOPBACK: 44 case AUDIO_TYPE_POST_MIX_LOOPBACK:
41 case AUDIO_TYPE_POST_DSP_LOOPBACK: 45 case AUDIO_TYPE_POST_DSP_LOOPBACK:
42 case AUDIO_TYPE_OTHER: 46 case AUDIO_TYPE_OTHER:
43 default: 47 default:
44 return 0; 48 return 0;
45 } 49 }
46 } 50 }
47 51
48 } // namespace 52 } // namespace
49 53
50 // static 54 // static
51 std::string AudioDevice::GetTypeString(AudioDeviceType type) { 55 std::string AudioDevice::GetTypeString(AudioDeviceType type) {
52 switch (type) { 56 switch (type) {
53 case AUDIO_TYPE_HEADPHONE: 57 case AUDIO_TYPE_HEADPHONE:
54 return "HEADPHONE"; 58 return "HEADPHONE";
55 case AUDIO_TYPE_MIC: 59 case AUDIO_TYPE_MIC:
56 return "MIC"; 60 return "MIC";
57 case AUDIO_TYPE_USB: 61 case AUDIO_TYPE_USB:
58 return "USB"; 62 return "USB";
59 case AUDIO_TYPE_BLUETOOTH: 63 case AUDIO_TYPE_BLUETOOTH:
60 return "BLUETOOTH"; 64 return "BLUETOOTH";
61 case AUDIO_TYPE_HDMI: 65 case AUDIO_TYPE_HDMI:
62 return "HDMI"; 66 return "HDMI";
63 case AUDIO_TYPE_INTERNAL_SPEAKER: 67 case AUDIO_TYPE_INTERNAL_SPEAKER:
64 return "INTERNAL_SPEAKER"; 68 return "INTERNAL_SPEAKER";
65 case AUDIO_TYPE_INTERNAL_MIC: 69 case AUDIO_TYPE_INTERNAL_MIC:
66 return "INTERNAL_MIC"; 70 return "INTERNAL_MIC";
71 case AUDIO_TYPE_FRONT_MIC:
72 return "FRONT_MIC";
73 case AUDIO_TYPE_REAR_MIC:
74 return "REAR_MIC";
67 case AUDIO_TYPE_KEYBOARD_MIC: 75 case AUDIO_TYPE_KEYBOARD_MIC:
68 return "KEYBOARD_MIC"; 76 return "KEYBOARD_MIC";
69 case AUDIO_TYPE_HOTWORD: 77 case AUDIO_TYPE_HOTWORD:
70 return "HOTWORD"; 78 return "HOTWORD";
71 case AUDIO_TYPE_LINEOUT: 79 case AUDIO_TYPE_LINEOUT:
72 return "LINEOUT"; 80 return "LINEOUT";
73 case AUDIO_TYPE_POST_MIX_LOOPBACK: 81 case AUDIO_TYPE_POST_MIX_LOOPBACK:
74 return "POST_MIX_LOOPBACK"; 82 return "POST_MIX_LOOPBACK";
75 case AUDIO_TYPE_POST_DSP_LOOPBACK: 83 case AUDIO_TYPE_POST_DSP_LOOPBACK:
76 return "POST_DSP_LOOPBACK"; 84 return "POST_DSP_LOOPBACK";
77 case AUDIO_TYPE_OTHER: 85 case AUDIO_TYPE_OTHER:
78 default: 86 default:
79 return "OTHER"; 87 return "OTHER";
80 } 88 }
81 } 89 }
82 90
83 // static 91 // static
84 AudioDeviceType AudioDevice::GetAudioType( 92 AudioDeviceType AudioDevice::GetAudioType(
85 const std::string& node_type) { 93 const std::string& node_type) {
86 if (node_type.find("HEADPHONE") != std::string::npos) 94 if (node_type.find("HEADPHONE") != std::string::npos)
87 return AUDIO_TYPE_HEADPHONE; 95 return AUDIO_TYPE_HEADPHONE;
88 else if (node_type.find("INTERNAL_MIC") != std::string::npos) 96 else if (node_type.find("INTERNAL_MIC") != std::string::npos)
89 return AUDIO_TYPE_INTERNAL_MIC; 97 return AUDIO_TYPE_INTERNAL_MIC;
98 else if (node_type.find("FRONT_MIC") != std::string::npos)
99 return AUDIO_TYPE_FRONT_MIC;
100 else if (node_type.find("REAR_MIC") != std::string::npos)
101 return AUDIO_TYPE_REAR_MIC;
90 else if (node_type.find("KEYBOARD_MIC") != std::string::npos) 102 else if (node_type.find("KEYBOARD_MIC") != std::string::npos)
91 return AUDIO_TYPE_KEYBOARD_MIC; 103 return AUDIO_TYPE_KEYBOARD_MIC;
92 else if (node_type.find("MIC") != std::string::npos) 104 else if (node_type.find("MIC") != std::string::npos)
93 return AUDIO_TYPE_MIC; 105 return AUDIO_TYPE_MIC;
94 else if (node_type.find("USB") != std::string::npos) 106 else if (node_type.find("USB") != std::string::npos)
95 return AUDIO_TYPE_USB; 107 return AUDIO_TYPE_USB;
96 else if (node_type.find("BLUETOOTH") != std::string::npos) 108 else if (node_type.find("BLUETOOTH") != std::string::npos)
97 return AUDIO_TYPE_BLUETOOTH; 109 return AUDIO_TYPE_BLUETOOTH;
98 else if (node_type.find("HDMI") != std::string::npos) 110 else if (node_type.find("HDMI") != std::string::npos)
99 return AUDIO_TYPE_HDMI; 111 return AUDIO_TYPE_HDMI;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 active ? "true" : "false"); 180 active ? "true" : "false");
169 base::StringAppendF(&result, 181 base::StringAppendF(&result,
170 "plugged_time= %s ", 182 "plugged_time= %s ",
171 base::Uint64ToString(plugged_time).c_str()); 183 base::Uint64ToString(plugged_time).c_str());
172 base::StringAppendF(&result, "mic_positions = %s ", mic_positions.c_str()); 184 base::StringAppendF(&result, "mic_positions = %s ", mic_positions.c_str());
173 185
174 return result; 186 return result;
175 } 187 }
176 188
177 } // namespace chromeos 189 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/audio/audio_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698