From a9f7fb46b346ca1719de61c42ab5f9a2b53c83ed Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 12 Oct 2020 15:06:49 +0200 Subject: [PATCH] Fix for ticket #2246: Ringtone volume cannot bechanged while ringing This fix delays the creation of the audioManager until the call is connected. This way the call feature does not takes the focus from the core service (where the ringtone is generated) until the call is esablished. This way the volume can be controled correctly while the phone is ringing (incoming and outgoing). --- .../main/java/im/vector/app/core/services/CallRingPlayer.kt | 2 +- .../java/im/vector/app/features/call/CallAudioManager.kt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt index 71733c7f07..d5d8bb14dd 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt @@ -95,7 +95,7 @@ class CallRingPlayerOutgoing( } else { mediaPlayer.setAudioAttributes(AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) - .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING) + .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION) .build()) } return mediaPlayer diff --git a/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt b/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt index 9b3c42ab5d..73d25662cd 100644 --- a/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt @@ -93,6 +93,10 @@ class CallAudioManager( fun startForCall(mxCall: MxCall) { Timber.v("## VOIP: AudioManager startForCall ${mxCall.callId}") + } + + fun setupAudioManager(mxCall: MxCall) { + Timber.v("## VOIP: AudioManager setupAudioManager ${mxCall.callId}") val audioManager = audioManager ?: return savedIsSpeakerPhoneOn = audioManager.isSpeakerphoneOn savedIsMicrophoneMute = audioManager.isMicrophoneMute @@ -150,6 +154,7 @@ class CallAudioManager( fun onCallConnected(mxCall: MxCall) { Timber.v("##VOIP: AudioManager call answered, adjusting current sound device") + setupAudioManager(mxCall) adjustCurrentSoundDevice(mxCall) }