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