Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ExtAudioFileRead: how to create AudioBufferList



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:
http://lists.apple.com/mailman/options/coreaudio-api/email@hidden

This email sent to email@hidden
References: 
 >ExtAudioFileRead: how to create AudioBufferList (From: maximilian marcoll <email@hidden>)
 >Re: ExtAudioFileRead: how to create AudioBufferList (From: David Duncan <email@hidden>)
 >Re: ExtAudioFileRead: how to create AudioBufferList (From: William Stewart <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.