title: Playback streaming audio with AVAudioengine (iOS)
body: <p>I want to stream audio on iOS using <code>AVAudioEngine</code>. 
  Currently I'm not sure how to do this.</p>
  
  <p>I get RTP data from the network and want to playback this audio data with <code>AVAudioEngine</code>.</p>
  
  <p>I am using the iOS <code>Network.Framework</code> to receive the network data. 
  I then decode the speech data and now want to play it back using <code>AVAudioEngine</code>.</p>
  
  <p>Here is my receive code: </p>
  
  <pre><code>connection.receiveMessage { (data, context, isComplete, error) in
      if isComplete {
  
      // decode the raw network data with Audio codec G711/G722
      let decodedData = AudioDecoder.decode(enc: data, frames: 160)
  
      // create PCMBuffer for audio data for playback
      let format = AVAudioFormat(standardFormatWithSampleRate: 8000, channels: 1)
      let buffer = AVAudioPCMBuffer(pcmFormat: format!, frameCapacity: 160)!
      buffer.frameLength = buffer.frameCapacity
  
      // TODO: now I have to copy the decodedData --&gt; buffer (AVAudioPCMBuffer)
  
      if error == nil {
         // recall receive() for next message
         self.receive(on: connection)
      }
  }
  </code></pre>
  
  <p>How do I copy the <code>decodedData</code> to my <code>AVAudioPCMBuffer</code>?
  Currently, my <code>buffer</code> var is created, but does not contain any data. </p>
  
  <p>Background information: </p>
  
  <p>My general approach would be to cache inside the PCMBuffer with a collection and playback this collection with the <code>AVAudioEngine</code>. </p>
  
  <p>Is there a better way consume the audio data directly (instantly)?</p>