Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Richard Zhao <linuxzsc@gmail.com>
Cc: alsa-devel <alsa-devel@alsa-project.org>
Subject: Re: How to tell user level hardware not support a certain format in a certain sample rate
Date: Mon, 16 Mar 2009 09:54:28 +0100	[thread overview]
Message-ID: <49BE13C4.10909@ladisch.de> (raw)
In-Reply-To: <4e090d470903150338q74cd3538xe908bc3d7df9a8de@mail.gmail.com>

Richard Zhao wrote:
> Sure I can add rules. but the rules will be checked as hw_param. If
> hw_param failed, does alsalib convert fmt or sample rate
> automatically?
> 
> For example:
> One codec, support:
> 44.1k : s8 s16 s24 s32
> 96k:  s24 s32
> 
> When user try to play s8/s16 96k audio file, hw_param will fail.

This is not how the rules work.

Initializing a device works like this:
1) The application opens the device, and the driver's open callback gets
   called.
2) The application chooses hardware parameters; ALSA checks that these
   values conform to the device's limitations.
3) After all hardware parameters are known, the driver's hw_params
   callback gets called.

When you driver adds constraint rules, it has do this in the open
callback (so that the rules are available in step 2 above).  Your
constraint rules will be called when the application tries to select
parameters; this is before the hw_params callback gets called.

In your example above, the open callback would install two rule
functions: one to remove s8/s16 if 96k has been selected, and one to
remove 96k if s8/s16 has been selected.

When the hw_params callback is called, ALSA guarantees that the
parameters are valid for the device.


HTH
Clemens

  reply	other threads:[~2009-03-16  8:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-23  7:02 How to tell user level hardware not support a certain format in a certain sample rate Richard Zhao
2009-03-02 14:04 ` Richard Zhao
2009-03-02 14:12   ` Takashi Iwai
2009-03-02 15:58   ` Clemens Ladisch
2009-03-15 10:38     ` Richard Zhao
2009-03-16  8:54       ` Clemens Ladisch [this message]
2009-03-17  6:57         ` Richard Zhao

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=49BE13C4.10909@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=linuxzsc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox