Skip to contentSkip to conversation

hw_params and approximate values

DISCUSSION Arve Knudsen 2 participants 4 messages Aug 21, 2003 – Aug 28, 2003

lore
Share & tools
lore
#0 lore raw

Hi

I'm not sure if I quite understand the alsa-lib docs regarding the snd_pcm_hw_params API; in addition to an approximate integer value, one might specify a direction. Is the direction parameter a way to instruct ALSA to look for a floating point value in either direction? If that's the case, couldn't this be handled with floats directly?

Regards

Arve Knudsen

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0

#1 lore raw
Quoted 7 lines · Arve Knudsen

Hi

I'm not sure if I quite understand the alsa-lib docs regarding the snd_pcm_hw_params API; in addition to an approximate integer value, one might specify a direction. Is the direction parameter a way to instruct ALSA to look for a floating point value in either direction? If that's the case, couldn't this be handled with floats directly?

The direction means:

0 = use exactly equal number
-1 = use the most close previous number
1 = use the most close next number

You may also get most close value using the *_near() function. In this case, the direction selection is left on the library or driver code.

Regarding floats, we cannot use floats in a simple way in kernel so it's better to avoid this requirement.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0

#2 lore raw
Quoted 16 lines · Jaroslav Kysela
Quoted 7 lines · Arve Knudsen

Hi

I'm not sure if I quite understand the alsa-lib docs regarding the snd_pcm_hw_params API; in addition to an approximate integer value, one might specify a direction. Is the direction parameter a way to instruct ALSA to look for a floating point value in either direction? If that's the case, couldn't this be handled with floats directly?

The direction means:

0 = use exactly equal number
-1 = use the most close previous number
1 = use the most close next number

Quoted 5 lines

You may also get most close value using the *_near() function. In this case, the direction selection is left on the library or driver code.

Regarding floats, we cannot use floats in a simple way in kernel so it's better to avoid this requirement.

By most close, do you mean the nearest supported integer value, or floating point value? The terminology is a little unclear to me, but the existance of a set_integer method leads me to believe the latter is correct. I was meaning to use set_rate_near() to find me a suitable default samplerate, but if it returns an approximate (floating point) value, I would like to be able to report the exact value. The code is meant to hide implementation details across platforms, so I cannot expose ALSA-specifics such as sub-unit direction.

Thanks

Arve Knudsen

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#3 lore raw
Quoted 26 lines · Arve Knudsen
Quoted 17 lines · Jaroslav Kysela
Quoted 8 lines · Arve Knudsen

Hi

I'm not sure if I quite understand the alsa-lib docs regarding the snd_pcm_hw_params API; in addition to an approximate integer value, one might specify a direction. Is the direction parameter a way to instruct ALSA to look for a floating point value in either direction? If that's the
case, couldn't this be handled with floats directly?

The direction means:

0 = use exactly equal number
-1 = use the most close previous number
1 = use the most close next number

Quoted 5 lines

You may also get most close value using the *_near() function. In this case, the direction selection is left on the library or driver code.

Regarding floats, we cannot use floats in a simple way in kernel so it's better to avoid this requirement.

Quoted 6 lines

By most close, do you mean the nearest supported integer value, or floating point value? The terminology is a little unclear to me, but the existance of a set_integer method leads me to believe the latter is correct. I was meaning to use set_rate_near() to find me a suitable default samplerate, but if it returns an approximate (floating point) value, I would like to be able to report the exact value. The code is

For rate, use snd_pcm_hw_params_get_rate_numden() function which returns the floating point value in fraction. Other values are always processed as integers in the driver (with possible rounding). And yes, the most close value might be a floating point one but rounded to the integer value.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf