mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 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
|
|
@ -345,7 +345,7 @@ static int parse_sample_rate(pa_config_parser_state *state) {
|
|||
|
||||
c = state->data;
|
||||
|
||||
if (pa_atou(state->rvalue, &r) < 0 || r > (uint32_t) PA_RATE_MAX || r <= 0 ||
|
||||
if (pa_atou(state->rvalue, &r) < 0 || !pa_sample_rate_valid(r) ||
|
||||
!((r % 4000 == 0) || (r % 11025 == 0))) {
|
||||
pa_log(_("[%s:%u] Invalid sample rate '%s'."), state->filename, state->lineno, state->rvalue);
|
||||
return -1;
|
||||
|
|
@ -363,7 +363,7 @@ static int parse_alternate_sample_rate(pa_config_parser_state *state) {
|
|||
|
||||
c = state->data;
|
||||
|
||||
if (pa_atou(state->rvalue, &r) < 0 || r > (uint32_t) PA_RATE_MAX || r <= 0 ||
|
||||
if (pa_atou(state->rvalue, &r) < 0 || !pa_sample_rate_valid(r) ||
|
||||
!((r % 4000==0) || (r % 11025 == 0))) {
|
||||
pa_log(_("[%s:%u] Invalid sample rate '%s'."), state->filename, state->lineno, state->rvalue);
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue