某dac设备插上mac后,试图用代码打开,返回错误代码设备被独占,在cocoachina以及csdn、Stack Overflow上所搜可以得知,只需要制作一个codeless kext即可在设备插上的时候阻止被系统捕获。
ioregistery是必须的工具
SampleUSBAudioOverrideDriver 苹果给了一个demo但是并没有在此基础上修改得到正确的结果,还是自己新建了一个工程,修改info.plist得到了结果。
github上搜索codeless kext 得到的比较有参考性。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.leo.kext.test3</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018年 </string>
<key>OSBundleLibraries</key>
<dict>
<key>com.apple.kpi.libkern</key>
<string>10.2</string>
</dict>
<key>IOKitPersonalities</key>
<dict>
<key>SampleUSBAudioDevice</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.kpi.iokit</string>
<key>IOClass</key>
<string>IOService</string>
<key>IOProviderClass</key>
<string>IOUSBInterface</string>
<key>bConfigurationValue</key>
<integer>1</integer>
<key>bInterfaceNumber</key>
<integer>0</integer>
<key>bcdDevice</key>
<integer>0x001</integer>
<key>idProduct</key>
<integer>001</integer>
<key>idVendor</key>
<integer>001</integer>
</dict>
</dict>
</dict>
</plist>
驱动安装上以后在ioregistry中对应设备下会出现一个ioservice 这样就对了
不过能打开但是还不能写入,暂时搁置了。
测试用的代码在github上叫 LTIOUSB