fix: AVWriter status 1 crash (#996)
* Fix AVWriter status 1 crash followup * Update RecordingSession.swift removing trailing semicolon to make linter happy * Update RecordingSession.swift Set hasRunningWritingAttempt to true * Update RecordingSession.swift * Update RecordingSession.swift * Update RecordingSession.swift * Update RecordingSession.swift Make the linter hate me again * Update RecordingSession.swift
This commit is contained in:
parent
fce7994d40
commit
83943da112
@ -33,6 +33,7 @@ class RecordingSession {
|
|||||||
private var initialTimestamp: CMTime?
|
private var initialTimestamp: CMTime?
|
||||||
private var latestTimestamp: CMTime?
|
private var latestTimestamp: CMTime?
|
||||||
private var hasWrittenFirstVideoFrame = false
|
private var hasWrittenFirstVideoFrame = false
|
||||||
|
private var isFinishing = false
|
||||||
|
|
||||||
var url: URL {
|
var url: URL {
|
||||||
return assetWriter.outputURL
|
return assetWriter.outputURL
|
||||||
@ -193,15 +194,22 @@ class RecordingSession {
|
|||||||
func finish() {
|
func finish() {
|
||||||
ReactLogger.log(level: .info, message: "Finishing Recording with AssetWriter status \"\(assetWriter.status.descriptor)\"...")
|
ReactLogger.log(level: .info, message: "Finishing Recording with AssetWriter status \"\(assetWriter.status.descriptor)\"...")
|
||||||
|
|
||||||
|
if isFinishing {
|
||||||
|
ReactLogger.log(level: .warning, message: "Tried calling finish() twice while AssetWriter is still writing!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !hasWrittenFirstVideoFrame {
|
if !hasWrittenFirstVideoFrame {
|
||||||
let error = NSError(domain: "capture/aborted",
|
let error = NSError(domain: "capture/aborted",
|
||||||
code: 1,
|
code: 1,
|
||||||
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(self, .failed, error)
|
completionHandler(self, .failed, error)
|
||||||
} else if assetWriter.status == .writing {
|
} else if assetWriter.status == .writing {
|
||||||
|
isFinishing = true
|
||||||
|
bufferAdaptor?.assetWriterInput.markAsFinished()
|
||||||
|
audioWriter?.markAsFinished()
|
||||||
assetWriter.finishWriting {
|
assetWriter.finishWriting {
|
||||||
self.bufferAdaptor?.assetWriterInput.markAsFinished()
|
self.isFinishing = false
|
||||||
self.audioWriter?.markAsFinished()
|
|
||||||
self.completionHandler(self, self.assetWriter.status, self.assetWriter.error)
|
self.completionHandler(self, self.assetWriter.status, self.assetWriter.error)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user