Re: Render callback not producing enough samples
Re: Render callback not producing enough samples
- Subject: Re: Render callback not producing enough samples
- From: Alberto Ricci <email@hidden>
- Date: Mon, 22 Mar 2004 16:31:28 +0100
Thank you, David.
I was referring to an Audio Unit callback.
OK, I will then return the exact number of frames requested, but I
wonder what is best to do when I am requested more frames than I have
in my ring buffer. This ring buffer is filled by a piece of custom
hardware, so I can't just decide to process more samples.
In order to have as many samples as requested, I would need to sleep
until the device has generated more samples, but then I don't think
it's a good thing to do from within a realtime thread... or is it?
Thanks,
Alberto.
At 8:52 AM -0500 3/18/04, David Duncan wrote:
On Mar 18, 2004, at 05:15 AM, Alberto Ricci wrote:
Suppose I want to play some data - which is generated in real time
- through the default output unit. Such data is generated at an
approximate rate of 44100 samples per second, but some frames may
be skipped every once in a while (just a few samples here and
there, resulting in an effective average rate of 44099.9 Hz or so),
so my Render callback wouldn't know what samples to generate in
those cases in order to ensure a precise 44100 Hz rate.
Are you talking about a HAL callback or an Audio Unit callback? The
provided Audio Output Units arrange so that you are always requested
a number of frames that ensure a consistent sample rate (this is not
the same as always requesting the same number of samples).
What should my Render callback do in such situations? Always return
the requested number of frames, no matter what, therefore filling
the gaps with silence (or with the last frame's value)? Or can it
return a smaller amount of samples and have CoreAudio properly
handle that?
You should always return the number of frames requested, and in fact
you must do so for Audio Units (because there is no mechanism to do
otherwise). Don't fill gaps with silence unless you really intend to
play silence.
Do you have a specific issue that is causing you to ask about this?
--
Reality is what, when you stop believing in it, doesn't go away.
Failure is not an option. It is a privilege reserved for those who try.
David Duncan
_______________________________________________
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.