[alsa-devel] [Alsa-user] How to get set/fixed sample rate of ALSA device?

Rene Herman rene.herman at keyaccess.nl
Mon Oct 8 21:30:42 CEST 2007

On 10/08/2007 09:14 PM, Bill Unruh wrote:

> On Mon, 8 Oct 2007, Peteris Krisjanis wrote:
>>> Introducing a /proc/asound/card0/pcm0{p,c}/hw_limits or similar might
>>>  not be a bad idea though?
>> That would be good idea, with completion with 'alsainfo' about device.
>> How to do that properly, any clues before I try to sink my teeths in 
>> ALSA code?
> Is this even possible? Ie, do sound cards actually tell you what their
> max or min hardware capabilities are and what info might you put into
> here? Ie, some cards can do 2 or 4 or 5.1 channel output. Do you put that
> in? And re speed, does the card actually advertise what speeds it
> supports, or is it more a matter of trying and if it does not support it,
> it rejects it.

It's really only about communicating what the _driver_ accepts (ie, tells us 
the hardware can do). That is, basically export the snd_pcm_hardware struct 
for the stream.

It could also be done in userspace by opening the stream and quering the 
format_mask, channels and rates and stuff and I'll look into that a bit as a 
followup to the rates_min/max thing that I posted if only as a template 
thingy, but unless I'm missing it, I don't believe there's actually a way to 
get the information from userspace without opening the "hw" device, and that 
one only allows "subdevices_count" concurrent opens, meaning you'd have to 
stop things talking to your soundcard if it has just one (normal).

Exposing it directly in /proc/asound would be the way. Peteris; if you'll be 
looking, note that rates (and channels) might not be continuous between 
their min and max or anything; mostly it's enumerated stuff. Looking at the 
/proc/asound/card0/pcm0p/sub0/hw_params file generation probably helps (but 
that just exports the currently selected paramters, not all possible).


More information about the Alsa-devel mailing list