title: Audio Unit and Writing to file
body: <p>I'm creating real-time audio sequencer app on OS X.
  Real-time synth part is implemented by using <code>AURenderCallback</code>.
  Now I'm making function to write rendered result to Wave File <code>(44100Hz 16bit Stereo)</code>.
  Format for render-callback function is 44100Hz 32bit float Stereo interleaved.</p>
  
  <p>I'm using <code>ExtAudioFileWrite</code> to write to file.
  But <code>ExtAudioFileWrite</code> function returns error code <code>1768846202</code>;</p>
  
  <p>I searched <code>1768846202</code> but I couldn't get information.
  Would you give me some hints?</p>
  
  <p>Thank you.</p>
  
  <p>Here is code.</p>
  
  <pre><code>    outFileFormat.mSampleRate = 44100;
      outFileFormat.mFormatID = kAudioFormatLinearPCM;
      outFileFormat.mFormatFlags = 
   kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
      outFileFormat.mBitsPerChannel = 16;
      outFileFormat.mChannelsPerFrame = 2;
      outFileFormat.mFramesPerPacket = 1;
      outFileFormat.mBytesPerFrame = 
   outFileFormat.mBitsPerChannel / 8 * outFileFormat.mChannelsPerFrame;
      outFileFormat.mBytesPerPacket = 
   outFileFormat.mBytesPerFrame * outFileFormat.mFramesPerPacket;
  
   AudioBufferList *ioList;
      ioList = (AudioBufferList*)calloc(1, sizeof(AudioBufferList)
           + 2 * sizeof(AudioBuffer));
      ioList-&gt;mNumberBuffers = 2;
      ioList-&gt;mBuffers[0].mNumberChannels = 1;
      ioList-&gt;mBuffers[0].mDataByteSize = allocByteSize / 2;
      ioList-&gt;mBuffers[0].mData = ioDataL;
   ioList-&gt;mBuffers[1].mNumberChannels = 1;
      ioList-&gt;mBuffers[1].mDataByteSize = allocByteSize / 2;
      ioList-&gt;mBuffers[1].mData = ioDataR;
  
  ...
  
  while (1) {
    //Fill buffer by using render callback func.
    RenderCallback(self, nil, nil, 0, frames, ioList);
  
          //i want to create one sec file.
          if (renderedFrames &gt;= 44100) break;
  
    err = ExtAudioFileWrite(outAudioFileRef, frames , ioList);
    if (err != noErr){
     NSLog(@"ERROR AT WRITING TO FILE");
     goto errorExit;
    }
      }
  </code></pre>