Re: AudioConverters
Re: AudioConverters
- Subject: Re: AudioConverters
- From: Doug Wyatt <email@hidden>
- Date: Fri, 30 Jul 2004 18:02:25 -0700
On Jul 29, 2004, at 15:20, Francois Hamel wrote:
Why is it that when I call AudioConverterFillComplexBuffer with a
certain packet number, I don't get the same number in the variable
"ioNumberDataPackets" in my convertion callback? Then, just after the
call, the packet count returned is the same as the one when the
function was called.
ex:
uint32 readPacketCount = 0;
uint32 remainPacketCount = size / m_inFormat.mBytesPerPacket;
while( remainPacketCount > 0 )
{
readPacketCount = remainPacketCount;
//here readPacketCount can be something like 16000
//then in the callback "ConvertCallback" I receive 12000 as
the
"ioNumberDataPackets" var
OSStatus result = AudioConverterFillComplexBuffer(m_converter,
&ConvertCallback, this, &readPacketCount, m_buffers, NULL);
//and here I receive 16000 back from the readPacketCount
variable
m_dwSrcDataOffset += readPacketCount *
m_inFormat.mBytesPerPacket;
remainPacketCount -= readPacketCount;
}
what could be causing this?
Are you converting from 24 bit to 32 bit? That would explain why when
you ask for 16000, the input proc is told that 12000 are required.
From the header:
// ioDataSize: on input, the minimum amount of data the converter would
// like in order to fulfill its current FillBuffer request. On output,
// the number of bytes actually being provided for input, or 0 if there
// is no more input.
You may return more or less than you were asked for. If you return
less, you will be called again almost immediately. This may be what you
want -- for example, you might have your input stream separated into
multiple buffers. The current buffer might not contain enough to
satisfy the converter. You pass back what you do have, advance to the
next buffer, and when you're called again, pass a pointer to the next
buffer.
If you return more than what you were asked for, then the converter
simply retains a pointer into your buffer until all of the input is
consumed.
Is it possible also to convert a big buffer
in one pass (without a loop)?
If you want to make an output buffer that large, yes.
Doug
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.