Fixed echo cancellation issue

This commit is contained in:
Sylvain Berfini 2014-07-10 12:30:36 +02:00
parent 75495815ef
commit 17e8947c94
3 changed files with 16 additions and 4 deletions

View file

@ -945,17 +945,16 @@ public class LinphoneManager implements LinphoneCoreListener {
public void ecCalibrationStatus(final LinphoneCore lc,final EcCalibratorStatus status, final int delayMs, public void ecCalibrationStatus(final LinphoneCore lc,final EcCalibratorStatus status, final int delayMs,
final Object data) { final Object data) {
routeAudioToReceiver();
EcCalibrationListener listener = (EcCalibrationListener) data; EcCalibrationListener listener = (EcCalibrationListener) data;
listener.onEcCalibrationStatus(status, delayMs); listener.onEcCalibrationStatus(status, delayMs);
} }
public void startEcCalibration(EcCalibrationListener l) throws LinphoneCoreException { public void startEcCalibration(EcCalibrationListener l) throws LinphoneCoreException {
routeAudioToSpeaker();
int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL); int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL);
int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL); int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL);
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0); mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0);
mLc.startEchoCalibration(l); mLc.startEchoCalibration(l);
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, oldVolume, 0); mAudioManager.setStreamVolume(STREAM_VOICE_CALL, oldVolume, 0);

View file

@ -653,6 +653,10 @@ public class LinphonePreferences {
public boolean isEchoCancellationEnabled() { public boolean isEchoCancellationEnabled() {
return getLc().isEchoCancellationEnabled(); return getLc().isEchoCancellationEnabled();
} }
public int getEchoCalibration() {
return getConfig().getInt("sound", "ec_delay", -1);
}
// End of audio settings // End of audio settings
// Video settings // Video settings

View file

@ -433,6 +433,12 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference(getString(R.string.pref_echo_cancellation_key)); CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference(getString(R.string.pref_echo_cancellation_key));
echoCancellation.setChecked(mPrefs.isEchoCancellationEnabled()); echoCancellation.setChecked(mPrefs.isEchoCancellationEnabled());
if (mPrefs.isEchoCancellationEnabled()) {
Preference echoCalibration = findPreference(getString(R.string.pref_echo_canceller_calibration_key));
echoCalibration.setSummary(String.format(getString(R.string.ec_calibrated), mPrefs.getEchoCalibration()));
}
} }
private void setAudioPreferencesListener() { private void setAudioPreferencesListener() {
@ -836,16 +842,19 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
public void run() { public void run() {
CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference(getString(R.string.pref_echo_cancellation_key)); CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference(getString(R.string.pref_echo_cancellation_key));
Preference echoCancellerCalibration = findPreference(getString(R.string.pref_echo_canceller_calibration_key)); Preference echoCancellerCalibration = findPreference(getString(R.string.pref_echo_canceller_calibration_key));
if (status == EcCalibratorStatus.DoneNoEcho) { if (status == EcCalibratorStatus.DoneNoEcho) {
echoCancellerCalibration.setSummary(R.string.no_echo); echoCancellerCalibration.setSummary(R.string.no_echo);
echoCancellation.setChecked(false); echoCancellation.setChecked(false);
LinphonePreferences.instance().setEchoCancellation(false);
} else if (status == EcCalibratorStatus.Done) { } else if (status == EcCalibratorStatus.Done) {
echoCancellerCalibration.setSummary(String.format(getString(R.string.ec_calibrated), delayMs)); echoCancellerCalibration.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
echoCancellation.setChecked(true); echoCancellation.setChecked(true);
LinphonePreferences.instance().setEchoCancellation(true);
} else if (status == EcCalibratorStatus.Failed) { } else if (status == EcCalibratorStatus.Failed) {
echoCancellerCalibration.setSummary(R.string.failed); echoCancellerCalibration.setSummary(R.string.failed);
echoCancellation.setChecked(true); echoCancellation.setChecked(true);
LinphonePreferences.instance().setEchoCancellation(true);
} }
} }
}); });