title: Play audio file using Audio Units?
body: <p>I've successfully recorded audio from the microphone into an audio file using Audio Units with the help of <a href="http://www.openframeworks.cc" rel="nofollow noreferrer">openframeworks</a> and this website <a href="http://atastypixel.com/blog/using-remoteio-audio-unit" rel="nofollow noreferrer">http://atastypixel.com/blog/using-remoteio-audio-unit</a>.</p>
  
  <p>I want to be able to stream the file back to audio units and play the audio. According to <a href="https://stackoverflow.com/questions/2575651/play-an-audio-file-using-remoteio-and-audio-unit">Play an audio file using RemoteIO and Audio Unit</a> I can use ExtAudioFileOpenURL and ExtAudioFileRead. However, how do I play audio data in my buffer?</p>
  
  <p>This is what I currently have:</p>
  
  <pre><code>static OSStatus setupAudioFileRead() {
      //construct the file destination URL
      CFURLRef destinationURL = audioSystemFileURL();
      OSStatus status = ExtAudioFileOpenURL(destinationURL, &amp;audioFileRef);
      CFRelease(destinationURL);
  
      if (checkStatus(status)) { ofLog(OF_LOG_ERROR, "ofxiPhoneSoundStream: Couldn't open file to read"); return status; }
  
      while( TRUE ) {
          // Try to fill the buffer to capacity.
          UInt32 framesRead = 8000;
          status = ExtAudioFileRead( audioFileRef, &amp;framesRead, &amp;inputBufferList );
  
          // error check
          if( checkStatus(status) ) { break; }
  
          // 0 frames read means EOF.
          if( framesRead == 0 ) { break; }
  
          //play audio???
      }
  
      return noErr;
  }
  </code></pre>