• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ExtAudioFileRead: how to create AudioBufferList
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ExtAudioFileRead: how to create AudioBufferList


  • Subject: Re: ExtAudioFileRead: how to create AudioBufferList
  • From: David Duncan <email@hidden>
  • Date: Sat, 18 Nov 2006 07:25:07 -0800

On Nov 18, 2006, at 05:34 AM, maximilian marcoll wrote:

ExtAudioFileRead needs an AudioBufferList for storing data in.
but i just can't figure out how to create an appropiate buffer list.
i can't allocate memory for the mBuffers field of the buffer list,
because mBuffers actually is no pointer.
if i don't allocate, it doesn't work either
(of course it doesn't - there is no memory for ExtrAudioFile to write to.)

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));

where numBuffers is the number of buffers you want in your AudioBufferList. We subtract 1 since it already has 1 allocated. Remember that C (and other C-like languages) don't range check arrays, so you can just index to your hearts content, which is what this relies on.
--
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


  • Follow-Ups:
    • Re: ExtAudioFileRead: how to create AudioBufferList
      • From: William Stewart <email@hidden>
References: 
 >ExtAudioFileRead: how to create AudioBufferList (From: maximilian marcoll <email@hidden>)

  • Prev by Date: ExtAudioFileRead: how to create AudioBufferList
  • Next by Date: When did AUFilePlayer finish playing?
  • Previous by thread: ExtAudioFileRead: how to create AudioBufferList
  • Next by thread: Re: ExtAudioFileRead: how to create AudioBufferList
  • Index(es):
    • Date
    • Thread