OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 private boolean shouldEnableAec = false; | 60 private boolean shouldEnableAec = false; |
61 private boolean shouldEnableAgc = false; | 61 private boolean shouldEnableAgc = false; |
62 private boolean shouldEnableNs = false; | 62 private boolean shouldEnableNs = false; |
63 | 63 |
64 // Checks if the device implements Acoustic Echo Cancellation (AEC). | 64 // Checks if the device implements Acoustic Echo Cancellation (AEC). |
65 // Returns true if the device implements AEC, false otherwise. | 65 // Returns true if the device implements AEC, false otherwise. |
66 public static boolean isAcousticEchoCancelerSupported() { | 66 public static boolean isAcousticEchoCancelerSupported() { |
67 // Note: we're using isAcousticEchoCancelerEffectAvailable() instead of | 67 // Note: we're using isAcousticEchoCancelerEffectAvailable() instead of |
68 // AcousticEchoCanceler.isAvailable() to avoid the expensive getEffects() | 68 // AcousticEchoCanceler.isAvailable() to avoid the expensive getEffects() |
69 // OS API call. | 69 // OS API call. |
70 return WebRtcAudioUtils.runningOnJellyBeanOrHigher() | 70 return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isAcousticEchoCancel
erEffectAvailable(); |
71 && isAcousticEchoCancelerEffectAvailable(); | |
72 } | 71 } |
73 | 72 |
74 // Checks if the device implements Automatic Gain Control (AGC). | 73 // Checks if the device implements Automatic Gain Control (AGC). |
75 // Returns true if the device implements AGC, false otherwise. | 74 // Returns true if the device implements AGC, false otherwise. |
76 public static boolean isAutomaticGainControlSupported() { | 75 public static boolean isAutomaticGainControlSupported() { |
77 // Note: we're using isAutomaticGainControlEffectAvailable() instead of | 76 // Note: we're using isAutomaticGainControlEffectAvailable() instead of |
78 // AutomaticGainControl.isAvailable() to avoid the expensive getEffects() | 77 // AutomaticGainControl.isAvailable() to avoid the expensive getEffects() |
79 // OS API call. | 78 // OS API call. |
80 return WebRtcAudioUtils.runningOnJellyBeanOrHigher() | 79 return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isAutomaticGainContr
olEffectAvailable(); |
81 && isAutomaticGainControlEffectAvailable(); | |
82 } | 80 } |
83 | 81 |
84 // Checks if the device implements Noise Suppression (NS). | 82 // Checks if the device implements Noise Suppression (NS). |
85 // Returns true if the device implements NS, false otherwise. | 83 // Returns true if the device implements NS, false otherwise. |
86 public static boolean isNoiseSuppressorSupported() { | 84 public static boolean isNoiseSuppressorSupported() { |
87 // Note: we're using isNoiseSuppressorEffectAvailable() instead of | 85 // Note: we're using isNoiseSuppressorEffectAvailable() instead of |
88 // NoiseSuppressor.isAvailable() to avoid the expensive getEffects() | 86 // NoiseSuppressor.isAvailable() to avoid the expensive getEffects() |
89 // OS API call. | 87 // OS API call. |
90 return WebRtcAudioUtils.runningOnJellyBeanOrHigher() | 88 return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isNoiseSuppressorEff
ectAvailable(); |
91 && isNoiseSuppressorEffectAvailable(); | |
92 } | 89 } |
93 | 90 |
94 // Returns true if the device is blacklisted for HW AEC usage. | 91 // Returns true if the device is blacklisted for HW AEC usage. |
95 public static boolean isAcousticEchoCancelerBlacklisted() { | 92 public static boolean isAcousticEchoCancelerBlacklisted() { |
96 List<String> blackListedModels = | 93 List<String> blackListedModels = WebRtcAudioUtils.getBlackListedModelsForAec
Usage(); |
97 WebRtcAudioUtils.getBlackListedModelsForAecUsage(); | |
98 boolean isBlacklisted = blackListedModels.contains(Build.MODEL); | 94 boolean isBlacklisted = blackListedModels.contains(Build.MODEL); |
99 if (isBlacklisted) { | 95 if (isBlacklisted) { |
100 Logging.w(TAG, Build.MODEL + " is blacklisted for HW AEC usage!"); | 96 Logging.w(TAG, Build.MODEL + " is blacklisted for HW AEC usage!"); |
101 } | 97 } |
102 return isBlacklisted; | 98 return isBlacklisted; |
103 } | 99 } |
104 | 100 |
105 // Returns true if the device is blacklisted for HW AGC usage. | 101 // Returns true if the device is blacklisted for HW AGC usage. |
106 public static boolean isAutomaticGainControlBlacklisted() { | 102 public static boolean isAutomaticGainControlBlacklisted() { |
107 List<String> blackListedModels = | 103 List<String> blackListedModels = WebRtcAudioUtils.getBlackListedModelsForAgc
Usage(); |
108 WebRtcAudioUtils.getBlackListedModelsForAgcUsage(); | |
109 boolean isBlacklisted = blackListedModels.contains(Build.MODEL); | 104 boolean isBlacklisted = blackListedModels.contains(Build.MODEL); |
110 if (isBlacklisted) { | 105 if (isBlacklisted) { |
111 Logging.w(TAG, Build.MODEL + " is blacklisted for HW AGC usage!"); | 106 Logging.w(TAG, Build.MODEL + " is blacklisted for HW AGC usage!"); |
112 } | 107 } |
113 return isBlacklisted; | 108 return isBlacklisted; |
114 } | 109 } |
115 | 110 |
116 // Returns true if the device is blacklisted for HW NS usage. | 111 // Returns true if the device is blacklisted for HW NS usage. |
117 public static boolean isNoiseSuppressorBlacklisted() { | 112 public static boolean isNoiseSuppressorBlacklisted() { |
118 List<String> blackListedModels = | 113 List<String> blackListedModels = WebRtcAudioUtils.getBlackListedModelsForNsU
sage(); |
119 WebRtcAudioUtils.getBlackListedModelsForNsUsage(); | |
120 boolean isBlacklisted = blackListedModels.contains(Build.MODEL); | 114 boolean isBlacklisted = blackListedModels.contains(Build.MODEL); |
121 if (isBlacklisted) { | 115 if (isBlacklisted) { |
122 Logging.w(TAG, Build.MODEL + " is blacklisted for HW NS usage!"); | 116 Logging.w(TAG, Build.MODEL + " is blacklisted for HW NS usage!"); |
123 } | 117 } |
124 return isBlacklisted; | 118 return isBlacklisted; |
125 } | 119 } |
126 | 120 |
127 // Returns true if the platform AEC should be excluded based on its UUID. | 121 // Returns true if the platform AEC should be excluded based on its UUID. |
128 // AudioEffect.queryEffects() can throw IllegalStateException. | 122 // AudioEffect.queryEffects() can throw IllegalStateException. |
129 @TargetApi(18) | 123 @TargetApi(18) |
130 private static boolean isAcousticEchoCancelerExcludedByUUID() { | 124 private static boolean isAcousticEchoCancelerExcludedByUUID() { |
131 for (Descriptor d : getAvailableEffects()) { | 125 for (Descriptor d : getAvailableEffects()) { |
132 if (d.type.equals(AudioEffect.EFFECT_TYPE_AEC) && | 126 if (d.type.equals(AudioEffect.EFFECT_TYPE_AEC) |
133 d.uuid.equals(AOSP_ACOUSTIC_ECHO_CANCELER)) { | 127 && d.uuid.equals(AOSP_ACOUSTIC_ECHO_CANCELER)) { |
134 return true; | 128 return true; |
135 } | 129 } |
136 } | 130 } |
137 return false; | 131 return false; |
138 } | 132 } |
139 | 133 |
140 // Returns true if the platform AGC should be excluded based on its UUID. | 134 // Returns true if the platform AGC should be excluded based on its UUID. |
141 // AudioEffect.queryEffects() can throw IllegalStateException. | 135 // AudioEffect.queryEffects() can throw IllegalStateException. |
142 @TargetApi(18) | 136 @TargetApi(18) |
143 private static boolean isAutomaticGainControlExcludedByUUID() { | 137 private static boolean isAutomaticGainControlExcludedByUUID() { |
144 for (Descriptor d : getAvailableEffects()) { | 138 for (Descriptor d : getAvailableEffects()) { |
145 if (d.type.equals(AudioEffect.EFFECT_TYPE_AGC) && | 139 if (d.type.equals(AudioEffect.EFFECT_TYPE_AGC) |
146 d.uuid.equals(AOSP_AUTOMATIC_GAIN_CONTROL)) { | 140 && d.uuid.equals(AOSP_AUTOMATIC_GAIN_CONTROL)) { |
147 return true; | 141 return true; |
148 } | 142 } |
149 } | 143 } |
150 return false; | 144 return false; |
151 } | 145 } |
152 | 146 |
153 // Returns true if the platform NS should be excluded based on its UUID. | 147 // Returns true if the platform NS should be excluded based on its UUID. |
154 // AudioEffect.queryEffects() can throw IllegalStateException. | 148 // AudioEffect.queryEffects() can throw IllegalStateException. |
155 @TargetApi(18) | 149 @TargetApi(18) |
156 private static boolean isNoiseSuppressorExcludedByUUID() { | 150 private static boolean isNoiseSuppressorExcludedByUUID() { |
157 for (Descriptor d : getAvailableEffects()) { | 151 for (Descriptor d : getAvailableEffects()) { |
158 if (d.type.equals(AudioEffect.EFFECT_TYPE_NS) && | 152 if (d.type.equals(AudioEffect.EFFECT_TYPE_NS) && d.uuid.equals(AOSP_NOISE_
SUPPRESSOR)) { |
159 d.uuid.equals(AOSP_NOISE_SUPPRESSOR)) { | |
160 return true; | 153 return true; |
161 } | 154 } |
162 } | 155 } |
163 return false; | 156 return false; |
164 } | 157 } |
165 | 158 |
166 // Returns true if the device supports Acoustic Echo Cancellation (AEC). | 159 // Returns true if the device supports Acoustic Echo Cancellation (AEC). |
167 @TargetApi(18) | 160 @TargetApi(18) |
168 private static boolean isAcousticEchoCancelerEffectAvailable() { | 161 private static boolean isAcousticEchoCancelerEffectAvailable() { |
169 return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AEC); | 162 return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AEC); |
170 } | 163 } |
171 | 164 |
172 // Returns true if the device supports Automatic Gain Control (AGC). | 165 // Returns true if the device supports Automatic Gain Control (AGC). |
173 @TargetApi(18) | 166 @TargetApi(18) |
174 private static boolean isAutomaticGainControlEffectAvailable() { | 167 private static boolean isAutomaticGainControlEffectAvailable() { |
175 return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AGC); | 168 return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AGC); |
176 } | 169 } |
177 | 170 |
178 // Returns true if the device supports Noise Suppression (NS). | 171 // Returns true if the device supports Noise Suppression (NS). |
179 @TargetApi(18) | 172 @TargetApi(18) |
180 private static boolean isNoiseSuppressorEffectAvailable() { | 173 private static boolean isNoiseSuppressorEffectAvailable() { |
181 return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_NS); | 174 return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_NS); |
182 } | 175 } |
183 | 176 |
184 // Returns true if all conditions for supporting the HW AEC are fulfilled. | 177 // Returns true if all conditions for supporting the HW AEC are fulfilled. |
185 // It will not be possible to enable the HW AEC if this method returns false. | 178 // It will not be possible to enable the HW AEC if this method returns false. |
186 public static boolean canUseAcousticEchoCanceler() { | 179 public static boolean canUseAcousticEchoCanceler() { |
187 boolean canUseAcousticEchoCanceler = | 180 boolean canUseAcousticEchoCanceler = isAcousticEchoCancelerSupported() |
188 isAcousticEchoCancelerSupported() | |
189 && !WebRtcAudioUtils.useWebRtcBasedAcousticEchoCanceler() | 181 && !WebRtcAudioUtils.useWebRtcBasedAcousticEchoCanceler() |
190 && !isAcousticEchoCancelerBlacklisted() | 182 && !isAcousticEchoCancelerBlacklisted() && !isAcousticEchoCancelerExclud
edByUUID(); |
191 && !isAcousticEchoCancelerExcludedByUUID(); | 183 Logging.d(TAG, "canUseAcousticEchoCanceler: " + canUseAcousticEchoCanceler); |
192 Logging.d(TAG, "canUseAcousticEchoCanceler: " | |
193 + canUseAcousticEchoCanceler); | |
194 return canUseAcousticEchoCanceler; | 184 return canUseAcousticEchoCanceler; |
195 } | 185 } |
196 | 186 |
197 // Returns true if all conditions for supporting the HW AGC are fulfilled. | 187 // Returns true if all conditions for supporting the HW AGC are fulfilled. |
198 // It will not be possible to enable the HW AGC if this method returns false. | 188 // It will not be possible to enable the HW AGC if this method returns false. |
199 public static boolean canUseAutomaticGainControl() { | 189 public static boolean canUseAutomaticGainControl() { |
200 boolean canUseAutomaticGainControl = | 190 boolean canUseAutomaticGainControl = isAutomaticGainControlSupported() |
201 isAutomaticGainControlSupported() | |
202 && !WebRtcAudioUtils.useWebRtcBasedAutomaticGainControl() | 191 && !WebRtcAudioUtils.useWebRtcBasedAutomaticGainControl() |
203 && !isAutomaticGainControlBlacklisted() | 192 && !isAutomaticGainControlBlacklisted() && !isAutomaticGainControlExclud
edByUUID(); |
204 && !isAutomaticGainControlExcludedByUUID(); | 193 Logging.d(TAG, "canUseAutomaticGainControl: " + canUseAutomaticGainControl); |
205 Logging.d(TAG, "canUseAutomaticGainControl: " | |
206 + canUseAutomaticGainControl); | |
207 return canUseAutomaticGainControl; | 194 return canUseAutomaticGainControl; |
208 } | 195 } |
209 | 196 |
210 // Returns true if all conditions for supporting the HW NS are fulfilled. | 197 // Returns true if all conditions for supporting the HW NS are fulfilled. |
211 // It will not be possible to enable the HW NS if this method returns false. | 198 // It will not be possible to enable the HW NS if this method returns false. |
212 public static boolean canUseNoiseSuppressor() { | 199 public static boolean canUseNoiseSuppressor() { |
213 boolean canUseNoiseSuppressor = | 200 boolean canUseNoiseSuppressor = isNoiseSuppressorSupported() |
214 isNoiseSuppressorSupported() | 201 && !WebRtcAudioUtils.useWebRtcBasedNoiseSuppressor() && !isNoiseSuppress
orBlacklisted() |
215 && !WebRtcAudioUtils.useWebRtcBasedNoiseSuppressor() | |
216 && !isNoiseSuppressorBlacklisted() | |
217 && !isNoiseSuppressorExcludedByUUID(); | 202 && !isNoiseSuppressorExcludedByUUID(); |
218 Logging.d(TAG, "canUseNoiseSuppressor: " + canUseNoiseSuppressor); | 203 Logging.d(TAG, "canUseNoiseSuppressor: " + canUseNoiseSuppressor); |
219 return canUseNoiseSuppressor; | 204 return canUseNoiseSuppressor; |
220 } | 205 } |
221 | 206 |
222 static WebRtcAudioEffects create() { | 207 static WebRtcAudioEffects create() { |
223 // Return null if VoIP effects (AEC, AGC and NS) are not supported. | 208 // Return null if VoIP effects (AEC, AGC and NS) are not supported. |
224 if (!WebRtcAudioUtils.runningOnJellyBeanOrHigher()) { | 209 if (!WebRtcAudioUtils.runningOnJellyBeanOrHigher()) { |
225 Logging.w(TAG, "API level 16 or higher is required!"); | 210 Logging.w(TAG, "API level 16 or higher is required!"); |
226 return null; | 211 return null; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 Logging.d(TAG, "enable(audioSession=" + audioSession + ")"); | 278 Logging.d(TAG, "enable(audioSession=" + audioSession + ")"); |
294 assertTrue(aec == null); | 279 assertTrue(aec == null); |
295 assertTrue(agc == null); | 280 assertTrue(agc == null); |
296 assertTrue(ns == null); | 281 assertTrue(ns == null); |
297 | 282 |
298 // Add logging of supported effects but filter out "VoIP effects", i.e., | 283 // Add logging of supported effects but filter out "VoIP effects", i.e., |
299 // AEC, AEC and NS. | 284 // AEC, AEC and NS. |
300 for (Descriptor d : AudioEffect.queryEffects()) { | 285 for (Descriptor d : AudioEffect.queryEffects()) { |
301 if (effectTypeIsVoIP(d.type) || DEBUG) { | 286 if (effectTypeIsVoIP(d.type) || DEBUG) { |
302 Logging.d(TAG, "name: " + d.name + ", " | 287 Logging.d(TAG, "name: " + d.name + ", " |
303 + "mode: " + d.connectMode + ", " | 288 + "mode: " + d.connectMode + ", " |
304 + "implementor: " + d.implementor + ", " | 289 + "implementor: " + d.implementor + ", " |
305 + "UUID: " + d.uuid); | 290 + "UUID: " + d.uuid); |
306 } | 291 } |
307 } | 292 } |
308 | 293 |
309 if (isAcousticEchoCancelerSupported()) { | 294 if (isAcousticEchoCancelerSupported()) { |
310 // Create an AcousticEchoCanceler and attach it to the AudioRecord on | 295 // Create an AcousticEchoCanceler and attach it to the AudioRecord on |
311 // the specified audio session. | 296 // the specified audio session. |
312 aec = AcousticEchoCanceler.create(audioSession); | 297 aec = AcousticEchoCanceler.create(audioSession); |
313 if (aec != null) { | 298 if (aec != null) { |
314 boolean enabled = aec.getEnabled(); | 299 boolean enabled = aec.getEnabled(); |
315 boolean enable = shouldEnableAec && canUseAcousticEchoCanceler(); | 300 boolean enable = shouldEnableAec && canUseAcousticEchoCanceler(); |
316 if (aec.setEnabled(enable) != AudioEffect.SUCCESS) { | 301 if (aec.setEnabled(enable) != AudioEffect.SUCCESS) { |
317 Logging.e(TAG, "Failed to set the AcousticEchoCanceler state"); | 302 Logging.e(TAG, "Failed to set the AcousticEchoCanceler state"); |
318 } | 303 } |
319 Logging.d(TAG, "AcousticEchoCanceler: was " | 304 Logging.d(TAG, "AcousticEchoCanceler: was " + (enabled ? "enabled" : "di
sabled") |
320 + (enabled ? "enabled" : "disabled") | 305 + ", enable: " + enable + ", is now: " |
321 + ", enable: " + enable + ", is now: " | 306 + (aec.getEnabled() ? "enabled" : "disabled")); |
322 + (aec.getEnabled() ? "enabled" : "disabled")); | |
323 } else { | 307 } else { |
324 Logging.e(TAG, "Failed to create the AcousticEchoCanceler instance"); | 308 Logging.e(TAG, "Failed to create the AcousticEchoCanceler instance"); |
325 } | 309 } |
326 } | 310 } |
327 | 311 |
328 if (isAutomaticGainControlSupported()) { | 312 if (isAutomaticGainControlSupported()) { |
329 // Create an AutomaticGainControl and attach it to the AudioRecord on | 313 // Create an AutomaticGainControl and attach it to the AudioRecord on |
330 // the specified audio session. | 314 // the specified audio session. |
331 agc = AutomaticGainControl.create(audioSession); | 315 agc = AutomaticGainControl.create(audioSession); |
332 if (agc != null) { | 316 if (agc != null) { |
333 boolean enabled = agc.getEnabled(); | 317 boolean enabled = agc.getEnabled(); |
334 boolean enable = shouldEnableAgc && canUseAutomaticGainControl(); | 318 boolean enable = shouldEnableAgc && canUseAutomaticGainControl(); |
335 if (agc.setEnabled(enable) != AudioEffect.SUCCESS) { | 319 if (agc.setEnabled(enable) != AudioEffect.SUCCESS) { |
336 Logging.e(TAG, "Failed to set the AutomaticGainControl state"); | 320 Logging.e(TAG, "Failed to set the AutomaticGainControl state"); |
337 } | 321 } |
338 Logging.d(TAG, "AutomaticGainControl: was " | 322 Logging.d(TAG, "AutomaticGainControl: was " + (enabled ? "enabled" : "di
sabled") |
339 + (enabled ? "enabled" : "disabled") | 323 + ", enable: " + enable + ", is now: " |
340 + ", enable: " + enable + ", is now: " | 324 + (agc.getEnabled() ? "enabled" : "disabled")); |
341 + (agc.getEnabled() ? "enabled" : "disabled")); | |
342 } else { | 325 } else { |
343 Logging.e(TAG, "Failed to create the AutomaticGainControl instance"); | 326 Logging.e(TAG, "Failed to create the AutomaticGainControl instance"); |
344 } | 327 } |
345 } | 328 } |
346 | 329 |
347 if (isNoiseSuppressorSupported()) { | 330 if (isNoiseSuppressorSupported()) { |
348 // Create an NoiseSuppressor and attach it to the AudioRecord on the | 331 // Create an NoiseSuppressor and attach it to the AudioRecord on the |
349 // specified audio session. | 332 // specified audio session. |
350 ns = NoiseSuppressor.create(audioSession); | 333 ns = NoiseSuppressor.create(audioSession); |
351 if (ns != null) { | 334 if (ns != null) { |
352 boolean enabled = ns.getEnabled(); | 335 boolean enabled = ns.getEnabled(); |
353 boolean enable = shouldEnableNs && canUseNoiseSuppressor(); | 336 boolean enable = shouldEnableNs && canUseNoiseSuppressor(); |
354 if (ns.setEnabled(enable) != AudioEffect.SUCCESS) { | 337 if (ns.setEnabled(enable) != AudioEffect.SUCCESS) { |
355 Logging.e(TAG, "Failed to set the NoiseSuppressor state"); | 338 Logging.e(TAG, "Failed to set the NoiseSuppressor state"); |
356 } | 339 } |
357 Logging.d(TAG, "NoiseSuppressor: was " | 340 Logging.d(TAG, "NoiseSuppressor: was " + (enabled ? "enabled" : "disable
d") + ", enable: " |
358 + (enabled ? "enabled" : "disabled") | 341 + enable + ", is now: " + (ns.getEnabled() ? "enabled" : "disabl
ed")); |
359 + ", enable: " + enable + ", is now: " | |
360 + (ns.getEnabled() ? "enabled" : "disabled")); | |
361 } else { | 342 } else { |
362 Logging.e(TAG, "Failed to create the NoiseSuppressor instance"); | 343 Logging.e(TAG, "Failed to create the NoiseSuppressor instance"); |
363 } | 344 } |
364 } | 345 } |
365 } | 346 } |
366 | 347 |
367 // Releases all native audio effect resources. It is a good practice to | 348 // Releases all native audio effect resources. It is a good practice to |
368 // release the effect engine when not in use as control can be returned | 349 // release the effect engine when not in use as control can be returned |
369 // to other applications or the native resources released. | 350 // to other applications or the native resources released. |
370 public void release() { | 351 public void release() { |
(...skipping 17 matching lines...) Expand all Loading... |
388 // Noise Suppressor (NS). Note that, an extra check for support is needed | 369 // Noise Suppressor (NS). Note that, an extra check for support is needed |
389 // in each comparison since some devices includes effects in the | 370 // in each comparison since some devices includes effects in the |
390 // AudioEffect.Descriptor array that are actually not available on the device. | 371 // AudioEffect.Descriptor array that are actually not available on the device. |
391 // As an example: Samsung Galaxy S6 includes an AGC in the descriptor but | 372 // As an example: Samsung Galaxy S6 includes an AGC in the descriptor but |
392 // AutomaticGainControl.isAvailable() returns false. | 373 // AutomaticGainControl.isAvailable() returns false. |
393 @TargetApi(18) | 374 @TargetApi(18) |
394 private boolean effectTypeIsVoIP(UUID type) { | 375 private boolean effectTypeIsVoIP(UUID type) { |
395 if (!WebRtcAudioUtils.runningOnJellyBeanMR2OrHigher()) | 376 if (!WebRtcAudioUtils.runningOnJellyBeanMR2OrHigher()) |
396 return false; | 377 return false; |
397 | 378 |
398 return (AudioEffect.EFFECT_TYPE_AEC.equals(type) | 379 return (AudioEffect.EFFECT_TYPE_AEC.equals(type) && isAcousticEchoCancelerSu
pported()) |
399 && isAcousticEchoCancelerSupported()) | 380 || (AudioEffect.EFFECT_TYPE_AGC.equals(type) && isAutomaticGainControlSu
pported()) |
400 || (AudioEffect.EFFECT_TYPE_AGC.equals(type) | 381 || (AudioEffect.EFFECT_TYPE_NS.equals(type) && isNoiseSuppressorSupporte
d()); |
401 && isAutomaticGainControlSupported()) | |
402 || (AudioEffect.EFFECT_TYPE_NS.equals(type) | |
403 && isNoiseSuppressorSupported()); | |
404 } | 382 } |
405 | 383 |
406 // Helper method which throws an exception when an assertion has failed. | 384 // Helper method which throws an exception when an assertion has failed. |
407 private static void assertTrue(boolean condition) { | 385 private static void assertTrue(boolean condition) { |
408 if (!condition) { | 386 if (!condition) { |
409 throw new AssertionError("Expected condition to be true"); | 387 throw new AssertionError("Expected condition to be true"); |
410 } | 388 } |
411 } | 389 } |
412 | 390 |
413 // Returns the cached copy of the audio effects array, if available, or | 391 // Returns the cached copy of the audio effects array, if available, or |
(...skipping 19 matching lines...) Expand all Loading... |
433 return false; | 411 return false; |
434 } | 412 } |
435 for (Descriptor d : effects) { | 413 for (Descriptor d : effects) { |
436 if (d.type.equals(effectType)) { | 414 if (d.type.equals(effectType)) { |
437 return true; | 415 return true; |
438 } | 416 } |
439 } | 417 } |
440 return false; | 418 return false; |
441 } | 419 } |
442 } | 420 } |
OLD | NEW |