Is it bad if I do not end the session when using AVFoundation?

I have written some code for a camera app like snapchat, in it the user holds a button to take a video. To try and speed up the process of going from one view to another we have gotten rid of the bellow function:

    func stopSession() {

    //if it is running then stop running
    if captureSession.isRunning {
        videoQueue().async {
            self.captureSession.stopRunning()
        }
    }

}

Instead of calling this I only use:

    func stopRecording() {

    if movieOutput.isRecording == true {
        movieOutput.stopRecording()
    }
}

This causes makes it so when the user lets go of the button it instantly changes to the preview. I have not found any errors occurring due to this. So I was wondering... Is there any problem in doing this?

728x90

1 Answers Is it bad if I do not end the session when using AVFoundation?

Don't skip stopping the session

stopRunning()

This method is used to stop the flow of data from the inputs to the outputs connected to the AVCaptureSession instance that is the receiver. This method is synchronous and blocks until the receiver has completely stopped running.

despite it will speed your process , the flow will continue which will drain the resources of the user , stopRecording only stops writing to the output file that you set here

startRecording(to:recordingDelegate:)

3 months ago