Re: render callback timing
Re: render callback timing
- Subject: Re: render callback timing
- From: David Duncan <email@hidden>
- Date: Fri, 5 Mar 2004 13:23:07 -0500
On Mar 5, 2004, at 12:36 PM, Josh Anon wrote:
In the callback, I also store the next play time in nanoseconds
(AudioConvertHostTimeToNanos) and, when asked, add that to device +
stream latency in nanos and return it as the next play time.
I'm not sure I follow what you are trying to accomplish here. What
time
stamps are you using and for what purpose?
The idea is that the guy using this object can ask for the next play
time in terms of system ticks--as close as possible to when the user
will hear the sound. In configure, I ask for the device and stream
latencies, and I register an observer for if they change. At the end
of the render callback, I do this:
_nextPlayTime =
AudioConvertHostTimeToNanos(((AudioTimeStamp*)inTimeStamp)-
>mHostTime);
In the GetNextPlayTime method, I convert the device + stream latencies
to nanoseconds, I get the nanoseconds per tick, I add the next play
time + latency, and I return the ticks.
Unless I'm mistaken, the time handed to you in the AudioTimeStamp is
when the HAL believes that the sound will be played on the device. From
CoreAudio/AudioHardware.h:
"The time stamp for theInputData represents when the data was recorded.
For the output, the time stamp represents when the first sample will be
played."
so you should probably not be adjusting for latency when determining
what the next play time is.
--
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.