Re: Acquiring input Data
Re: Acquiring input Data
- Subject: Re: Acquiring input Data
- From: Heath Raftery <email@hidden>
- Date: Fri, 17 Jun 2005 22:08:03 +1000
On 17/06/2005, at 7:24 PM, Paul Barbot wrote:
On 6/17/05, Heath Raftery <email@hidden> wrote:
Your main function looks fine to me. Can you show us your input
callback, where AURender is called? My guess is that the
AudioBufferList you are providing to the Render call is not right. I
believe it needs to be ready to accept data of the type specified by
your InputUnit.
Yes, I think it's can be the AudiobufferList because i didn't know
how to
allocate it (just like you say in another thread)
Yep, that's what I was thinking ;) I haven't had a chance to look at
Bill's suggestion of AUOutputBL in that other thread, so maybe you'll
want to investigate that for yourself. I'll get on to it for myself
in the very near future.
here how i try to allocate in my my main() :
/*-----------------------------
main------------------------------------*/
theBufferList.mNumberBuffers = 1;
theBufferList.mBuffers[0].mDataByteSize = 100;
theBufferList.mBuffers[0].mData = calloc(100,1);
theBufferList.mBuffers[0].mNumberChannels = 1;
/*-----------------------------
main------------------------------------*/
Looks far too small to me, which would cause the -50. I'd need to see
your InputUnit's AudioStreamBasicDescription to really know what your
theBufferList should look like, but here's a guess based on my
experience. All my input data has been 2 channel deinterleaved, so
for starters you need two buffers with one channel each. Easiest way
to do this is probably to have a pointer to theBufferList, instead of
allocating it statically. That way you can do this:
AudioBufferList *theBufferListPtr;
theBufferListPtr = malloc(sizeof(AudioBufferList) + sizeof
(AudioBuffer)); //enough room for two buffers
theBufferListPtr->mNumberBuffers = 2;
theBufferListPtr->mBuffers[0].mNumberChannels = 1;
theBufferListPtr->mBuffers[1].mNumberChannels = 1;
Now, to get the size of the buffers, I use this:
UInt32 bufferSizeBytes, bufferSizeFrames=0;
UInt32 theSize = sizeof(bufferSizeFrames);
err = AudioUnitGetProperty(InputUnit,
kAudioDevicePropertyUsesVariableBufferFrameSizes,
kAudioUnitScope_Global, 0, &bufferSizeFrames, &theSize);
if(err)
AudioUnitGetProperty(InputUnit,
kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0,
&bufferSizeFrames, &theSize);
bufferSizeBytes = bufferSizeFrames * sizeof(Float32);
Which checks to see if the device uses variable buffer sizes. If it
does, it gets the max value, otherwise it gets the normal buffer
size. Then all you have to do is this:
theBufferListPtr->mBuffers[0].mDataByteSize = bufferSizeBytes;
theBufferListPtr->mBuffers[0].mData = malloc(bufferSizeBytes);
theBufferListPtr->mBuffers[1].mDataByteSize = bufferSizeBytes;
theBufferListPtr->mBuffers[1].mData = malloc(bufferSizeBytes);
You'll see bufferSizeBytes is in the order of 2048 or 3200.
Otherwise your InputProc looks fine. It Friday night after a big
week, so there could be some mistakes above, but I hope this gets you
a little further!
Heath
_______________________________________________
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