I\'m testing my app in XCode 6 and find an issue with AVAudioSession in iOS8.
When I call
[[AVAudioSession sharedInstance] setActive:NO error
I'm using AVAudioEngine and AVAudioPlayerNode to play sounds. I meet the same problem. My environment is iOS 10.
I use AVAudioSession.sharedInstance()
to handle AVAudioSession. When I run my app in simulator everything is fine, but when I switch it to my device. It failed.
I suppose that I'm using the same session to handle recording and playing. So it may cause some strange issues. In my case, I record the sound and delay 1s to play it. So when I use stopRecordingAudio()
, I add this piece of code :
if audioEngine.running {
audioEngine = AVAudioEngine() // var audioEngine = AVAudioEngine()
try! AVAudioSession.sharedInstance().setActive(false)
}
After redefining audioEngine, audioEngine had been forced to stop and session was released. Crash is never happened again.
Hope this message could help you.