Wait for call service cleanup before restoring media and stopping the native core
This commit is contained in:
1 parent
0aa7219a59
commit
6abcb869df
2 files changed
+5
-4
No files matched your search
@@ -42,7 +42,7 @@ object CallController : TelecomCallManager.Listener {
|
||||
private var radioToRestore: Long? = null
|
||||
|
||||
/** На время подготовки и разговора только звонок может запускать аудиоустройства. */
|
||||
fun blocksMedia(): Boolean = mediaPreparation?.isActive == true || _state.value?.let {
|
||||
fun blocksMedia(): Boolean = CallService.cleanupPending() || mediaPreparation?.isActive == true || _state.value?.let {
|
||||
it.preparing || it.phase == CallPhase.OUTGOING || it.phase == CallPhase.RINGING ||
|
||||
it.phase == CallPhase.WAIT_DECISION || it.phase == CallPhase.ACTIVE
|
||||
} == true
|
||||
@@ -277,7 +277,6 @@ object CallController : TelecomCallManager.Listener {
|
||||
fun serviceLost(id: Long, owner: CallService) {
|
||||
checkMain()
|
||||
if (service !== owner) return
|
||||
service = null
|
||||
LogManager.addLog("ERROR", "Call", "service destroyed during call id=$id")
|
||||
end(id, 7)
|
||||
}
|
||||
@@ -315,7 +314,7 @@ object CallController : TelecomCallManager.Listener {
|
||||
acceptSent = false
|
||||
answerWhenVisible = 0L
|
||||
videoJob?.cancel(); videoJob = null; videoSpeakerPending = false; _videoActive.value = false
|
||||
owner?.shutdown()
|
||||
val serviceReleased = owner?.shutdown() ?: CallService.pendingRelease
|
||||
_video.value = null
|
||||
proximity.stop()
|
||||
TelecomCallManager.setDisconnected(id, reason)
|
||||
@@ -329,9 +328,10 @@ object CallController : TelecomCallManager.Listener {
|
||||
_state.value = st.copy(phase = CallPhase.ENDED, reason = reason, preparing = false,
|
||||
connectionType = CallConnectionType.NONE, connectionNextHop = 0)
|
||||
syncCoreActivity()
|
||||
LogManager.addLog("INFO", "Call", "finished id=$id reason=$reason; audio/service/proximity released")
|
||||
LogManager.addLog("INFO", "Call", "finished id=$id reason=$reason serviceCleanupComplete=${serviceReleased?.isCompleted != false}")
|
||||
val released = mediaPreparation
|
||||
scope.launch {
|
||||
serviceReleased?.await()
|
||||
released?.join()
|
||||
if (!coreReady || !NativeLib.isReady() || blocksMedia()) return@launch
|
||||
val group = radioToRestore ?: return@launch
|
||||
|
||||
@@ -72,6 +72,7 @@ object NativeLib {
|
||||
runBlocking(Dispatchers.Main.immediate) {
|
||||
RadioCallController.reset()
|
||||
StreamController.reset(); CallController.reset(); ChatApplication.instance.avatars.stop(); ChatApplication.instance.memberFiles.cancel()
|
||||
CallService.requireReleased() // Не останавливать native при неподтверждённой очистке его media-владельца.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user