TPCircularBuffer Usage
TPCircularBuffer Usage
- Subject: TPCircularBuffer Usage
- From: Pier <email@hidden>
- Date: Sat, 17 Nov 2012 13:03:44 +0800
Hi,
I'm using Michael Tyson's famous TCCircularBuffer from this page.
I'm trying to use it in a way where I keep the pointer to the start of my audio data.
SInt16 *buffer = TPCircularBufferTail(&THIS->buffer, &availableBytes);
memcpy(targetBuffer, buffer, MIN(bytesToCopy, availableBytes)); // targetBuffer is playback buffer
TPCircularBufferConsume(&THIS->buffer, sampleCount);
The first time I go into the above code, I keep a copy of *buffer and name it *startPtr, so that I can use it in my audio code for playback manually. I know that the data has been "consumed" by TPCircularBufferConsume, but it seems to be still there.
I'm able to play it back from *startPtr by looping this
memcpy(targetBuffer, startPtr, MIN(bytesToCopy, availableBytes));
startPtr += (bytesToCopy / sizeof(SInt16)); // startPtr is SInt16 pointer
but once I stop the playback - and go on to do other things within the application, and then return back to activate the playback again, it doesn't work anymore. (plays back silence)
Why is this so, and am I making a terrible mistake by doing the above?
Thanks.
--
Pier.
_______________________________________________
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