1

I'm developing driver for USB video capture device. First of all, I've started with CoreMediaIO sample:

https://developer.apple.com/library/content/samplecode/CoreMediaIO/Introduction/Intro.html

The kernel extension is based on IOVideoSample. It gets data from the USB device and sends to the assistant. Kext has IOKitPersonalities based on the USB device. So the device is real and should support HotPlug. Kext main class loads when the device is plugged in and unloads when the device is plugged out.

SampleAssistant was changed only to detect my kext class. PlugIn has NoCMIOHardwarePluginLazyLoadingInfo property.

When all video capture apps are closed - hotplug works well. Terminate function is being called from kext and kext object is being unloaded without any problem.

Even if you start video capture app with the stream from the device, then close it and plug out device - hotplug also works.

It works well with QuickTime player. It can find a stream and show an image, but there is one problem.

When QuickTime (or any other video capture app) works and show stream from the device - hotplug doesn't work. If you try to plug out the device it will remain in the system and USB port won't work until you reboot Mac. According to logs - terminate function wasn't called at all. Seems that something retains a link to the device.

I've started digging into the problem.

First of all, I figured out that SampleAssistant doesn't support hotplug by default. It has notification only for device arriving (DeviceArrived). I've added "interest" notification and handle only "kIOMessageSeviceIsTerminated" message - executing DeviceRemoved function and force deleting device object, but it didn't help.

There is also a file CMIO_DPA_Sample_Server_Stream.cpp. If you go to Stream::Start function and delete "mIOSAStream.Open;" and "mIOSAStream.Start();" lines - hotplug works.

Can you please advise what can be done to solve this problem?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.