From 294c4fb8ab01728358836f478bcc1174ba7fb9d8 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 6 Sep 2011 19:15:34 -0500 Subject: ALSA: usb: refine delay information with USB frame counter Existing code only updates the audio delay when URBs were submitted/retired. This can introduce an uncertainty of 8ms on the number of samples played out with the default settings, and a lot more when URBs convey more packets to reduce the interrupt rate and power consumption. This patch relies on the USB frame counter to reduce the uncertainty to less than 2ms worst-case. The delay information essentially becomes independent of the URB size and number of packets. This should help applications like PulseAudio which require accurate audio timing. Clemens Ladisch reported a decrease of mplayer's A-V difference from nrpacks down to at most 1ms. Thanks to Clemens for also pointing out that the implementation of frame counters varies between different HCDs. Only the 8 lowest-bits are used to estimate the delay. Signed-off-by: Pierre-Louis Bossart [clemens: changed debug code] Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/usb/pcm.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound/usb/pcm.h') diff --git a/sound/usb/pcm.h b/sound/usb/pcm.h index ed3e283f618..df7a003682a 100644 --- a/sound/usb/pcm.h +++ b/sound/usb/pcm.h @@ -1,6 +1,9 @@ #ifndef __USBAUDIO_PCM_H #define __USBAUDIO_PCM_H +snd_pcm_uframes_t snd_usb_pcm_delay(struct snd_usb_substream *subs, + unsigned int rate); + void snd_usb_set_pcm_ops(struct snd_pcm *pcm, int stream); int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface, -- cgit v1.2.3-70-g09d2