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() {
|
||||
videoInput!.requestMediaDataWhenReady(on: queue) {
|
||||
videoInput?.requestMediaDataWhenReady(on: queue) {
|
||||
// NOTE: assumeIsolated crashes on macOS with Swift 6.0, fixed in 6.1
|
||||
self.assumeIsolated { _self in
|
||||
_self.writeAllReadySamples()
|
||||
|
|
@ -243,9 +243,11 @@ actor SampleWriter {
|
|||
if !hasMoreAudio { log.debug("Finished encoding audio") }
|
||||
}
|
||||
|
||||
let hasMoreVideo = writeReadySamples(output: videoOutput!, input: videoInput!)
|
||||
if let videoInput, let videoOutput {
|
||||
let hasMoreVideo = writeReadySamples(output: videoOutput, input: videoInput)
|
||||
if !hasMoreVideo { log.debug("Finished encoding video") }
|
||||
}
|
||||
}
|
||||
|
||||
private func writeReadySamples(output: AVAssetReaderOutput, input: AVAssetWriterInput) -> Bool {
|
||||
while input.isReadyForMoreMediaData {
|
||||
|
|
|
|||
Loading…
Reference in a new issue