Re: timestamps for usb audio device
Re: timestamps for usb audio device
- Subject: Re: timestamps for usb audio device
- From: Jeff Moore <email@hidden>
- Date: Wed, 12 May 2010 12:06:46 -0700
On May 12, 2010, at 10:33 AM, Jeff Schindler wrote:
> We have a driver for a USB audio device which is experiencing some glitchy audio (clicks/pops). The most likely candidate appears to be our timestamp generation - we are generating the timestamps using machine time. We do our data copying on input on a CoreAudio timer, which is when we detect the ring buffer wrap and take the timestamp.
Ouch. That's not going to produce very good time stamps.
> HALLab does detect some bad timestamps, but those detections don't necessarily correlate with the glitches we are detecting (both audibly and via a scope). First off, should the reported bad timestamps in HALLab (red lines) correspond to audible glitches and will HALLab necessarily report all bad timestamps generated?
No. Sometimes the glitches are slight enough to not be heard. The HAL will also internally correct for certain kinds of bad time stamps.
> Secondly, is the most likely culprit of our glitchy audio timestamp related and, if so, what things might we try to correct it? Thanks for any help.
You really need to be generating your time stamps based on the interrupt times for the USB frame edges. Otherwise, you will have more noise than signal in your time stamps from the scheduling latency. If I remember right, the driver for the controller stashes the host time for the frame edge somewhere in it's data structures. I'm not a USB expert, so you'd probably need to dig through the documentation and headers to find out more info about where to look for the value.
But once you know the time for the frame edges, you can build up an interpolator to get a good estimate for the time when the ring buffer wraps from the middle of a frame. Of course, if you can arrange to have your ring buffer occupy a whole number of USB frames, so much the easier.
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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