Fix Crash / stop capture in wrong thread
This commit is contained in:
parent
99056a7807
commit
96ecb1d07e
@ -537,12 +537,25 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun close() {
|
fun close() {
|
||||||
|
Timber.v("## VOIP WebRtcPeerConnectionManager close() >")
|
||||||
CallService.onNoActiveCall(context)
|
CallService.onNoActiveCall(context)
|
||||||
|
audioManager.stop()
|
||||||
|
val callToEnd = currentCall
|
||||||
|
currentCall = null
|
||||||
|
// This must be done in this thread
|
||||||
|
videoCapturer?.stopCapture()
|
||||||
|
videoCapturer?.dispose()
|
||||||
|
videoCapturer = null
|
||||||
executor.execute {
|
executor.execute {
|
||||||
currentCall?.release()
|
callToEnd?.release()
|
||||||
videoCapturer?.stopCapture()
|
|
||||||
videoCapturer?.dispose()
|
if (currentCall == null) {
|
||||||
videoCapturer = null
|
Timber.v("## VOIP Dispose peerConnectionFactory as there is no need to keep one")
|
||||||
|
peerConnectionFactory?.dispose()
|
||||||
|
peerConnectionFactory = null
|
||||||
|
}
|
||||||
|
|
||||||
|
Timber.v("## VOIP WebRtcPeerConnectionManager close() executor done")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,7 +725,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||||||
Timber.v("## VOIP setCaptureFormat $format")
|
Timber.v("## VOIP setCaptureFormat $format")
|
||||||
currentCall ?: return
|
currentCall ?: return
|
||||||
executor.execute {
|
executor.execute {
|
||||||
// videoCapturer?.stopCapture()
|
// videoCapturer?.stopCapture()
|
||||||
videoCapturer?.changeCaptureFormat(format.width, format.height, format.fps)
|
videoCapturer?.changeCaptureFormat(format.width, format.height, format.fps)
|
||||||
currentCaptureMode = format
|
currentCaptureMode = format
|
||||||
currentCallsListeners.forEach { tryThis { it.onCaptureStateChanged(this) } }
|
currentCallsListeners.forEach { tryThis { it.onCaptureStateChanged(this) } }
|
||||||
@ -723,7 +736,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||||||
return currentCaptureMode
|
return currentCaptureMode
|
||||||
}
|
}
|
||||||
|
|
||||||
fun endCall() {
|
fun endCall(originatedByMe: Boolean = true) {
|
||||||
// Update service state
|
// Update service state
|
||||||
CallService.onNoActiveCall(context)
|
CallService.onNoActiveCall(context)
|
||||||
// close tracks ASAP
|
// close tracks ASAP
|
||||||
@ -737,16 +750,11 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentCall?.mxCall?.hangUp()
|
if (originatedByMe) {
|
||||||
currentCall = null
|
// send hang up event
|
||||||
audioManager.stop()
|
currentCall?.mxCall?.hangUp()
|
||||||
close()
|
|
||||||
executor.execute {
|
|
||||||
if (currentCall == null) {
|
|
||||||
peerConnectionFactory?.dispose()
|
|
||||||
peerConnectionFactory = null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
close()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onWiredDeviceEvent(event: WiredHeadsetStateReceiver.HeadsetPlugEvent) {
|
fun onWiredDeviceEvent(event: WiredHeadsetStateReceiver.HeadsetPlugEvent) {
|
||||||
@ -788,15 +796,16 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||||||
|
|
||||||
override fun onCallHangupReceived(callHangupContent: CallHangupContent) {
|
override fun onCallHangupReceived(callHangupContent: CallHangupContent) {
|
||||||
val call = currentCall ?: return
|
val call = currentCall ?: return
|
||||||
|
// Remote echos are filtered, so it's only remote hangups that i will get here
|
||||||
if (call.mxCall.callId != callHangupContent.callId) return Unit.also {
|
if (call.mxCall.callId != callHangupContent.callId) return Unit.also {
|
||||||
Timber.w("onCallHangupReceived for non active call? ${callHangupContent.callId}")
|
Timber.w("onCallHangupReceived for non active call? ${callHangupContent.callId}")
|
||||||
}
|
}
|
||||||
call.mxCall.state = CallState.Terminated
|
call.mxCall.state = CallState.Terminated
|
||||||
currentCall = null
|
endCall(false)
|
||||||
close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCallManagedByOtherSession(callId: String) {
|
override fun onCallManagedByOtherSession(callId: String) {
|
||||||
|
Timber.v("## VOIP onCallManagedByOtherSession: $callId")
|
||||||
currentCall = null
|
currentCall = null
|
||||||
CallService.onNoActiveCall(context)
|
CallService.onNoActiveCall(context)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user