Re: Using NSMutableData for an audio buffer?
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.