mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -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
|
|
@ -263,7 +263,7 @@ static int ucm_get_device_property(
|
|||
/* get rate */
|
||||
if ((value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_PLAYBACK_RATE)) ||
|
||||
(value = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_PLAYBACK_RATE))) {
|
||||
if (pa_atou(value, &ui) == 0 && ui > 0 && ui < PA_RATE_MAX) {
|
||||
if (pa_atou(value, &ui) == 0 && pa_sample_rate_valid(ui)) {
|
||||
pa_log_debug("UCM playback device %s rate %d", device_name, ui);
|
||||
device->playback_rate = ui;
|
||||
} else
|
||||
|
|
@ -284,7 +284,7 @@ static int ucm_get_device_property(
|
|||
/* get rate */
|
||||
if ((value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_CAPTURE_RATE)) ||
|
||||
(value = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_CAPTURE_RATE))) {
|
||||
if (pa_atou(value, &ui) == 0 && ui > 0 && ui < PA_RATE_MAX) {
|
||||
if (pa_atou(value, &ui) == 0 && pa_sample_rate_valid(ui)) {
|
||||
pa_log_debug("UCM capture device %s rate %d", device_name, ui);
|
||||
device->capture_rate = ui;
|
||||
} else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue