Can anyone explain AudioConverterFillComplexBuffer returning 1768846202 - Input Size Error (insz) ?
Can anyone explain AudioConverterFillComplexBuffer returning 1768846202 - Input Size Error (insz) ?
- Subject: Can anyone explain AudioConverterFillComplexBuffer returning 1768846202 - Input Size Error (insz) ?
- From: wm schauweker <email@hidden>
- Date: Sun, 17 Jan 2010 13:39:29 -0800 (PST)
I'm sorry to bother folks on this list again, but I have not been able to track down this error. If you can spot the error that would be great, but I would settle for some guidance on what this cryptic error message can mean.
I ASSUME that the error is caused by something incorrect in the input callback function. The callback is happening, and the error occurs right after the first return from the callback.
The conversion is for raw 32-bit 8.24 samples, 2 channels, to .wav format. (After help from Doug yesterday I have clean ASBDs and can create the converter.)
Briefly, the input process is reading from a sample file:
o a sample count (first channel).
o a buffer of data (first channel)
o a sample count (second channel - should be, and is, same as first count)
o
a buffer of data (second channel)
The callback uses an input buffer list initially constructed elsewhere, and if during input processing the sample count exceeds the buffer size required, then the buffers are expanded.
After filling the buffers, the packet size and a pointer to the buffer list is returned. ASSUMPTION: The packet size is the number of samples in one buffer divided by the bytes per sample.
(One point: I know already that my input EOF handling is incorrect; that is not part of this problem.)
// CASBD is an ASBD.
inputFormat.SetAUCanonical(2, false);
inputFormat.mSampleRate = 44100.0;
// Converted recording format is interleaved, 2-channel, 16 bits/sample.
convertedFormat.mSampleRate =
44100.0;
convertedFormat.mFormatID = kAudioFormatLinearPCM;
convertedFormat.mFramesPerPacket = 1;
convertedFormat.mChannelsPerFrame = 2;
convertedFormat.mBytesPerFrame = 4;
convertedFormat.mBytesPerPacket = 4;
convertedFormat.mBitsPerChannel = 16;
convertedFormat.mReserved = 0;
convertedFormat.mFormatFlags =
kLinearPCMFormatFlagIsSignedInteger |
kLinearPCMFormatFlagIsPacked |
0;
>>>
// Static callback function for providing input data to AudioConverter.
OSStatus
ExporterDelegate::AudioConverterInputProc(AudioConverterRef inAudioConverter,
UInt32 *ioNumberDataPackets,
AudioBufferList *ioData,
AudioStreamPacketDescription **outDataPacketDescription,
void *inUserData) {
ExporterDelegate *THIS = (ExporterDelegate*)inUserData;
OSStatus result = 0;
// Read size of sample block.
UInt32 count;
fread(&count, 1, sizeof(count), THIS->inputFile_);
// Check for zero size - EOF.
if (count == 0) {
// Need to return an EOF code and zero packet count.
*ioNumberDataPackets = 0;
result = EOFEXPORTER;
} else {
// Adjust buffer sizes to accommodate input
block.
// If the input buffers are too small, expand them.
if (THIS->inputBufferSize_ < count) {
THIS->inputBufferSize_ = count;
THIS->inputBuffers_->mBuffers[0].mData = realloc(THIS->inputBuffers_->mBuffers[0].mData, count);
THIS->inputBuffers_->mBuffers[1].mData = realloc(THIS->inputBuffers_->mBuffers[1].mData, count);
THIS->inputBuffers_->mBuffers[0].mDataByteSize = count;
THIS->inputBuffers_->mBuffers[1].mDataByteSize = count;
THIS->inputBuffers_->mBuffers[0].mNumberChannels = 1;
THIS->inputBuffers_->mBuffers[1].mNumberChannels = 1;
}
int xxx;
// Read in two blocks of data (one for each channel).
xxx = fread(THIS->inputBuffers_->mBuffers[0].mData, 1, count, THIS->inputFile_);
fread(&count, 1, sizeof(count), THIS->inputFile_);
xxx = fread(THIS->inputBuffers_->mBuffers[1].mData, 1, count, THIS->inputFile_);
ioData = THIS->inputBuffers_;
// Return number of bytes in each buffer
divided by 4.
*ioNumberDataPackets = count >> 2;
}
return result;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden