fix: AVAssetWriter status is 1 crash (#995)

fixes #930

markAsFinished has to be called within the finishWritingWithCompletionHandler.
Moving that 2 lines allowed me to spam start / stop for hundreds of time without a single crash.
This commit is contained in:
Hirbod 2022-04-15 09:45:31 +02:00 committed by GitHub
parent 485f33eb1c
commit 2ccce3587d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -199,9 +199,9 @@ class RecordingSession {
userInfo: [NSLocalizedDescriptionKey: "Stopped Recording Session too early, no frames have been recorded!"]) userInfo: [NSLocalizedDescriptionKey: "Stopped Recording Session too early, no frames have been recorded!"])
completionHandler(.failed, error) completionHandler(.failed, error)
} else if assetWriter.status == .writing { } else if assetWriter.status == .writing {
bufferAdaptor?.assetWriterInput.markAsFinished()
audioWriter?.markAsFinished()
assetWriter.finishWriting { assetWriter.finishWriting {
self.bufferAdaptor?.assetWriterInput.markAsFinished()
self.audioWriter?.markAsFinished()
self.completionHandler(self.assetWriter.status, self.assetWriter.error) self.completionHandler(self.assetWriter.status, self.assetWriter.error)
} }
} else { } else {