Index: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java |
diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java |
index 14295c2161eaa1b805b6dc639ca2d31974e8b5f1..e02158816c950ee664b2f3045b5b86e87876a978 100644 |
--- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java |
+++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java |
@@ -24,8 +24,8 @@ import java.util.List; |
import java.util.UUID; |
// This class wraps control of three different platform effects. Supported |
-// effects are: AcousticEchoCanceler (AEC), AutomaticGainControl (AGC) and |
-// NoiseSuppressor (NS). Calling enable() will active all effects that are |
+// effects are: AcousticEchoCanceler (AEC) and NoiseSuppressor (NS). |
+// Calling enable() will active all effects that are |
// supported by the device if the corresponding |shouldEnableXXX| member is set. |
class WebRtcAudioEffects { |
private static final boolean DEBUG = false; |
@@ -36,8 +36,6 @@ class WebRtcAudioEffects { |
// The implementor field will be set to "The Android Open Source Project". |
private static final UUID AOSP_ACOUSTIC_ECHO_CANCELER = |
UUID.fromString("bb392ec0-8d4d-11e0-a896-0002a5d5c51b"); |
- private static final UUID AOSP_AUTOMATIC_GAIN_CONTROL = |
- UUID.fromString("aa8130e0-66fc-11e0-bad0-0002a5d5c51b"); |
private static final UUID AOSP_NOISE_SUPPRESSOR = |
UUID.fromString("c06c8400-8e06-11e0-9cb6-0002a5d5c51b"); |
@@ -49,16 +47,14 @@ class WebRtcAudioEffects { |
// Contains the audio effect objects. Created in enable() and destroyed |
// in release(). |
private AcousticEchoCanceler aec = null; |
- private AutomaticGainControl agc = null; |
private NoiseSuppressor ns = null; |
// Affects the final state given to the setEnabled() method on each effect. |
// The default state is set to "disabled" but each effect can also be enabled |
- // by calling setAEC(), setAGC() and setNS(). |
+ // by calling setAEC() and setNS(). |
// To enable an effect, both the shouldEnableXXX member and the static |
// canUseXXX() must be true. |
private boolean shouldEnableAec = false; |
- private boolean shouldEnableAgc = false; |
private boolean shouldEnableNs = false; |
// Checks if the device implements Acoustic Echo Cancellation (AEC). |
@@ -70,15 +66,6 @@ class WebRtcAudioEffects { |
return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isAcousticEchoCancelerEffectAvailable(); |
} |
- // Checks if the device implements Automatic Gain Control (AGC). |
- // Returns true if the device implements AGC, false otherwise. |
- public static boolean isAutomaticGainControlSupported() { |
- // Note: we're using isAutomaticGainControlEffectAvailable() instead of |
- // AutomaticGainControl.isAvailable() to avoid the expensive getEffects() |
- // OS API call. |
- return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isAutomaticGainControlEffectAvailable(); |
- } |
- |
// Checks if the device implements Noise Suppression (NS). |
// Returns true if the device implements NS, false otherwise. |
public static boolean isNoiseSuppressorSupported() { |
@@ -98,16 +85,6 @@ class WebRtcAudioEffects { |
return isBlacklisted; |
} |
- // Returns true if the device is blacklisted for HW AGC usage. |
- public static boolean isAutomaticGainControlBlacklisted() { |
- List<String> blackListedModels = WebRtcAudioUtils.getBlackListedModelsForAgcUsage(); |
- boolean isBlacklisted = blackListedModels.contains(Build.MODEL); |
- if (isBlacklisted) { |
- Logging.w(TAG, Build.MODEL + " is blacklisted for HW AGC usage!"); |
- } |
- return isBlacklisted; |
- } |
- |
// Returns true if the device is blacklisted for HW NS usage. |
public static boolean isNoiseSuppressorBlacklisted() { |
List<String> blackListedModels = WebRtcAudioUtils.getBlackListedModelsForNsUsage(); |
@@ -131,19 +108,6 @@ class WebRtcAudioEffects { |
return false; |
} |
- // Returns true if the platform AGC should be excluded based on its UUID. |
- // AudioEffect.queryEffects() can throw IllegalStateException. |
- @TargetApi(18) |
- private static boolean isAutomaticGainControlExcludedByUUID() { |
- for (Descriptor d : getAvailableEffects()) { |
- if (d.type.equals(AudioEffect.EFFECT_TYPE_AGC) |
- && d.uuid.equals(AOSP_AUTOMATIC_GAIN_CONTROL)) { |
- return true; |
- } |
- } |
- return false; |
- } |
- |
// Returns true if the platform NS should be excluded based on its UUID. |
// AudioEffect.queryEffects() can throw IllegalStateException. |
@TargetApi(18) |
@@ -162,12 +126,6 @@ class WebRtcAudioEffects { |
return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AEC); |
} |
- // Returns true if the device supports Automatic Gain Control (AGC). |
- @TargetApi(18) |
- private static boolean isAutomaticGainControlEffectAvailable() { |
- return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AGC); |
- } |
- |
// Returns true if the device supports Noise Suppression (NS). |
@TargetApi(18) |
private static boolean isNoiseSuppressorEffectAvailable() { |
@@ -184,16 +142,6 @@ class WebRtcAudioEffects { |
return canUseAcousticEchoCanceler; |
} |
- // Returns true if all conditions for supporting the HW AGC are fulfilled. |
- // It will not be possible to enable the HW AGC if this method returns false. |
- public static boolean canUseAutomaticGainControl() { |
- boolean canUseAutomaticGainControl = isAutomaticGainControlSupported() |
- && !WebRtcAudioUtils.useWebRtcBasedAutomaticGainControl() |
- && !isAutomaticGainControlBlacklisted() && !isAutomaticGainControlExcludedByUUID(); |
- Logging.d(TAG, "canUseAutomaticGainControl: " + canUseAutomaticGainControl); |
- return canUseAutomaticGainControl; |
- } |
- |
// Returns true if all conditions for supporting the HW NS are fulfilled. |
// It will not be possible to enable the HW NS if this method returns false. |
public static boolean canUseNoiseSuppressor() { |
@@ -236,25 +184,6 @@ class WebRtcAudioEffects { |
return true; |
} |
- // Call this method to enable or disable the platform AGC. It modifies |
- // |shouldEnableAgc| which is used in enable() where the actual state |
- // of the AGC effect is modified. Returns true if HW AGC is supported and |
- // false otherwise. |
- public boolean setAGC(boolean enable) { |
- Logging.d(TAG, "setAGC(" + enable + ")"); |
- if (!canUseAutomaticGainControl()) { |
- Logging.w(TAG, "Platform AGC is not supported"); |
- shouldEnableAgc = false; |
- return false; |
- } |
- if (agc != null && (enable != shouldEnableAgc)) { |
- Logging.e(TAG, "Platform AGC state can't be modified while recording"); |
- return false; |
- } |
- shouldEnableAgc = enable; |
- return true; |
- } |
- |
// Call this method to enable or disable the platform NS. It modifies |
// |shouldEnableNs| which is used in enable() where the actual state |
// of the NS effect is modified. Returns true if HW NS is supported and |
@@ -277,7 +206,6 @@ class WebRtcAudioEffects { |
public void enable(int audioSession) { |
Logging.d(TAG, "enable(audioSession=" + audioSession + ")"); |
assertTrue(aec == null); |
- assertTrue(agc == null); |
assertTrue(ns == null); |
// Add logging of supported effects but filter out "VoIP effects", i.e., |
@@ -309,24 +237,6 @@ class WebRtcAudioEffects { |
} |
} |
- if (isAutomaticGainControlSupported()) { |
- // Create an AutomaticGainControl and attach it to the AudioRecord on |
- // the specified audio session. |
- agc = AutomaticGainControl.create(audioSession); |
- if (agc != null) { |
- boolean enabled = agc.getEnabled(); |
- boolean enable = shouldEnableAgc && canUseAutomaticGainControl(); |
- if (agc.setEnabled(enable) != AudioEffect.SUCCESS) { |
- Logging.e(TAG, "Failed to set the AutomaticGainControl state"); |
- } |
- Logging.d(TAG, "AutomaticGainControl: was " + (enabled ? "enabled" : "disabled") |
- + ", enable: " + enable + ", is now: " |
- + (agc.getEnabled() ? "enabled" : "disabled")); |
- } else { |
- Logging.e(TAG, "Failed to create the AutomaticGainControl instance"); |
- } |
- } |
- |
if (isNoiseSuppressorSupported()) { |
// Create an NoiseSuppressor and attach it to the AudioRecord on the |
// specified audio session. |
@@ -354,10 +264,6 @@ class WebRtcAudioEffects { |
aec.release(); |
aec = null; |
} |
- if (agc != null) { |
- agc.release(); |
- agc = null; |
- } |
if (ns != null) { |
ns.release(); |
ns = null; |
@@ -377,7 +283,6 @@ class WebRtcAudioEffects { |
return false; |
return (AudioEffect.EFFECT_TYPE_AEC.equals(type) && isAcousticEchoCancelerSupported()) |
- || (AudioEffect.EFFECT_TYPE_AGC.equals(type) && isAutomaticGainControlSupported()) |
|| (AudioEffect.EFFECT_TYPE_NS.equals(type) && isNoiseSuppressorSupported()); |
} |