• 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: Using NSMutableData for an audio buffer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSMutableData for an audio buffer?


  • Subject: Re: Using NSMutableData for an audio buffer?
  • From: Doug Wyatt <email@hidden>
  • Date: Wed, 28 Jan 2004 16:57:35 -0800

On Jan 28, 2004, at 2:40, Christopher Corbell wrote:
I'm wondering about the safety of using an NSMutableData object for
an audio buffer in CoreAudio calls, esp. the AudioConverter callback
for AudioConverterFillComplexBuffer().

Right now my code is grabbing non-interleaved Float32 data from
an AudioUnit render notification. The data goes into two ring buffers
and the capturing thread just appends it into two NSMutableData
objects.

After capture is complete I'm trying to convert it to an AIFF file.
In this situation, when the NSMutableData objects won't be changed,
is it safe to use [theData bytes] + currentOffset when setting
the AudioBuffer mData field for the converter callback? I'm
guessing the callback will just do a copy of these bytes and
not modify the buffer in any way so it should be OK. However
while the conversion works I'm also seeing instability and
wondering if this could be a cause.

Sounds like the NSMutableData is getting reallocated -- moving in memory -- when you resize it on the render notification. This can (and therefore eventually *will*) happen while you're writing it to the file.

If you use preallocated memory buffers instead, you'll avoid not only this problem, but also the possibility of the realtime thread blocking on a memory allocation.

Doug

--
Doug Wyatt
Core Audio, Apple
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

References: 
 >Using NSMutableData for an audio buffer? (From: Christopher Corbell <email@hidden>)

  • Prev by Date: Re: Streaming OS X audio over network
  • Next by Date: Re: HALOutputUnit: Nx1 or 1xN
  • Previous by thread: Using NSMutableData for an audio buffer?
  • Next by thread: Simple wave generating?
  • Index(es):
    • Date
    • Thread