【发布时间】:2012-05-03 10:33:14
【问题描述】:
在一个 iOS 应用项目中,我有一个音频单元(用于输入/输出)初始化代码(在设置各种属性、回调等之后)以:
OSErr err = AudioUnitInitialize (self.audioUnit);
NSAssert1 (err == noErr, "Error initializing audio unit: %ld", err);
我的问题是,在某些情况下,我必须在没有可用音频硬件的计算机上(当然是在 iPhone 模拟器中)运行此代码,然后会发生以下情况:
首先,在控制台上我收到以下消息(对不起,长线,没有额外的换行符对我来说似乎更清楚):
2012-05-03 12:41:15.020 TimeKeeper[452:10703] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-03 12:41:15.140 TimeKeeper[452:10703] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-03 12:41:15.207 TimeKeeper[452:10703] Error '!obj' trying to fetch default input device's sample rate
2012-05-03 12:41:15.209 TimeKeeper[452:10703] Error getting audio input device sample rate: '!obj'
然后大约 2 分钟左右过去了,直到 AudioUnitInitialize 返回错误代码 0(即 noErr),并且控制台上出现此消息:
2012-05-03 12:43:45.222 TimeKeeper[452:14403] AQMEIO_Base::DoStartIO: timeout
2012-05-03 12:43:45.226 TimeKeeper[452:14403] AQMEDevice(0x7b0de00)::StartIO: error -66681
如果我再调用AudioOutputUnitStart,函数再次返回大约需要2分钟,但至少返回状态不为零。
我希望能够判断音频硬件是否不可用,因此我可以避免首先调用AudioUnitInitialize --- 或者至少无需等待即可获得非零返回状态长(在应用程序运行时术语中)。
【问题讨论】:
标签: iphone ios core-audio audiounit