Switch audio to voice communication mode before launching echo canceller and returning to the normal mode after
This commit is contained in:
parent
9ba7065d86
commit
c95b546dc5
2 changed files with 13 additions and 3 deletions
|
@ -1112,11 +1112,12 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
|
||||
public void startEcCalibration(LinphoneCoreListener l) throws LinphoneCoreException {
|
||||
routeAudioToSpeaker();
|
||||
Compatibility.setAudioManagerInCallMode((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE));
|
||||
Log.i("Set audio mode on 'Voice Communication'");
|
||||
int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL);
|
||||
int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL);
|
||||
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0);
|
||||
mLc.startEchoCalibration(l);
|
||||
|
||||
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, oldVolume, 0);
|
||||
}
|
||||
|
||||
|
@ -1505,8 +1506,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
@Override
|
||||
public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,
|
||||
int delay_ms, Object data) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL);
|
||||
Log.i("Set audio mode on 'Normal'");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
|
@ -40,8 +41,10 @@ import org.linphone.ui.LedPreference;
|
|||
import org.linphone.ui.PreferencesListFragment;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.CheckBoxPreference;
|
||||
|
@ -82,14 +85,20 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
echoCancellerCalibration.setSummary(R.string.no_echo);
|
||||
echoCancellation.setChecked(false);
|
||||
LinphonePreferences.instance().setEchoCancellation(false);
|
||||
((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL);
|
||||
Log.i("Set audio mode on 'Normal'");
|
||||
} else if (status == EcCalibratorStatus.Done) {
|
||||
echoCancellerCalibration.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
|
||||
echoCancellation.setChecked(true);
|
||||
LinphonePreferences.instance().setEchoCancellation(true);
|
||||
((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL);
|
||||
Log.i("Set audio mode on 'Normal'");
|
||||
} else if (status == EcCalibratorStatus.Failed) {
|
||||
echoCancellerCalibration.setSummary(R.string.failed);
|
||||
echoCancellation.setChecked(true);
|
||||
LinphonePreferences.instance().setEchoCancellation(true);
|
||||
((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL);
|
||||
Log.i("Set audio mode on 'Normal'");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue