Pierre-Louis Bossart wrote:
I was trying to find a bug in the timestamping logic I am working on and after some time I realized the USB audio class driver seems to have an issue. If I instrument the code in sound/usb/pcm.c, I see a offset of up to 6ms between the snd_usb_substream_playback_trigger and prepare_playback_urb steps
[45053.102625] trigger_start [45053.108320] prepare_playback_urb
My understanding is that empty URBs are submitted in the prepare step to avoid underflows, which is fine. The problem with that is that the trigger_tstamp value is captured before audio transfers actually start and there is a constant offset when trying to track audio/system time drifts or do basic a/v sync.
Most other devices have a FIFO that gets filled quickly when the stream is started. This results in a small offset in the opposite direction.
AFAICS you cannot avoid having an offset when trying to relate the trigger_tstamp value to the sample clock.
Regards, Clemens