From e45e8b822970e04634ea3cc6a760ce0330737550 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 2 Feb 2017 21:23:43 +0100 Subject: [PATCH] Fix AudioManager mode. It shall be set to MODE_RINGTONE when playing the local ring, and MODE_IN_COMMUNICATION in Connected state. Before this commit MODE_IN_COMMUNICATION was only set for outgoing calls, not incoming, which is bad. --- src/org/linphone/LinphoneManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index 2c77c0fd9..a69abd887 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -1204,6 +1204,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag if (state == State.Connected) { if (mLc.getCallsNb() == 1) { + //It is for incoming calls, because outgoing calls enter MODE_IN_COMMUNICATION immediately when they start. + //However, incoming call first use the MODE_RINGING to play the local ring. + setAudioManagerInCallMode(); mAudioManager.abandonAudioFocus(null); requestAudioFocus(STREAM_VOICE_CALL); } @@ -1214,10 +1217,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } } - if (state == State.OutgoingEarlyMedia) { - setAudioManagerInCallMode(); - } - if (state == State.CallEnd || state == State.Error) { if (mLc.getCallsNb() == 0) { Context activity = getContext(); @@ -1257,6 +1256,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } } if (state == State.OutgoingInit) { + //Enter the MODE_IN_COMMUNICATION mode as soon as possible, so that ringback + //is heard normally in earpiece or bluetooth receiver. setAudioManagerInCallMode(); requestAudioFocus(STREAM_VOICE_CALL); startBluetooth(); @@ -1375,8 +1376,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag routeAudioToSpeaker(); // Need to be able to ear the ringtone during the early media } - if (Hacks.needGalaxySAudioHack()) - mAudioManager.setMode(MODE_RINGTONE); + //if (Hacks.needGalaxySAudioHack()) + mAudioManager.setMode(MODE_RINGTONE); try { if ((mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE || mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) && mVibrator != null) {