mirror of
https://github.com/samsonjs/SJSAssetExportSession.git
synced 2026-03-25 08:45:50 +00:00
Fix a crash when cancelled while writing samples
Now we never force-unwrap videoInput or videoOutput. Or anything else for that matter.
This commit is contained in:
parent
2f1b859a03
commit
1e768033a1
1 changed files with 5 additions and 3 deletions
|
|
@ -229,7 +229,7 @@ actor SampleWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func startEncodingVideoTracks() {
|
private func startEncodingVideoTracks() {
|
||||||
videoInput!.requestMediaDataWhenReady(on: queue) {
|
videoInput?.requestMediaDataWhenReady(on: queue) {
|
||||||
// NOTE: assumeIsolated crashes on macOS with Swift 6.0, fixed in 6.1
|
// NOTE: assumeIsolated crashes on macOS with Swift 6.0, fixed in 6.1
|
||||||
self.assumeIsolated { _self in
|
self.assumeIsolated { _self in
|
||||||
_self.writeAllReadySamples()
|
_self.writeAllReadySamples()
|
||||||
|
|
@ -243,8 +243,10 @@ actor SampleWriter {
|
||||||
if !hasMoreAudio { log.debug("Finished encoding audio") }
|
if !hasMoreAudio { log.debug("Finished encoding audio") }
|
||||||
}
|
}
|
||||||
|
|
||||||
let hasMoreVideo = writeReadySamples(output: videoOutput!, input: videoInput!)
|
if let videoInput, let videoOutput {
|
||||||
if !hasMoreVideo { log.debug("Finished encoding video") }
|
let hasMoreVideo = writeReadySamples(output: videoOutput, input: videoInput)
|
||||||
|
if !hasMoreVideo { log.debug("Finished encoding video") }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func writeReadySamples(output: AVAssetReaderOutput, input: AVAssetWriterInput) -> Bool {
|
private func writeReadySamples(output: AVAssetReaderOutput, input: AVAssetWriterInput) -> Bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue