opentok-ios-sdk-samples-swift
opentok-ios-sdk-samples-swift copied to clipboard
Variable isResetting is never set to true or audio restart
Variables isResetting is not set to true on doRestartAudio function and causes an audio tear down that could end in a null pointer error if a restart is called for one unit (rendering or capture) while the other one has not yet start to render or capture.
Error is solved adding "isResetting = true" on top of doRestartAudio function.
fileprivate func doRestartAudio(numberOfAttempts: Int) {
UtilsHelper.log("DefaultAudioDevice::doRestartAudio: ")
isResetting = true
if recording {
let _ = self.stopCapture()
disposeAudioUnit(audioUnit: &recordingVoiceUnit)
let _ = self.startCapture()
}
if playing {
let _ = self.stopRendering()
disposeAudioUnit(audioUnit: &playoutVoiceUnit)
let _ = self.startRendering()
}
isResetting = false
}