Re: Determining buffer playback status / position
Re: Determining buffer playback status / position
- Subject: Re: Determining buffer playback status / position
- From: William Stewart <email@hidden>
- Date: Tue, 10 Jan 2006 17:40:20 -0800
On 10/01/2006, at 12:13 PM, Stephen Shaw wrote:
AUConverter's (as with any other AU) will provide buffers for you to
fill in the render callback. These buffers are owned by the AU.
I wasn't aware of that, In the sample PlayAudioFileLite, it showed a
buffer being allocated and assigned to an element of the
AudioBufferList.
I don't think this code is the best code to start from.
ioData->mBuffers[0].mData = gSourceBuffer;
ioData->mBuffers[0].mDataByteSize = bytesReturned;
Yes, this can be done. The Lifetime of the buffer is not something
we've guaranteed - though I think a reasonable assumption is the end
of the current render cycle.
I had assumed that the graph was being feed the memory range specified
by my ptr (gSourceBuffer) directly (unless it's being copied to
private
buffers internally immediately when submitted).
My problem is that I have one subsystem which is returning audio in a
sequence of 'n' buffers in a list. It treats the list like a ring and
when finished with the 'n'th buffer it returns to buffer element 0 to
start filling there again.
ok
Something along the lines of this (an example):
UInt8* buffArray[10];
For (int I = 0; I < 10; i++)
buffArray[i] = calloc (512, sizeof (UInt8));
when my callback is called by the audio unit, I return it a ptr in the
AudioBufferList to my current location in buffArray[0] until it's
exhausted and then I increment to buffArray[1] and so on until
buffArray[9].
ok
Meanwhile the audio generation subsystem (which owns the buffers) is
filling those buffers ahead of me, but when it is done with
buffArray[9], and before it starts filling buffArray[0] again, it
needs
to know that I'm done with the playback from that buffer (buffArray
[0]).
While I'm feeding the buffers to CoreAudio, I need to know that it is
done accessing the data from the buffArray[0] memory range so that it
can be reused.
I think the end of the render cycle that you supply that buffer too
(presuming that the render cycle is of the same size as the buffer
you are providing).
You can find out when that render cycle finishes by instantiating a
render notifiction to the output unit you are ultimately connected
too. When the post-render notification fires, your buffer is safe to
reuse.
Bill
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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