title: Error in AudioFileWritePackets
body: <p>i'm just trying to capture the mic and save data to wav file ! and here is the code:</p>
  
  <pre><code>AudioFileID FileID=remoteIOplayer-&gt;mixAudioFile;
  if (inBusNumber == 16){
      AudioUnitRender(audioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData);
      OSStatus result = AudioFileWritePackets(FileID, false, (inNumberFrames * 4), NULL, mixpacketNum, &amp;inNumberFrames, ioData-&gt;mBuffers[i].mData);
      if (result != noErr){
          NSLog(@"Error Writing");
          mixpacketNum += inNumberFrames;
  }
  }
  </code></pre>
  
  <p>and i created the file correctly with the following format that also used to capture the mic:</p>
  
  <pre><code>audioFormat.mSampleRate         = 44100.00;
      audioFormat.mFormatID           = kAudioFormatLinearPCM;
      audioFormat.mFormatFlags        = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
      audioFormat.mFramesPerPacket    = 1;
      audioFormat.mChannelsPerFrame   = 1;
      audioFormat.mBitsPerChannel     = 16;
      audioFormat.mBytesPerPacket     = 2;
      audioFormat.mBytesPerFrame      = 2;
  </code></pre>
  
  <p>the error is result OSStatus    -38 fnopnerr (file not open)</p>