mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
forcing the outgoing calls to use the same audio config as the call itself
- tentatively fixes the speaker being used by previous instance changes if a reset fails
This commit is contained in:
parent
55c0f1fcb3
commit
eb8a704ee7
2 changed files with 12 additions and 3 deletions
|
@ -28,6 +28,8 @@ import android.os.VibrationEffect
|
|||
import android.os.Vibrator
|
||||
import androidx.core.content.getSystemService
|
||||
import im.vector.app.R
|
||||
import im.vector.app.features.call.audio.CallAudioManager
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
import im.vector.app.features.notifications.NotificationUtils
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import timber.log.Timber
|
||||
|
@ -94,7 +96,8 @@ class CallRingPlayerIncoming(
|
|||
}
|
||||
|
||||
class CallRingPlayerOutgoing(
|
||||
context: Context
|
||||
context: Context,
|
||||
private val callManager: WebRtcCallManager
|
||||
) {
|
||||
|
||||
private val applicationContext = context.applicationContext
|
||||
|
@ -102,7 +105,7 @@ class CallRingPlayerOutgoing(
|
|||
private var player: MediaPlayer? = null
|
||||
|
||||
fun start() {
|
||||
applicationContext.getSystemService<AudioManager>()?.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||
callManager.setAudioModeToCallType()
|
||||
player?.release()
|
||||
player = createPlayer()
|
||||
if (player != null) {
|
||||
|
@ -120,6 +123,12 @@ class CallRingPlayerOutgoing(
|
|||
}
|
||||
}
|
||||
|
||||
private fun WebRtcCallManager.setAudioModeToCallType() {
|
||||
currentCall.get()?.let {
|
||||
audioManager.setMode(if (it.mxCall.isVideoCall) CallAudioManager.Mode.VIDEO_CALL else CallAudioManager.Mode.AUDIO_CALL)
|
||||
}
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
player?.release()
|
||||
player = null
|
||||
|
|
|
@ -84,7 +84,7 @@ class CallService : VectorService() {
|
|||
super.onCreate()
|
||||
notificationManager = NotificationManagerCompat.from(this)
|
||||
callRingPlayerIncoming = CallRingPlayerIncoming(applicationContext, notificationUtils)
|
||||
callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext)
|
||||
callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext, callManager)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
Loading…
Reference in a new issue