Enable built-in echo canceler if available.
1. Always initialize AudioRecord with VOICE_COMMUNICATION.
2. If echo canceler is available, disable our echo suppressor.
Change-Id: Idf18d3833189a8478c1b252ebe6ce55e923280b3
diff --git a/voip/jni/rtp/AudioGroup.cpp b/voip/jni/rtp/AudioGroup.cpp
index 64db250..c031eee 100644
--- a/voip/jni/rtp/AudioGroup.cpp
+++ b/voip/jni/rtp/AudioGroup.cpp
@@ -484,7 +484,7 @@
ON_HOLD = 0,
MUTED = 1,
NORMAL = 2,
- EC_ENABLED = 3,
+ ECHO_SUPPRESSION = 3,
LAST_MODE = 3,
};
@@ -619,6 +619,10 @@
if (mode < 0 || mode > LAST_MODE) {
return false;
}
+ if (mode == ECHO_SUPPRESSION && AudioSystem::getParameters(
+ 0, String8("ec_supported")) == "ec_supported=yes") {
+ mode = NORMAL;
+ }
if (mMode == mode) {
return true;
}
@@ -775,8 +779,8 @@
AudioTrack track;
AudioRecord record;
if (track.set(AudioSystem::VOICE_CALL, sampleRate, AudioSystem::PCM_16_BIT,
- AudioSystem::CHANNEL_OUT_MONO, output) != NO_ERROR ||
- record.set(AUDIO_SOURCE_MIC, sampleRate, AudioSystem::PCM_16_BIT,
+ AudioSystem::CHANNEL_OUT_MONO, output) != NO_ERROR || record.set(
+ AUDIO_SOURCE_VOICE_COMMUNICATION, sampleRate, AudioSystem::PCM_16_BIT,
AudioSystem::CHANNEL_IN_MONO, input) != NO_ERROR) {
LOGE("cannot initialize audio device");
return false;