Re: render callback: To memclear or not to memclear; that is the question...
Re: render callback: To memclear or not to memclear; that is the question...
- Subject: Re: render callback: To memclear or not to memclear; that is the question...
- From: William Stewart <email@hidden>
- Date: Fri, 18 Jun 2010 17:37:52 -0700
On Jun 17, 2010, at 1:28 PM, uɐıʇəqɐz pnoqɥɒɯ wrote:
>
> On Jun 17, 2010, at 11:29 AM, William Stewart wrote:
>
>>> What I'd like to know is whether I can accomplish the same end-result by just doing so:
>>>
>>> ioData->mBuffers[0].mDataByteSize = 0;
>>> with or without:
>>> *ioActionFlags |= kAudioUnitRenderAction_OutputIsSilence;
>>
>> no
>>
>> it is also good to set the silence flag though
>
> To be clear, you are saying that it is good to do:
>
> for (UInt32 i=0; i < inData->mNumberBuffers; i++)
> memset(inData->mBuffers[i].mData, 0, inData->mBuffers[i].mDataByteSize);
this is required
> *ioActionFlags |= kAudioUnitRenderAction_OutputIsSilence;
this is highly recommended
>
>>
>>>
>>> It seems to me that in the iPhoneMixerEQGraphTest sample, when the data in the source buffer isn't sufficient to satisfy the requested inNumberFrames, the following statement:
>>
>> That isn't how audio units work. You are REQUIRED to provide the requested number of samples, no more and no less.
>
> I'm curious, would it not be more efficient if the AU checked the mDataByteSize and bailed if zero or handled only the actual byte count? This coming from someone new to this all :-) Another efficient way would be if there was an empty buffer (silenceDataBuff) sitting around which could then be used:
>
> memcpy(ioData->mBuffers[0].mData, &in[sample], bytesAvailable);
> ioData->mBuffers[0].mDataByteSize = bytesAvailable;
> ioData->mBuffers[1].mData = silenceDataBuffPtr;
> ioData->mBuffers[1].mDataByteSize = theRestOfTheBytesAURequested;
>
> Or are different elements of mBuffers array reserved for different channels?
the way to tell your caller to bail is to return an error.
>
>
>>> if (offset < numFramesToRender) {
>>> numFramesToRender -= offset;
>>> ioData->mBuffers[0].mDataByteSize = numFramesToRender * userData->soundBuffer[inBusNumber].asbd.mBytesPerFrame;
>>> }
>>> (where numFramesToRender is a smaller number than inNumberFrames)
>>> seems to satisfy the caller, and no noise is heard despite the buffer being returned is smaller than requested.
>
> I think this might be a bug in the sample code. Can you please forward to Edward, the author, for confirmation? It looks like he checks to see if the inNumberFrames are greater than what's available, and then sets:
>
> ioData->mBuffers[0].mDataByteSize = numFramesToRender * userData->soundBuffer[inBusNumber].asbd.mBytesPerFrame;
>
> to a smaller value, and calls memcopy, only copying what is available and not the actual number of bytes requested.
ok, will do
>
>
> -mahboud
>
_______________________________________________
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