Navaron Bracke

remove unused code in MacOS impl

@@ -32,8 +32,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -32,8 +32,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
32 32
33 var symbologies:[VNBarcodeSymbology] = [] 33 var symbologies:[VNBarcodeSymbology] = []
34 34
35 - // var analyzeMode: Int = 0  
36 - var analyzing: Bool = false  
37 var position = AVCaptureDevice.Position.back 35 var position = AVCaptureDevice.Position.back
38 36
39 public static func register(with registrar: FlutterPluginRegistrar) { 37 public static func register(with registrar: FlutterPluginRegistrar) {
@@ -65,8 +63,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -65,8 +63,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
65 setScale(call, result) 63 setScale(call, result)
66 case "resetScale": 64 case "resetScale":
67 resetScale(call, result) 65 resetScale(call, result)
68 - // case "analyze":  
69 - // switchAnalyzeMode(call, result)  
70 case "stop": 66 case "stop":
71 stop(result) 67 stop(result)
72 case "updateScanWindow": 68 case "updateScanWindow":
@@ -101,12 +97,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -101,12 +97,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
101 97
102 // Gets called when a new image is added to the buffer 98 // Gets called when a new image is added to the buffer
103 public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { 99 public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
104 - // Ignore invalid textureId 100 + // Ignore invalid texture id.
105 if textureId == nil { 101 if textureId == nil {
106 return 102 return
107 } 103 }
108 guard let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { 104 guard let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else {
109 - print("Failed to get image buffer from sample buffer.")  
110 return 105 return
111 } 106 }
112 latestBuffer = imageBuffer 107 latestBuffer = imageBuffer
@@ -118,7 +113,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -118,7 +113,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
118 nextScanTime = currentTime + timeoutSeconds 113 nextScanTime = currentTime + timeoutSeconds
119 imagesCurrentlyBeingProcessed = true 114 imagesCurrentlyBeingProcessed = true
120 DispatchQueue.global(qos: .userInitiated).async { [weak self] in 115 DispatchQueue.global(qos: .userInitiated).async { [weak self] in
121 - if(self!.latestBuffer == nil){ 116 + if self!.latestBuffer == nil {
122 return 117 return
123 } 118 }
124 var cgImage: CGImage? 119 var cgImage: CGImage?
@@ -165,6 +160,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -165,6 +160,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
165 // add the symbologies the user wishes to support 160 // add the symbologies the user wishes to support
166 barcodeRequest.symbologies = self!.symbologies 161 barcodeRequest.symbologies = self!.symbologies
167 } 162 }
  163 +
168 try imageRequestHandler.perform([barcodeRequest]) 164 try imageRequestHandler.perform([barcodeRequest])
169 } catch let e { 165 } catch let e {
170 DispatchQueue.main.async { 166 DispatchQueue.main.async {
@@ -415,11 +411,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -415,11 +411,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
415 result(nil) 411 result(nil)
416 } 412 }
417 413
418 - // func switchAnalyzeMode(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {  
419 - // analyzeMode = call.arguments as! Int  
420 - // result(nil)  
421 - // }  
422 -  
423 func stop(_ result: FlutterResult) { 414 func stop(_ result: FlutterResult) {
424 if (device == nil || captureSession == nil) { 415 if (device == nil || captureSession == nil) {
425 result(nil) 416 result(nil)
@@ -436,7 +427,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -436,7 +427,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
436 device.removeObserver(self, forKeyPath: #keyPath(AVCaptureDevice.torchMode)) 427 device.removeObserver(self, forKeyPath: #keyPath(AVCaptureDevice.torchMode))
437 registry.unregisterTexture(textureId) 428 registry.unregisterTexture(textureId)
438 429
439 - // analyzeMode = 0  
440 latestBuffer = nil 430 latestBuffer = nil
441 captureSession = nil 431 captureSession = nil
442 device = nil 432 device = nil