Index: media/audio/android/audio_manager_android.cc |
diff --git a/media/audio/android/audio_manager_android.cc b/media/audio/android/audio_manager_android.cc |
index b588768bbd08c1fcfbb75df70248a9da752a28a4..104f70d465ddb545747a9c6201cc5ae2808ba8de 100644 |
--- a/media/audio/android/audio_manager_android.cc |
+++ b/media/audio/android/audio_manager_android.cc |
@@ -11,6 +11,7 @@ |
#include "base/logging.h" |
#include "base/strings/string_number_conversions.h" |
#include "jni/AudioManagerAndroid_jni.h" |
+#include "media/audio/android/audio_record_input.h" |
#include "media/audio/android/opensles_input.h" |
#include "media/audio/android/opensles_output.h" |
#include "media/audio/audio_manager.h" |
@@ -103,18 +104,25 @@ void AudioManagerAndroid::GetAudioOutputDeviceNames( |
AudioParameters AudioManagerAndroid::GetInputStreamParameters( |
const std::string& device_id) { |
+ JNIEnv* env = AttachCurrentThread(); |
// Use mono as preferred number of input channels on Android to save |
// resources. Using mono also avoids a driver issue seen on Samsung |
// Galaxy S3 and S4 devices. See http://crbug.com/256851 for details. |
ChannelLayout channel_layout = CHANNEL_LAYOUT_MONO; |
int buffer_size = Java_AudioManagerAndroid_getMinInputFrameSize( |
- base::android::AttachCurrentThread(), GetNativeOutputSampleRate(), |
+ env, GetNativeOutputSampleRate(), |
ChannelLayoutToChannelCount(channel_layout)); |
- return AudioParameters( |
+ AudioParameters params( |
AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, |
GetNativeOutputSampleRate(), 16, |
buffer_size <= 0 ? kDefaultInputBufferSize : buffer_size); |
+ |
+ AudioParameters::PlatformEffects effects; |
+ effects.echo_canceller = |
+ Java_AudioManagerAndroid_shouldUseAcousticEchoCanceler(env); |
+ params.SetPlatformEffects(effects); |
+ return params; |
} |
AudioOutputStream* AudioManagerAndroid::MakeAudioOutputStream( |
@@ -189,6 +197,20 @@ AudioInputStream* AudioManagerAndroid::MakeLowLatencyInputStream( |
// device, i.e., this selection does also switch the output device. |
// All input and output streams will be affected by the device selection. |
SetAudioDevice(device_id); |
+ |
+ if (params.effects().echo_canceller) { |
+ // Platform effects can only be enabled through the AudioRecord path. |
+ // An effect should only have been requested here if recommended by |
+ // AudioManagerAndroid.shouldUse<Effect>. |
+ // |
+ // Creating this class requires Jelly Bean, which is already guaranteed by |
+ // shouldUse<Effect>. Only DCHECK on that condition to allow tests to use |
+ // the effect settings as a way to select the input path. |
+ DCHECK_GE(base::android::BuildInfo::GetInstance()->sdk_int(), 16); |
+ DVLOG(1) << "Creating AudioRecordInputStream"; |
+ return new AudioRecordInputStream(this, params); |
+ } |
+ DVLOG(1) << "Creating OpenSLESInputStream"; |
return new OpenSLESInputStream(this, params); |
} |