2

在下面的代码中,AudioKit.start() 在装有 iOS 10.1.1 的 iPhone SE 上崩溃。它在模拟器上运行良好。

private func play(note: Int) {
  let pluckedString = AKPluckedString()
  AudioKit.output = pluckedString
  AudioKit.start() // <-- Crash here!
  let frequency = note.midiNoteToFrequency()
  pluckedString.trigger(frequency: frequency)
}

控制台错误日志是

2016-12-04 10:51:45.765130 MyApp[1833:720319] [aurioc] 889: failed: -10851 (enable 2, outf< 2 ch,      0 Hz, Float32, non-inter> inf< 2 ch,      0 Hz, Float32, non-inter>)
2016-12-04 10:51:45.766519 MyApp[1833:720319] [aurioc] 889: failed: -10851 (enable 2, outf< 2 ch,  44100 Hz, Float32, non-inter> inf< 2 ch,      0 Hz, Float32, non-inter>)
2016-12-04 10:51:45.767008 MyApp[1833:720319] [aurioc] 889: failed: -10851 (enable 2, outf< 2 ch,  44100 Hz, Float32, non-inter> inf< 2 ch,      0 Hz, Float32, non-inter>)
2016-12-04 10:51:45.767982 MyApp[1833:720319] [central] 54:   ERROR:    [0x1b42d7c40] >avae> AVAudioEngineGraph.mm:2515: PerformCommand: error -10851

我错过了什么?与模拟器相比,我找不到任何有关设备所需额外设置的文档。AudioKit的版本是 3.5。XCode 版本是 8.1

4

1 回答 1

2

我发现了这个问题。我为音频会话设置了录制类别。通过确保音频会话类别在播放时不是 AVAudioSessionCategoryRecord;我的应用程序不再崩溃。

于 2016-12-07T20:15:35.680 回答