2016-12-04 123 views
2

在下面的代碼中,AudioKit.start()在iOS 10.1.1的iPhone SE上崩潰。它可以在模擬器上正常工作。AudioKit在設備上崩潰,但不是模擬器

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

回答

2

我發現了這個問題。我爲音頻會話設置了一個錄音類別。通過確保音頻會話類別在播放時不是AVAudioSessionCategoryRecord;我的應用程序不再崩潰了。

相關問題