Re: timers in AudioHardwarePlugin
Re: timers in AudioHardwarePlugin
- Subject: Re: timers in AudioHardwarePlugin
- From: Philippe Wicker <email@hidden>
- Date: Sun, 3 Aug 2003 16:04:26 +0200
On Sunday, August 3, 2003, at 02:38 PM, Stefan Werner wrote:
Hi,
I am currently working on a user space audio driver, using the
AudioHardwarePlugin.h API. What I have working for now is a plugin
that reports itself to the system and answers most DeviceGetProperty()
and StreamGetProperty() requests. It's working good enough that
programs like Ableton Live detect and initialize my driver.
What I am working on right now is calling the clients'
AudioDeviceIOProc() functions, and this is where I'm stuck right now.
How do I get accurate timers as an AudioHardwarePlugin? Not being
derived from IOAudioEngine.h, my driver cannot use IOKit to get
timestamps and interrupts. What is the best way to get accurate timers
in user space?
It depends on the accuracy you need. You can use the POSIX call
nanosleep (or usleep which is based on nanosleep). These calls suspend
execution of the calling thread for the time specified in the
parameters. Because your thread is first suspended, then woken up, the
actual time between the suspend time and the return to your code
includes time needed by the system to perform context switches. For
instance, a call to a 10 microsec sleep time using nanosleep takes an
average time of about 25 microsec on a DP867. Using usleep yields
similar results. The error may however be greater than (25 minus 10)
because this is a best case value (everything is on the L1 cache, the
1st call to nanosleep takes about 65 microsec) and the cpu may be used
by some other threads while your's is sleeping and be yielded the cpu
again a much longer time after (depending on its scheduling and
priority settings).
Thanks,
Stefan
_______________________________________________
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.
Philippe Wicker
email@hidden
_______________________________________________
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.