【发布时间】:2020-10-25 21:10:50
【问题描述】:
连接节点时出错
let sourceNode = AVAudioSinkNode { (test1, frameCount, audioBufferList) -> OSStatus in
print("callback", self.testInteger)
return noErr
}
audioEngine.attach(sourceNode)
audioEngine.connect(audioEngine.inputNode, to: sourceNode, format: nil)
[aurioc] AURemoteIO.cpp: 1086: Initialize: failed: -10851 (启用 1, outf inf )
然后try audioEngine.start () 出现错误
[avae] AVAEInternal.h: 88 所需条件为假:[AVAudioEngineGraph.mm:1415:Initialize: (IsFormatSampleRateAndChannelCountValid (inputHWFormat))] [avae] AVAudioEngine.mm:160 Engine @ 0x2836a8940: 无法初始化,错误 = -10875 [avae] AVAEInternal.h: 88 所需条件为假:[AVAudioEngineGraph.mm:1415:Initialize: (IsFormatSampleRateAndChannelCountValid (inputHWFormat))]
我也试过
audioEngine.connect (audioEngine.inputNode, to: sourceNode, format: audioEngine.inputNode.inputFormat (forBus: 0))
和
audioEngine.connect (audioEngine.inputNode, to: sourceNode, format: audioEngine.inputNode.outputFormat (forBus: 0))
在这两种情况下,应用程序崩溃并出现错误 “由于未捕获的异常'com.apple.coreaudio.avfaudio'而终止应用程序,原因:'所需条件为假:IsFormatSampleRateAndChannelCountValid(格式)”
【问题讨论】:
-
format: nil错误。 -
@matt 是的,我意识到这是错误的,但我仍然不明白我应该改用什么,我尝试了其他格式(我在我的问题中写过)但它们也不起作用.你能告诉我应该使用哪种格式吗?
标签: swift avfoundation core-audio avaudioengine