Voice broadcast connection error handling while recording (#7282)

This commit is contained in:
Yoan Pintas
2023-01-18 16:27:13 +00:00
committed by GitHub
parent 152fc60aa1
commit d34cebc6be
13 changed files with 152 additions and 49 deletions
@@ -116,6 +116,8 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
// Discard the service on VoiceBroadcastService error. We keep the service in case of other error type
if error as? VoiceBroadcastServiceError != nil {
self.tearDownVoiceBroadcastService()
} else {
AppDelegate.theDelegate().showError(asAlert: error)
}
})
}
@@ -136,6 +138,10 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
}
}, failure: { error in
MXLog.error("[VoiceBroadcastRecorderService] Failed to pause voice broadcast", context: error)
// Pause voice broadcast recording without sending pending events.
if error is VoiceBroadcastServiceError == false {
AppDelegate.theDelegate().showError(asAlert: error)
}
})
}
@@ -151,6 +157,9 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
UIApplication.shared.isIdleTimerDisabled = true
}, failure: { error in
MXLog.error("[VoiceBroadcastRecorderService] Failed to resume voice broadcast", context: error)
if error is VoiceBroadcastServiceError == false {
AppDelegate.theDelegate().showError(asAlert: error)
}
})
}
@@ -169,6 +178,15 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
self.tearDownVoiceBroadcastService()
}
func pauseOnErrorRecordingVoiceBroadcast() {
audioEngine.pause()
UIApplication.shared.isIdleTimerDisabled = false
invalidateTimer()
// Update state
self.serviceDelegate?.voiceBroadcastRecorderService(self, didUpdateState: .error)
}
// MARK: - Private
/// Reset chunk values.
private func resetValues() {