Re: ExtAudioFileRead: how to create AudioBufferList
Re: ExtAudioFileRead: how to create AudioBufferList
- Subject: Re: ExtAudioFileRead: how to create AudioBufferList
- From: David Duncan <email@hidden>
- Date: Mon, 20 Nov 2006 11:48:56 -0800
On Nov 20, 2006, at 11:26 AM, William Stewart wrote:
The idiom is a common one for allocating variable length arrays.
This can be done easily with malloc() and other byte-oriented
allocators like this:
mInputBuffer = (AudioBufferList*)malloc(sizeof(AudioBufferList) +
(numBuffers-1) * sizeof(AudioBuffer));
This is not quite correct and won't work correctly for 64 bit. The
correct way is to use the offsetof operator:
mBufferList = reinterpret_cast<AudioBufferList*>(new Byte[offsetof
(AudioBufferList, mBuffers) + (mNumberBuffers * sizeof
(AudioBuffer))]);
I'm interested in why the my code isn't compatible with 64-bit,
mostly for my own education, but also because it's just extending a
pre-existing array by the number of additional buffers needed.
--
Reality is what, when you stop believing in it, doesn't go away.
Failure is not an option. It is a privilege reserved for those who try.
David Duncan
_______________________________________________
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