Skip to content

Commit

Permalink
moved decoding calculation into different queue
Browse files Browse the repository at this point in the history
  • Loading branch information
aslanyanhaik committed May 7, 2020
1 parent 05f7174 commit 783ac44
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/Public/RCCameraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ extension RCCameraViewController {
input.device.activeVideoMaxFrameDuration = CMTimeMake(value: 1, timescale: 30)
captureSession.addInput(input)
let videoOutput = AVCaptureVideoDataOutput()
videoOutput.setSampleBufferDelegate(self, queue: .main)
videoOutput.setSampleBufferDelegate(self, queue: DispatchQueue.global(qos: .userInteractive))
videoOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: NSNumber(value: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)]
captureSession.addOutput(videoOutput)
} catch {
Expand Down Expand Up @@ -197,8 +197,10 @@ extension RCCameraViewController: AVCaptureVideoDataOutputSampleBufferDelegate {
coder.imageDecoder.bytesPerRow = bytesPerRow
if let message = try? coder.decode(buffer: lumaCopy.assumingMemoryBound(to: UInt8.self)) {
captureSession.stopRunning()
delegate?.cameraViewController(didFinishScanning: message)
dismiss(animated: true)
DispatchQueue.main.async {[weak self] in
self?.delegate?.cameraViewController(didFinishScanning: message)
self?.dismiss(animated: true)
}
}
lumaCopy.deallocate()
CVPixelBufferUnlockBaseAddress(pixelBuffer, .readOnly)
Expand Down

0 comments on commit 783ac44

Please sign in to comment.