Disable software aec if enabled but not needed anymore (only once, user can still enable it back later)

This commit is contained in:
Sylvain Berfini 2014-07-11 16:13:30 +02:00
parent 7140f4f20d
commit 9c4731a8fc
3 changed files with 40 additions and 0 deletions

View file

@ -503,6 +503,14 @@ public class LinphoneManager implements LinphoneCoreListener {
if (prefMigrator.isMigrationNeeded()) { if (prefMigrator.isMigrationNeeded()) {
prefMigrator.doMigration(); prefMigrator.doMigration();
} }
// Some devices could be using software AEC before
// This will disable it in favor of hardware AEC if available
if (prefMigrator.isEchoMigratioNeeded()) {
Log.d("Echo canceller configuration need to be updated");
prefMigrator.doEchoMigration();
mPrefs.echoConfigurationUpdated();
}
mLc.setContext(mServiceContext); mLc.setContext(mServiceContext);
mLc.setZrtpSecretsCache(basePath + "/zrtp_secrets"); mLc.setZrtpSecretsCache(basePath + "/zrtp_secrets");

View file

@ -684,6 +684,14 @@ public class LinphonePreferences {
public int getEchoCalibration() { public int getEchoCalibration() {
return getConfig().getInt("sound", "ec_delay", -1); return getConfig().getInt("sound", "ec_delay", -1);
} }
public boolean isEchoConfigurationUpdated() {
return getConfig().getBool("app", "ec_updated", false);
}
public void echoConfigurationUpdated() {
getConfig().setBool("app", "ec_updated", true);
}
// End of audio settings // End of audio settings
// Video settings // Video settings

View file

@ -44,6 +44,30 @@ public class PreferencesMigrator {
mOldPrefs = PreferenceManager.getDefaultSharedPreferences(context); mOldPrefs = PreferenceManager.getDefaultSharedPreferences(context);
} }
public boolean isEchoMigratioNeeded() {
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc == null) {
return false;
}
if (mNewPrefs.isEchoConfigurationUpdated()) {
return false;
}
return (!lc.needsEchoCalibration() && mNewPrefs.isEchoCancellationEnabled());
}
public void doEchoMigration() {
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc == null) {
return;
}
if (!lc.needsEchoCalibration()) {
mNewPrefs.setEchoCancellation(false);
}
}
public boolean isMigrationNeeded() { public boolean isMigrationNeeded() {
int accountNumber = mOldPrefs.getInt(getString(R.string.pref_extra_accounts), -1); int accountNumber = mOldPrefs.getInt(getString(R.string.pref_extra_accounts), -1);
return accountNumber != -1; return accountNumber != -1;