Re: Question about the AudioConverterFillComplexBuffer callback function
Re: Question about the AudioConverterFillComplexBuffer callback function
- Subject: Re: Question about the AudioConverterFillComplexBuffer callback function
- From: William Stewart <email@hidden>
- Date: Tue, 11 May 2010 10:41:38 -0700
On May 11, 2010, at 4:02 AM, Fredrik wrote:
>
>>
>>> I have been looking at the new example code, FileConverter and noticed that the callback does reading directly from the file. In my case I have already read from my file into a buffer. Is it possible to just supply the buffer to the callback function instead?
>>
>> You would put the buffer pointer into the AudioBufferList.
>>
>> outOutputData->mBuffers[0].mData = myPointer;
>> outOutputData->mBuffers[0].mDataByteSize = .. the size in bytes of the data pointed to by myPointer ..
>> ioOutputDataPacketSize = .. number of packets (or frames of LPCM) of audio pointed to by myPointer.
>>
>>>
>>> I also noticed that the struct passed to the example callback function contains a AudioStreamBasicDescription is it possible to do this without it, since I have created a converter with this as arguments?
>>
>> The inInputDataProcUserData pointer can point to absolutely anything you want.
>>
>
> Thank you, that's great. In the callback function itself all I have to do is to move packets from the input data buffer to the output buffer and advance the pointer right.
That's all up to you. The outOutputData buffer list is there to hold your pointer (your memory).. You are responsible for filling this in correctly (as James describes above)
> How can I find out the ideal or reasonable amount of packets to move in the callback?
As much as you have... you have to keep the pointer(s) you provide valid and untouched until the NEXT call to your input proc. At that point the converter is finished with the previous pointer and its content, so you can either reuse it, advance it, throw it away, whatever is appropriate to how you are managing this.
> I saw in the documentation that a small amount will cause the function to be called more frequently.
Yes... it is driven by what you are demanding by:
How often do you call AudioConverterFillComplexBuffer
How much data do you want converted in that call.
The input proc is only called to satisfy a given request, by a given call of FCBuffer. If, when FCBuffer is called, you already have enough data in the converter to satisfy that request, then the input proc will not be called. If you don't, the input proc will be called. if the input proc doesn't return enough data, it will be called again. If you don't have enough data at that time, then you can return an error. That signfies to the converter that you don't have enough data, so it will return to you (the caller of FCBuffer) as much converted data as it can, and the non-zero result code that YOU returned in your input proc.
Bill
_______________________________________________
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