mikebuss/MTBBarcodeScanner — pull request #4 by brandonschlenker (2014-06-23 00:00:37+00:00)
Title: stopScanning AVCaptureSession cleanup bug fixes

Previously stopScanning did not correctly discard the existing session. This often resulted in the main thread infinitely locking on -[AVCaptureMetadataOutputInternal dealloc]. Using my iPhone 5 I was able to reproduce this every time in the given sample project when stopScanning was called in viewWillDisappear or viewDidDisappear.

I've modified stopScanning to perform the cleanup necessary to resolve the issue.
[AVCaptureSession removeOutput] and [AVCaptureSession removeInput] often take a significant amount of time so these calls dispatched to a background thread.

I've also slightly modified the code to create new AVCaptureSessions and AVCaptureDevices. These are no longer directly attached to self.session and self.capture device.

https://gist.github.com/brandonschlenker/091d8a22ff5598244f5b