Add pa_sample_rate_valid()

I think this makes the code a bit nicer to read and write. This also
reduces the chances of off-by-one errors when checking the bounds of
sample rate values.
This commit is contained in:
Tanu Kaskinen 2013-12-04 09:50:10 +02:00 committed by Peter Meerwald
parent 1cda717252
commit a67318f8af
12 changed files with 24 additions and 21 deletions

View file

@ -371,8 +371,7 @@ int pa_modargs_get_sample_rate(pa_modargs *ma, uint32_t *rate) {
rate_local = *rate;
if ((pa_modargs_get_value_u32(ma, "rate", &rate_local)) < 0 ||
rate_local <= 0 ||
rate_local > PA_RATE_MAX)
!pa_sample_rate_valid(rate_local))
return -1;
*rate = rate_local;
@ -417,8 +416,7 @@ int pa_modargs_get_alternate_sample_rate(pa_modargs *ma, uint32_t *alternate_rat
rate_local = *alternate_rate;
if ((pa_modargs_get_value_u32(ma, "alternate_rate", &rate_local)) < 0 ||
rate_local <= 0 ||
rate_local > PA_RATE_MAX)
!pa_sample_rate_valid(*alternate_rate))
return -1;
if (!((rate_local % 4000 == 0) || (rate_local % 11025 == 0)))