當耳機插入iOS設備時,我想直接向揚聲器播放錄製的音頻。AudioUnitRender出錯kAudioUnitErr_CannotDoInCurrentContext(-10863)
我所做的是在AURenderCallback
func中調用AudioUnitRender
,以便將音頻數據寫入AudioBuffer結構。
如果「IO緩衝區持續時間」未設置或設置爲0.020秒,則可以正常工作。如果「IO的緩存時間」是通過調用setPreferredIOBufferDuration
設置爲一個很小的值(0.005等),AudioUnitRender()
會返回一個錯誤:
kAudioUnitErr_CannotDoInCurrentContext (-10863).
任何一個可以幫助找出原因,以及如何解決它嗎?謝謝
問題已通過設置相同的採樣率與其它工作AudioUnit解決。當有多個AudioUnit同時工作時,似乎很難解釋這一點。無論如何,您提供的信息對於瞭解此錯誤代碼的原因非常有幫助。謝謝! – bjzhao