Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw: add "min_rate" and "max_rate" as alternatives to single "rate" parameter #191

Closed
wants to merge 1 commit into from

Conversation

bku-sue
Copy link
Contributor

@bku-sue bku-sue commented Nov 15, 2021

Our typical use case is to limit the rate to between 44100 and 48000, as with these boundaries the resampling becomes easier, than if only allowing 48000.

…rameter

Signed-off-by: Benedek Kupper <benedek.kupper@streamunlimited.com>
err = _snd_pcm_hw_param_set_minmax(params, SND_PCM_HW_PARAM_RATE,
hw->rate, 0, hw->rate + 1, -1);
#if 1 // TODO: find out which arguments are correct
hw->rates.min, 0, hw->rates.max + 1, -1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct.

@@ -1863,6 +1870,26 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
rate = val;
continue;
}
if (strcmp(id, "min_rate") == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add extension to the rate field like:

rate [ 44100 48000 ]

The parser stores this as compound internally:

rate.0 44100
rate.1 48000

You may use a loop to parse this or snd_config_search() fcn (and look for '0' and '1' keys). There is snd_config_is_array() to check, if the compound is array.

@perexg perexg closed this in d85c0d8 May 20, 2022
perexg added a commit that referenced this pull request May 20, 2022
Allow three configuration types:

  rate 48000			# single rate
  rate [ 48000 ]		# single rate (2nd)
  rate [ 44100 48000 ]		# range

Fixes: #191
Fixes: ac04cb63 ("hw: add "min_rate" and "max_rate" as alternatives to single "rate" parameter")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
@perexg
Copy link
Member

perexg commented May 20, 2022

I implemented my suggestion in 7f2d6c3 and applied your change.

@bku-sue bku-sue deleted the pcm-hw-rate-minmax branch May 25, 2022 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants