Merge pull request #7013 from vector-im/giomfo/disable_sleep_mode

Voice broadcast - Disable the sleep mode during the recording until we are able to handle it
This commit is contained in:
giomfo 2022-10-31 12:29:29 +01:00 committed by GitHub
commit 89cfac4dd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,12 +63,16 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
}
try? audioEngine.start()
// Disable the sleep mode during the recording until we are able to handle it
UIApplication.shared.isIdleTimerDisabled = true
}
func stopRecordingVoiceBroadcast() {
MXLog.debug("[VoiceBroadcastRecorderService] Stop recording voice broadcast")
audioEngine.stop()
audioEngine.inputNode.removeTap(onBus: audioNodeBus)
UIApplication.shared.isIdleTimerDisabled = false
voiceBroadcastService?.stopVoiceBroadcast(success: { [weak self] _ in
MXLog.debug("[VoiceBroadcastRecorderService] Stopped")
@ -97,6 +101,7 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
func pauseRecordingVoiceBroadcast() {
audioEngine.pause()
UIApplication.shared.isIdleTimerDisabled = false
voiceBroadcastService?.pauseVoiceBroadcast(success: { [weak self] _ in
guard let self = self else { return }
@ -118,7 +123,8 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
guard let self = self else { return }
// Update state
self.serviceDelegate?.voiceBroadcastRecorderService(self, didUpdateState: .started)
self.serviceDelegate?.voiceBroadcastRecorderService(self, didUpdateState: .resumed)
UIApplication.shared.isIdleTimerDisabled = true
}, failure: { error in
MXLog.error("[VoiceBroadcastRecorderService] Failed to resume voice broadcast", context: error)
})