Core Audio - CARIngBuffer
- by tech74
Hi, Im looking at using the CARingBuffer in iPhone SDK 3.1 Developer\Extras\CoreAudio\PublicUtility, however was a little puzzled about some of its methods. Firstly this will only make sense really to anyone who's used this class
For example the GetTimebounds,SetTimeBounds, ClipTimeBounds functions what are these actually doing?
Also when using it, i get crashes caused by example this method in the main Fetch method
- ZeroABL(abl, 0, destStartOffset * mBytesPerFrame);
CARingBufferError CARingBuffer::Fetch(AudioBufferList *abl, UInt32 nFrames, SampleTime startRead)
{
SampleTime endRead = startRead + nFrames;
SampleTime startRead0 = startRead;
SampleTime endRead0 = endRead;
SampleTime size;
CARingBufferError err = ClipTimeBounds(startRead, endRead);
if (err) return err;
size = endRead - startRead;
SInt32 destStartOffset = startRead - startRead0;
if (destStartOffset 0) {
ZeroABL(abl, 0, destStartOffset * mBytesPerFrame);
}
Here the destStartOffset has become larger than the size of the abl Bufferlist so when a memset is done it exceeds the boundaries of the abl Bufferlist causing the crash. Why hasn't this class got checks in to prevent this.