Skip to content

Commit d7a6b2d

Browse files
authored
Merge pull request #104 from aws-amplify/main
chore: kickoff release
2 parents 061dd32 + 265040c commit d7a6b2d

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Sources/FaceLiveness/AV/LivenessCaptureSession.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,22 @@ class LivenessCaptureSession {
6969
}
7070

7171
func stopRunning() {
72-
if captureSession?.isRunning == true {
73-
captureSession?.stopRunning()
72+
guard let session = captureSession else { return }
73+
74+
defer {
75+
captureSession = nil
76+
}
77+
78+
if session.isRunning {
79+
session.stopRunning()
80+
}
81+
82+
for input in session.inputs {
83+
session.removeInput(input)
84+
}
85+
86+
for output in session.outputs {
87+
session.removeOutput(output)
7488
}
7589
}
7690

Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct CameraPreviewView: View {
3939
.position(x: geometry.size.width*Self.previewXPositionRatio,
4040
y: geometry.size.height*Self.previewYPositionRatio)
4141
}
42+
}.onDisappear {
43+
model.stopSession()
4244
}
4345
}
4446
}

Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewViewModel.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CameraPreviewViewModel: NSObject, ObservableObject {
3333
)
3434

3535
do {
36-
try self.previewCaptureSession?.startSession()
36+
try previewCaptureSession?.startSession()
3737
} catch {
3838
Amplify.Logging.default.error("Error starting preview capture session with error: \(error)")
3939
}
@@ -47,6 +47,10 @@ class CameraPreviewViewModel: NSObject, ObservableObject {
4747
}
4848
.assign(to: &$currentImageFrame)
4949
}
50+
51+
func stopSession() {
52+
previewCaptureSession?.stopRunning()
53+
}
5054
}
5155

5256
extension CameraPreviewViewModel: AVCaptureVideoDataOutputSampleBufferDelegate {

0 commit comments

Comments
 (0)