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

Unified Diff: media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java

Issue 99033003: Enable platform echo cancellation through the AudioRecord path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java
diff --git a/media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java b/media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java
index 0c37c0a9e3a51c92e52e907ba449fcc76cd7019b..ee95b63aa942e1fb3cdada4346589fa20e1081f3 100644
--- a/media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java
+++ b/media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java
@@ -13,6 +13,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.database.ContentObserver;
+import android.media.audiofx.AcousticEchoCanceler;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
@@ -111,6 +112,14 @@ class AudioManagerAndroid {
// fails.
private static final int DEFAULT_FRAME_PER_BUFFER = 256;
+ // List of device models which have been vetted for good quality platform
+ // echo cancellation.
+ private static final Set<String> PLATFORM_AEC_MODEL_WHITELIST =
henrika (OOO until Aug 14) 2013/12/06 12:52:21 Guess you can follow this example instead of using
ajm 2013/12/10 06:37:16 Done.
+ new HashSet<String>(Arrays.asList(new String[] {
+ "Nexus 5",
+ "Nexus 7"
+ }));
+
private final AudioManager mAudioManager;
private final Context mContext;
private final long mNativeAudioManagerAndroid;
@@ -314,7 +323,7 @@ class AudioManagerAndroid {
@CalledByNative
private int getNativeOutputSampleRate() {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
String sampleRateString = mAudioManager.getProperty(
AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
return (sampleRateString == null ?
@@ -378,6 +387,20 @@ class AudioManagerAndroid {
DEFAULT_FRAME_PER_BUFFER : Integer.parseInt(framesPerBuffer));
}
+ @CalledByNative
+ public static boolean isPlatformAECSupported() {
henrika (OOO until Aug 14) 2013/12/06 12:52:21 Would it make sense to name this API to something
ajm 2013/12/06 19:06:43 Except that most (all?) devices will actually repo
Ami GONE FROM CHROMIUM 2013/12/06 19:22:53 hasAcousticEchoCanceler fails to connote that this
ajm 2013/12/10 06:37:16 Sounds good.
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+ // AcousticEchoCanceler was added in API level 16 (Jelly Bean).
Ami GONE FROM CHROMIUM 2013/12/06 19:22:53 Wouldn't this be accounted for by l.397?
ajm 2013/12/10 06:37:16 As I understand it, we'll get a crash if we try to
+ return false;
+ }
+
+ boolean isAvailable = AcousticEchoCanceler.isAvailable();
+ boolean isWhitelisted = PLATFORM_AEC_MODEL_WHITELIST.contains(Build.MODEL);
tommi (sloooow) - chröme 2013/12/06 12:11:34 nit: Since the list contains only two items, you p
ajm 2013/12/06 19:06:43 My initial implementation had all conditions in th
ajm 2013/12/10 06:37:16 Changed as recommended now.
+ logd("AcousticEchoCanceler.isAvailable: " + isAvailable);
+ logd("Build.MODEL: " + Build.MODEL + " isWhitelisted: " + isWhitelisted);
Ami GONE FROM CHROMIUM 2013/12/06 19:22:53 I don't think these are worth spamming logcat for.
ajm 2013/12/10 06:37:16 Done.
+ return isAvailable && isWhitelisted;
+ }
+
/** Sets the speaker phone mode. */
public void setSpeakerphoneOn(boolean on) {
boolean wasOn = mAudioManager.isSpeakerphoneOn();
@@ -603,12 +626,12 @@ class AudioManagerAndroid {
}
/** Trivial helper method for debug logging */
- private void logd(String msg) {
+ private static void logd(String msg) {
Log.d(TAG, msg);
}
/** Trivial helper method for error logging */
- private void loge(String msg) {
+ private static void loge(String msg) {
Log.e(TAG, msg);
}

Powered by Google App Engine
This is Rietveld 408576698