From 8036675e28643a2d1b060814048942f016bf326a Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 31 Aug 2016 16:27:39 +0200 Subject: [PATCH] Adding type of stream to RequestAudioFocus --- src/org/linphone/LinphoneManager.java | 36 +++++++++++++-------------- submodules/linphone | 2 +- submodules/msopenh264 | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index e025c5505..4b7d463be 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -66,6 +66,7 @@ import org.linphone.core.PublishState; import org.linphone.core.SubscriptionState; import org.linphone.core.TunnelConfig; import org.linphone.mediastream.Log; +import org.linphone.mediastream.MediastreamerAndroidContext; import org.linphone.mediastream.Version; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera; @@ -139,6 +140,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag private static List mPendingChatFileMessage; private static LinphoneChatMessage mUploadPendingFileMessage; + public String wizardLoginViewDomain = null; private static List simpleListeners = new ArrayList(); @@ -1069,6 +1071,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag else if (state == State.IncomingReceived || (state == State.CallIncomingEarlyMedia && mR.getBoolean(R.bool.allow_ringing_while_early_media))) { // Brighten screen for at least 10 seconds if (mLc.getCallsNb() == 1) { + requestAudioFocus(STREAM_RING); BluetoothManager.getInstance().disableBluetoothSCO(); // Just in case ringingCall = call; @@ -1082,8 +1085,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag if (state == State.Connected) { if (mLc.getCallsNb() == 1) { - requestAudioFocus(); - setAudioManagerInCallMode(); + mAudioManager.abandonAudioFocus(null); + requestAudioFocus(STREAM_VOICE_CALL); } if (Hacks.needSoftvolume()) { @@ -1096,15 +1099,14 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag setAudioManagerInCallMode(); } - if (state == State.CallReleased || state == State.Error) { + if (state == State.CallEnd || state == State.Error) { if (mLc.getCallsNb() == 0) { + Context activity = getContext(); if (mAudioFocused){ int res = mAudioManager.abandonAudioFocus(null); Log.d("Audio focus released a bit later: " + (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED ? "Granted" : "Denied")); mAudioFocused = false; } - - Context activity = getContext(); if (activity != null) { TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE); if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) { @@ -1116,17 +1118,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } } } - - if (state == State.CallEnd) { - if (mLc.getCallsNb() == 0) { - if (mIncallWakeLock != null && mIncallWakeLock.isHeld()) { - mIncallWakeLock.release(); - Log.i("Last call ended: releasing incall (CPU only) wake lock"); - } else { - Log.i("Last call ended: no incall (CPU only) wake lock were held"); - } - } - } if (state == State.CallUpdatedByRemote) { // If the correspondent proposes video while audio call boolean remoteVideo = call.getRemoteParams().getVideoEnabled(); @@ -1140,6 +1131,10 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } } } + if (state == State.OutgoingInit) { + setAudioManagerInCallMode(); + requestAudioFocus(STREAM_VOICE_CALL); + } if (state == State.StreamsRunning) { if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { @@ -1175,6 +1170,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag routeAudioToSpeaker(); setAudioManagerInCallMode(); Log.i("Set audio mode on 'Voice Communication'"); + requestAudioFocus(STREAM_VOICE_CALL); int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL); int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL); mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0); @@ -1186,6 +1182,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag routeAudioToSpeaker(); setAudioManagerInCallMode(); Log.i("Set audio mode on 'Voice Communication'"); + requestAudioFocus(STREAM_VOICE_CALL); int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL); int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL); int sampleRate = 44100; @@ -1222,9 +1219,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag private boolean isRinging; - private void requestAudioFocus(){ + private void requestAudioFocus(int stream){ if (!mAudioFocused){ - int res = mAudioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT ); + int res = mAudioManager.requestAudioFocus(null, stream, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT ); Log.d("Audio focus requested: " + (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED ? "Granted" : "Denied")); if (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) mAudioFocused=true; } @@ -1259,7 +1256,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag mVibrator.vibrate(patern, 1); } if (mRingerPlayer == null) { - requestAudioFocus(); + requestAudioFocus(STREAM_RING); mRingerPlayer = new MediaPlayer(); mRingerPlayer.setAudioStreamType(STREAM_RING); @@ -1528,6 +1525,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status, int delay_ms, Object data) { ((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL); + mAudioManager.abandonAudioFocus(null); Log.i("Set audio mode on 'Normal'"); } diff --git a/submodules/linphone b/submodules/linphone index 01df9f935..6bc186fb2 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 01df9f93533bb1526a673ae7c557ae2508747a49 +Subproject commit 6bc186fb256f7a1ff0755d42773e55f91ca4a9b3 diff --git a/submodules/msopenh264 b/submodules/msopenh264 index 7744dc572..3fe5d85ee 160000 --- a/submodules/msopenh264 +++ b/submodules/msopenh264 @@ -1 +1 @@ -Subproject commit 7744dc572470de6caf11b7e4ce7e79ba0c5efd55 +Subproject commit 3fe5d85ee4dbed91920f3a43f129d28b3dece138