opentok-ios-sdk-samples-swift icon indicating copy to clipboard operation
opentok-ios-sdk-samples-swift copied to clipboard

Variable isResetting is never set to true or audio restart

Open jlorente opened this issue 4 years ago • 0 comments

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
    }

jlorente avatar Nov 17 '20 10:11 jlorente