From: Clemens Ladisch <clemens@ladisch.de>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: sarah.a.sharp@linux.intel.com, alsa-devel@alsa-project.org
Subject: Re: [PATCH] ALSA: usb: refine delay information with USB frame counter
Date: Tue, 30 Aug 2011 09:59:34 +0200 [thread overview]
Message-ID: <4E5C9866.9060901@ladisch.de> (raw)
In-Reply-To: <1314642732-8909-1-git-send-email-pierre-louis.bossart@linux.intel.com>
Pierre-Louis Bossart wrote:
> 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 improve audio/video sync and help
> applications like PulseAudio which require accurate audio
> timing.
I haven't yet found the time to test this, but there are a few
theoretical nitpicks ...
> + /* HCD implementations use different widths, use lower 8 bits.
> + * The delay will be managed up to 256ms, which is more than
> + * enough
> + */
/*
* Multi-line comments are supposed to use this formatting style.
*/
> + current_frame_number &= 0xFF;
> + frame_diff = current_frame_number-subs->last_frame_number;
> + if (frame_diff < 0)
> + frame_diff += 256; /* handle 8-bit wrap-around */
This could be replaced with just:
frame_diff = (current_frame_number - subs->last_frame_number) & 0xff;
> + /* Report when delay estimate is off by more than 2ms.
> + * The error should be lower than 2ms since the estimate relies
> + * on two reads of a counter updated every ms */
> + if (abs(est_delay-subs->last_delay) > (runtime->rate*2/1000L))
> + snd_printk(KERN_DEBUG "ALSA usb.c: Delay %d actual delay %d\n",
> + est_delay, subs->last_delay);
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 ...
Regards,
Clemens
next prev parent reply other threads:[~2011-08-30 7:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-29 18:32 [PATCH] ALSA: usb: refine delay information with USB frame counter Pierre-Louis Bossart
2011-08-30 7:59 ` Clemens Ladisch [this message]
2011-08-30 15:34 ` Pierre-Louis Bossart
2011-09-05 7:53 ` Clemens Ladisch
-- strict thread matches above, loose matches on Subject: below --
2011-08-24 21:26 Pierre-Louis Bossart
2011-08-25 7:54 ` Clemens Ladisch
2011-08-25 14:00 ` Pierre-Louis Bossart
[not found] ` <002301cc632f$5bfe0a90$13fa1fb0$@bossart@linux.intel.com>
2011-08-25 14:07 ` Clemens Ladisch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E5C9866.9060901@ladisch.de \
--to=clemens@ladisch.de \
--cc=alsa-devel@alsa-project.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=sarah.a.sharp@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.