[alsa-devel] [PATCH] ALSA: usb: refine delay information with USB frame counter

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Tue Aug 30 17:34:55 CEST 2011

> /*
>  * Multi-line comments are supposed to use this formatting style.
>  */


> This could be replaced with just:
> 	frame_diff = (current_frame_number - subs->last_frame_number) &
> 0xff;

> Do you know how large the difference actually becomes?
> I'm not sure if it might be possible to construct a scenario where
> rounding errors could accumulate ...

I don't think so. I've use a classic technique, I've seen similar code used
to improve a/v sync when the audio time is updated in steps. The estimate
starts from the delay as computed before (number of samples queued), then
decreased down (possibly to zero) using the frame counter. When the urbs are
retired, the delay is reset as previously. The frame number is only used to
predict the delay more accurately, and the delay is always based on 2 reads
of the frame counter. Worst case one case be off by one ms on each read.

More information about the Alsa-devel mailing list