title: Removing AVAudioPlayerNode after use causes crash
body: <p>I'm using <code>AVAudioEngine</code>to play sound files and record the output to a file. I have lots of sound effect files, each played by tapping a button. To play the file I create an <code>AVAudioPlayerNode</code> and connects it to the engine. After the file has played I try to disconnect/detach the node in the completionHandler closure, to free up memory. If I don't remove nodes I will just keep adding new nodes and new connections to the engine.</p>
  
  <p>However, the next time I try to play a file, the app just freezes. Here's my code:</p>
  
  <pre><code>let url = NSBundle.mainBundle().URLForResource(name, withExtension: "wav")!
  let audioPlayerFile = try AVAudioFile(forReading: url)
  let playerNode = AVAudioPlayerNode()
  self.engine.attachNode(playerNode)
  self.engine.connect(playerNode, to: self.engine.mainMixerNode, format: audioPlayerFile.processingFormat)
  playerNode.scheduleFile(audioPlayerFile, atTime: nil, completionHandler: { () -&gt; Void in
      self.engine.disconnectNodeOutput(playerNode)
      self.engine.detachNode(playerNode)
  })
  playerNode.play()
  </code></pre>
  
  <p>What's the best way to implement a functionality like this, i.e. playing multiple files, potentially overlapping each other, while recording?</p>