All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: alsa-devel@alsa-project.org
Subject: Re: Misusing snd_pcm_avail_update()
Date: Tue, 20 Jan 2009 19:48:25 +0100	[thread overview]
Message-ID: <49761C79.8060605@ladisch.de> (raw)
In-Reply-To: <20090120142614.GA27494@tango.0pointer.de>

Lennart Poettering wrote:
> Particularly with USB I experience that right after the device is
> started data is read much much faster from the playback buffer than
> expected. This feels as if the USB driver would at the beginning take
> all data from the playback buffer and copy it to some other buffer
> which was previously completely empty. Then after that second buffer
> is filled up the copying slows down to the expected speed.

Yes, the USB driver uses double-buffering, and the initial queueing of
data for the USB controller is done at faster rate, to reduce the
startup latency.

The size of the second buffer is about one period, but never more
than 64 ms.

> I currently deal with this by always halving the first wakeup time --
> which works most of the time but is a hack.

In theory, you could deduce this behaviour from
snd_pcm_hw_params_is_double(), but the USB driver forgets to set this
flag.

> With the function I suggest I'd be able to explicitly query how much
> time I have before I need to wake up.

I was thinking about a function that returns the hardware's block size
(i.e., the precision of the avail/delay values), but that wouldn't be
able to describe this behaviour of the USB driver.  I think I might just
remove this feature.

> > Well, you could make the "some extra margin" above larger than one
> > period.
>
> To save power I want to disable interrupts from the sound cards as
> much as possible.

In some cases (unusal hardware, but also USB), the period size affects
the block size, i.e., smaller periods give better timing precision.

For this case, it might be useful to make the "pointer precision" a
hardware parameter that can be restricted by an interval, like the other
parameters.


Best regards,
Clemens

  reply	other threads:[~2009-01-20 18:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-20  2:57 Misusing snd_pcm_avail_update() Lennart Poettering
2009-01-20  8:29 ` Clemens Ladisch
2009-01-20  8:32   ` Clemens Ladisch
2009-01-20 14:26   ` Lennart Poettering
2009-01-20 18:48     ` Clemens Ladisch [this message]
2009-01-20 20:29       ` Lennart Poettering
2009-01-21  0:39         ` Takashi Iwai
2009-01-22 22:20           ` Lennart Poettering
2009-01-23 17:13             ` Takashi Iwai
2009-01-23 17:56               ` Clemens Ladisch
2009-01-24  9:52                 ` Takashi Iwai
2009-01-28 18:30                 ` Lennart Poettering
2009-01-29  8:28                   ` Clemens Ladisch
2009-01-28 18:26               ` Lennart Poettering
2009-01-23 18:49           ` James Courtier-Dutton

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=49761C79.8060605@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    /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.