All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Lennart Poettering <mznyfn@0pointer.de>
Cc: alsa-devel <alsa-devel@alsa-project.org>
Subject: Re: how is 'dir' in snd_pcm_hw_params_set_periods_near() supposed to work?
Date: Tue, 09 Sep 2008 10:02:15 +0200	[thread overview]
Message-ID: <48C62D87.8090303@ladisch.de> (raw)
In-Reply-To: <20080908202808.GB5221@tango.0pointer.de>

Lennart Poettering wrote:
> How is the 'dir' argument in snd_pcm_hw_params_set_periods_near()
> supposed to work?

Short answer: use NULL.

Long answer: Before calling the function, -1 means that the number of
periods must be less than 'val', 1 means greater.  After calling the
function, 'dir' is set to -1 to indicate that the actual number of
periods is less than 'val', etc.

> I'd assume that passing dir=1 would mean that it is looked for a
> number of periods that is greater *or equal* to what we request. [...]
> The docs don't really elaborate on this much.

While the docs don't really elaborate on anything, for any ALSA
function, in this case they actually say "<" and not "<=".

> I'd certainly think that having ">=" and "<=" here is much more useful
> and natural than ">" and "<", and hence I was wondering: is this just
> a bug in the software or is it really intended to be this way?

It's intended.

In the configuration space, parameters like the number of periods are
represented as an interval, i.e., as a minimum and a maximum value.
Since it is possible to have values that are not integers (e.g., buffer
size = 1000, period size = 400 => number of periods = 2.5), both bounds
of the interval can be 'open', i.e., the respective boundary value does
not belong the the interval.  In the above example, the minimum would be
2 and the maximum 3, with both values themselves excluded.

It is not very useful to set the 'dir' parameter before calling
snd_pcm_hw_params_set_periods_near(); if you don't want an exact value,
you're more likely to set an interval with *_set_*_min() and *_max()
anyway.

The 'dir' parameter is useful to determine, after the call, that the
value is not an integer.  In this case, <= or >= would not make sense.


Regards,
Clemens

      reply	other threads:[~2008-09-09  8:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-08 20:28 how is 'dir' in snd_pcm_hw_params_set_periods_near() supposed to work? Lennart Poettering
2008-09-09  8:02 ` Clemens Ladisch [this message]

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=48C62D87.8090303@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=mznyfn@0pointer.de \
    /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.