title: AudioConverterConvertBuffer problem with insz error
body: <p>I have a problem with the this function AudioConverterConvertBuffer. Basically I want to convert from this format</p>
  
  <pre><code>  _
  
  streamFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked |0 ;
    _streamFormat.mBitsPerChannel = 16;
    _streamFormat.mChannelsPerFrame = 2;
    _streamFormat.mBytesPerPacket = 4;
    _streamFormat.mBytesPerFrame = 4;
    _streamFormat.mFramesPerPacket = 1;
    _streamFormat.mSampleRate = 44100;
    _streamFormat.mReserved = 0;
  </code></pre>
  
  <p>to this format</p>
  
  <pre><code>_streamFormatOutput.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked|0 ;//| kAudioFormatFlagIsNonInterleaved |0;
    _streamFormatOutput.mBitsPerChannel = 16;
    _streamFormatOutput.mChannelsPerFrame = 1;
    _streamFormatOutput.mBytesPerPacket = 2;
    _streamFormatOutput.mBytesPerFrame = 2;
    _streamFormatOutput.mFramesPerPacket = 1;
    _streamFormatOutput.mSampleRate = 44100;
    _streamFormatOutput.mReserved = 0;
  </code></pre>
  
  <p>and what i want to do is to extract an audio channel(Left channel or right channel) from an LPCM buffer based on the input format to make it mono in the output format. Some logic code to convert is as follows</p>
  
  <p>This is to set the channel map for PCM output file</p>
  
  <pre><code>SInt32 channelMap[1] = {0};
   status = AudioConverterSetProperty(converter, kAudioConverterChannelMap, sizeof(channelMap), channelMap);
  </code></pre>
  
  <p>and this is to convert the buffer in a while loop</p>
  
  <pre><code>      AudioBufferList  audioBufferList;
    CMBlockBufferRef blockBuffer;
    CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampBuffer, NULL, &amp;audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &amp;blockBuffer);
    for (int y=0; y&lt;audioBufferList.mNumberBuffers; y++) {
     AudioBuffer audioBuffer = audioBufferList.mBuffers[y];
     //frames = audioBuffer.mData;
     NSLog(@"the number of channel for buffer number %d is %d",y,audioBuffer.mNumberChannels);
     NSLog(@"The buffer size is %d",audioBuffer.mDataByteSize);
     numBytesIO = audioBuffer.mDataByteSize;
  
     convertedBuf = malloc(sizeof(char)*numBytesIO);
  
  
     status = AudioConverterConvertBuffer(converter, audioBuffer.mDataByteSize, audioBuffer.mData, &amp;numBytesIO, convertedBuf);
     char errchar[10];
     NSLog(@"status audio converter convert %d",status);
     if (status != 0) {
      NSLog(@"Fail conversion");
      assert(0);
     }
     NSLog(@"Bytes converted %d",numBytesIO);
  
     status = AudioFileWriteBytes(mRecordFile, YES, countByteBuf, &amp;numBytesIO, convertedBuf);
     NSLog(@"status for writebyte %d, bytes written %d",status,numBytesIO);
  
     free(convertedBuf);
  
     if (numBytesIO != audioBuffer.mDataByteSize) {
      NSLog(@"Something wrong in writing");
      assert(0);
     }
     countByteBuf = countByteBuf + numBytesIO;
  </code></pre>
  
  <p>But the insz problem is there... so it cant convert. I would appreciate any input</p>
  
  <p>Thanks in advance</p>