mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-09 13:29:59 -05:00
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:
parent
1cda717252
commit
a67318f8af
12 changed files with 24 additions and 21 deletions
|
|
@ -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)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue