[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] pactl: fix parsing of percentages with decimal points
Tanu Kaskinen (@tanuk)
gitlab at gitlab.freedesktop.org
Sat Jun 4 08:08:19 UTC 2022
Tanu Kaskinen pushed to branch master at PulseAudio / pulseaudio
Commits:
05c06afa by Sean Greenslade at 2022-06-04T00:24:49-07:00
pactl: fix parsing of percentages with decimal points
The logic for detecting which type of volume was given incorrectly interpreted
any value with a decimal as a VOL_LINEAR. It also could set multiple flags,
which would put the flags variable into an indeterminate state. Additionally,
the flags stack variable was uninitialized which could also lead to an
indeterminate flag state.
Percentages are now prioritized over all other types, and only one type flag
can be set.
- - - - -
1 changed file:
- src/utils/pactl.c
Changes:
=====================================
src/utils/pactl.c
=====================================
@@ -2527,16 +2527,16 @@ static int parse_volume(const char *vol_spec, pa_volume_t *vol, enum volume_flag
vs = pa_xstrdup(vol_spec);
*vol_flags = (pa_startswith(vs, "+") || pa_startswith(vs, "-")) ? VOL_RELATIVE : VOL_ABSOLUTE;
- if (strchr(vs, '.'))
- *vol_flags |= VOL_LINEAR;
if (pa_endswith(vs, "%")) {
*vol_flags |= VOL_PERCENT;
vs[strlen(vs)-1] = 0;
}
- if (pa_endswith(vs, "db") || pa_endswith(vs, "dB")) {
+ else if (pa_endswith(vs, "db") || pa_endswith(vs, "dB")) {
*vol_flags |= VOL_DECIBEL;
vs[strlen(vs)-2] = 0;
}
+ else if (strchr(vs, '.'))
+ *vol_flags |= VOL_LINEAR;
atod_input = vs;
@@ -2597,7 +2597,7 @@ static int parse_volumes(char *args[], unsigned n) {
volume.channels = n;
for (i = 0; i < volume.channels; i++) {
- enum volume_flags flags;
+ enum volume_flags flags = 0;
if (parse_volume(args[i], &volume.values[i], &flags) < 0)
return -1;
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/05c06afa58e30b7958e96766d1e917099c8a4041
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/05c06afa58e30b7958e96766d1e917099c8a4041
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20220604/d2fab1d2/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list