All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Takashi Iwai <tiwai@suse.de>, Eldad Zack <eldad@fogrefinery.com>,
	USB list <linux-usb@vger.kernel.org>,
	alsa-devel@alsa-project.org, Daniel Mack <zonque@gmail.com>
Subject: Re: Buffer size for ALSA USB PCM audio
Date: Wed, 14 Aug 2013 20:34:36 +0200	[thread overview]
Message-ID: <520BCDBC.2060507@ladisch.de> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1308131659320.897-100000@iolanthe.rowland.org>

Alan Stern wrote:
> On Mon, 12 Aug 2013, Alan Stern wrote:
>> Here's a revised version of the patch (still untested).  The difference
>> is that this version tries always to keep a period's worth of bytes in
>> the USB hardware queue.  This will provide better protection against
>> underruns when the period is larger than the queue's minimum
>> requirement.
>
> After more thought, I decided that patch does too much.  It's not
> necessary to keep track of the number of packets.  Instead, the driver
> should always try to keep as much data in the USB hardware queue as it
> is allowed to.

This is what the current code does (i.e., re-submitting all URBs in
their completion handler).

> In other words, there should be enough URBs so that an entire ALSA
> buffer can be queued at any time, subject only to the limit on the
> maximum number of URBs and packets.

The URB queue adds latency, so it should never be made too big, even
for big ALSA buffers.  Once we have reached a queue length that is
practically guaranteed to be safe from underruns, more URBs do not make
sense.  (The current limit of 24 ms is somewhat arbitrary.)

> It doesn't make sense to allocate just enough URBs to cover a single
> period.

Indeed.  I've used two periods in my recent patch, but I don't really
know how I would justify this choice in the commit message.  ;-)

What doesn't make sense either is the current algorithm that computes
a specific value for the total number of packets (total_packs) and then
takes great care to allocate the URBs so that this number is reached,
even if this means that the number of packets per URBs varies.

And while we're at it: the default number of packets per URB was chosen
before the driver had the ability to estimate the delay from the current
frame number; it should now be quite safe to increase it.


Regards,
Clemens

  parent reply	other threads:[~2013-08-14 18:35 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 14:41 Buffer size for ALSA USB PCM audio Alan Stern
     [not found] ` <Pine.LNX.4.44L0.1307241013190.1313-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-07-24 14:54   ` Takashi Iwai
     [not found]     ` <s5hsiz4knyf.wl%tiwai-l3A5Bk7waGM@public.gmane.org>
2013-07-24 15:22       ` Alan Stern
     [not found]         ` <Pine.LNX.4.44L0.1307241108180.1313-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-07-24 15:26           ` Takashi Iwai
     [not found]             ` <s5hob9skmgs.wl%tiwai-l3A5Bk7waGM@public.gmane.org>
2013-07-24 15:43               ` Alan Stern
     [not found]                 ` <Pine.LNX.4.44L0.1307241138180.1313-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-07-25  8:24                   ` Takashi Iwai
     [not found]                     ` <s5hbo5rkpwm.wl%tiwai-l3A5Bk7waGM@public.gmane.org>
2013-07-25 14:50                       ` Alan Stern
     [not found]                         ` <Pine.LNX.4.44L0.1307251043470.882-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-07-29 10:03                           ` Takashi Iwai
     [not found]                             ` <s5hvc3tfzt7.wl%tiwai-l3A5Bk7waGM@public.gmane.org>
2013-07-29 15:00                               ` Alan Stern
     [not found]                                 ` <Pine.LNX.4.44L0.1307291041410.1479-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-07-29 17:12                                   ` Clemens Ladisch
     [not found]                                     ` <51F6A262.6010800-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
2013-07-29 18:20                                       ` Alan Stern
     [not found]                                         ` <Pine.LNX.4.44L0.1307291400450.1479-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-07-29 19:23                                           ` Daniel Mack
     [not found]                                             ` <51F6C123.7020407-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-07-29 19:38                                               ` Alan Stern
2013-07-30  6:43                                               ` [alsa-devel] " Takashi Iwai
     [not found]                                                 ` <s5hob9k5z0b.wl%tiwai-l3A5Bk7waGM@public.gmane.org>
2013-08-01 17:11                                                   ` Eldad Zack
2013-08-01 17:37                                       ` Alan Stern
     [not found]                                         ` <Pine.LNX.4.44L0.1307311645190.1546-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-12 13:22                                           ` [alsa-devel] " Takashi Iwai
     [not found]                                             ` <s5h7gfryrgh.wl%tiwai-l3A5Bk7waGM@public.gmane.org>
2013-08-12 14:53                                               ` Alan Stern
     [not found]                                                 ` <Pine.LNX.4.44L0.1308121036460.1489-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-12 15:04                                                   ` Takashi Iwai
     [not found]                                                     ` <s5hvc3bx85c.wl%tiwai-l3A5Bk7waGM@public.gmane.org>
2013-08-12 16:50                                                       ` Alan Stern
     [not found]                                                         ` <Pine.LNX.4.44L0.1308121218590.1489-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-13 21:06                                                           ` Alan Stern
     [not found]                                                             ` <Pine.LNX.4.44L0.1308131659320.897-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-13 21:34                                                               ` Daniel Mack
     [not found]                                                                 ` <520AA657.5010704-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-14 20:50                                                                   ` Eldad Zack
2013-08-15 16:06                                                                   ` Alan Stern
     [not found]                                                                     ` <Pine.LNX.4.44L0.1308151136180.905-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-18 16:56                                                                       ` Clemens Ladisch
2013-08-14 18:34                                                             ` Clemens Ladisch [this message]
     [not found]                                                               ` <520BCDBC.2060507-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
2013-08-21 21:37                                                                 ` Alan Stern
     [not found]                                                                   ` <Pine.LNX.4.44L0.1308211654010.1297-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-26 18:37                                                                     ` Alan Stern
     [not found]                                                                       ` <Pine.LNX.4.44L0.1308261419100.886-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-27  6:32                                                                         ` James Stone
     [not found]                                                                           ` <CABRv+91ZGMHbHZFW0gYOL-zGP=HbmiJU51z-_C_2Jj+5ATisrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-27 16:53                                                                             ` Alan Stern
2013-08-27  7:19                                                                         ` Clemens Ladisch
2013-08-27  8:01                                                                           ` Pavel Hofman
     [not found]                                                                             ` <521C5CC2.7030809-49v42ZqfXVBBDgjK7y7TUQ@public.gmane.org>
2013-08-27  8:11                                                                               ` [alsa-devel] " Clemens Ladisch
     [not found]                                                                           ` <521C5315.3030207-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
2013-08-27 16:50                                                                             ` Alan Stern
     [not found]                                                                               ` <Pine.LNX.4.44L0.1308271246130.1810-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-27 20:03                                                                                 ` Clemens Ladisch
     [not found]                                                                                   ` <521D060E.4-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
2013-08-27 20:11                                                                                     ` Alan Stern
     [not found]                                                                                       ` <Pine.LNX.4.44L0.1308271608430.940-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-28  6:41                                                                                         ` Clemens Ladisch
     [not found]                                                                                           ` <521D9BAE.2060508-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
2013-08-28 18:46                                                                                             ` Alan Stern
     [not found]                                                                                               ` <Pine.LNX.4.44L0.1308281441090.1541-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-29  8:10                                                                                                 ` James Stone
     [not found]                                                                                                   ` <CABRv+92cJPKVT9f2dyHJ_rg6sX3hP9Ct6QFas771fS79h7Eu2w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-29 15:00                                                                                                     ` Alan Stern
     [not found]                                                                                                       ` <Pine.LNX.4.44L0.1308291059300.1170-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-08-29 17:45                                                                                                         ` James Stone
2013-08-29 18:42                                                                                                           ` Alan Stern
     [not found]                                                                                                           ` <CABRv+93oVW0rDEJnNeGyfqem2PM42b28-z9q+Ze8r7rky7szDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-09-03 14:04                                                                                                             ` [alsa-devel] " Alan Stern
2013-09-22 21:50                                                                                                         ` Eldad Zack
2013-09-09 14:20                                                                                                 ` Daniel Mack
     [not found]                                                                                                   ` <522DD92C.4020009-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-09 15:36                                                                                                     ` Alan Stern
2013-08-13 21:54                                                           ` 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=520BCDBC.2060507@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=eldad@fogrefinery.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tiwai@suse.de \
    --cc=zonque@gmail.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.