[alsa-devel] Requiring the same sample rate for playback and record?
tiwai at suse.de
Wed Jul 16 12:59:50 CEST 2008
At Mon, 14 Jul 2008 16:25:04 -0500,
Timur Tabi wrote:
> Takashi Iwai wrote:
> > Right now there is no "elegant" way for this, unfortunately.
> > A common way many drivers use is to remember the rate of the first
> > stream, then add it to hw_constraint of the secondary streams.
> Can you give me an example of a driver that does this? I can't seem to find one.
In a simple case, you don't need hw_constraint functions. Just
override the corresponding fields of runtime->hw in open callback.
For example, pci/via82xx.c sets the current rate value to
runtime->hw.rate_min/max if there is another stream.
More complicated examples are found in echoaudio driver.
> > But, this could be also a bit racy (unavoidable due to its design)
> > although practically it seems working.
> I've been trying to implement this, but I'm not sure how. I have a couple
> 1) Which snd_pcm_hw_constraint_xxx function should I use to specify a sample
> rate or sample size constraint of a single number? I'm thinking
The simplest way is to override the runtime->hw parameter as mentinoed
in the above.
> 2) Where should I be calling this function? In my _hw_params()
Usually these hw_constraints are set in open callback.
> I would like to do is require the constraint to be enforced only when a stream
> is already playing. That is, if playback is paused, then the capture stream can
> set any sample rate it wants. Is this doable, or just too complicated?
This is a scenario above a simple hw_constraint. This would be also
confusing to apps in many cases.
More information about the Alsa-devel