CameraEngine icon indicating copy to clipboard operation
CameraEngine copied to clipboard

"unable to add mic as InputDevice"

Open otymartin opened this issue 7 years ago • 3 comments

I keep getting this error

otymartin avatar Aug 15 '16 14:08 otymartin

I've been having the same issue.

It looks like a race condition because when we initialize a CameraEngine, it performs all session initialization in background (see setupSession() in CameraEngine.swift). As soon that the initializing part is over (on our end), we ask it to change the device (going from .Back to .Front) - causing a new call to addInputDevice that happens at the same time as the background initializer one.

screen shot 2016-09-01 at 16 56 54

delannoyk avatar Sep 01 '16 14:09 delannoyk

@delannoyk I failed to follow up but never solved the problem. Where you able to?

otymartin avatar Sep 25 '16 18:09 otymartin

You can solve it by dispatching the call to the sessionQueue (requires modifying the source code)

public func changeCurrentDevice(position: AVCaptureDevicePosition) { self.cameraDevice.changeCurrentDevice(position) // Note: to avoid multi-threading crash dispatch_async(self.sessionQueue) { () -> Void in self.configureInputDevice() } }

OlivierVoyer avatar Oct 05 '16 09:10 OlivierVoyer