fix: Make recorder less error-prone (#189)

* Abort recording if failed to start or empty frames

* Activate Audio Session on `cameraQueue`

* Double-check stop recording in callback

* Only call callback once

* Format

* Add description to `.aborted` error

* Update RecordingSession.swift

* Update AVAudioSession+updateCategory.swift

* Rename serial dispatch queues
This commit is contained in:
Marc Rousavy
2021-06-09 14:56:56 +02:00
committed by GitHub
parent 02168e1f28
commit 5919d46a46
7 changed files with 97 additions and 35 deletions

View File

@@ -188,6 +188,7 @@ enum CaptureError {
case invalidPhotoCodec
case videoNotEnabled
case photoNotEnabled
case aborted
case unknown(message: String? = nil)
var code: String {
@@ -210,6 +211,8 @@ enum CaptureError {
return "video-not-enabled"
case .photoNotEnabled:
return "photo-not-enabled"
case .aborted:
return "aborted"
case .unknown:
return "unknown"
}
@@ -235,6 +238,8 @@ enum CaptureError {
return "Video capture is disabled! Pass `video={true}` to enable video recordings."
case .photoNotEnabled:
return "Photo capture is disabled! Pass `photo={true}` to enable photo capture."
case .aborted:
return "The capture has been stopped before any input data arrived."
case let .unknown(message: message):
return message ?? "An unknown error occured while capturing a video/photo."
}