简体   繁体   中英

AudioKit crashes on device, but not simulator

In the below code AudioKit.start() crashes on my iPhone SE with iOS 10.1.1. It works fine on the Simulator.

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

The console error log is

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

What have I missed? I can't find any documentation about any needed extra setup for devices compared to the simulator. The version of AudioKit is 3.5. XCode version is 8.1

I found the issue. I had a recording category set for the audio session. By making sure that the audio session category isn't AVAudioSessionCategoryRecord on playback; my app doesn't crash anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM