Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lennart Poettering <mznyfn@0pointer.de>
To: alsa-devel@alsa-project.org
Subject: Re: Misusing snd_pcm_avail_update()
Date: Tue, 20 Jan 2009 21:29:34 +0100	[thread overview]
Message-ID: <20090120202933.GA17626@tango.0pointer.de> (raw)
In-Reply-To: <49761C79.8060605@ladisch.de>

On Tue, 20.01.09 19:48, Clemens Ladisch (clemens@ladisch.de) wrote:

> > 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.

But still, with this flag I would only now that the startup sequence
is "fast". But not how "fast".

I appears to me that it would make a lot more sense if the driver
would simply tell me how long I may sleep instead of adding multiple
new functions 1) that tell me if double-buffering is used and what the
size of the second buffer is, 2) that tell me that data is pulled
block-by-block from the buffer and what the block size is, and so on. 

The function should look like this:

    snd_pcm_sframes_t snd_pcm_busy_for(snd_pcm_t *pcm);

I called the prototype "busy for" since effectively the value I am
looking for is the time the card will be busy with the data it already
has, and doesn't need any new data.

Can I convince you guys that a function like this would make a lot of
sense?

Instead of exporting all the gory details about blocks/double
buffering and so on, just a simple high-level call. 

> > 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.

I am pretty sure there might be other drivers that work like this as
well. Hence I think simply removing double buffering in the USB driver
doesn't really solve the general issues I have.

> > > 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.

It would be good if this could be controlled independantly from
each other. 

> 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.

That would be good.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4

  reply	other threads:[~2009-01-20 20:29 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
2009-01-20 20:29       ` Lennart Poettering [this message]
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=20090120202933.GA17626@tango.0pointer.de \
    --to=mznyfn@0pointer.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox