[pulseaudio-discuss] [PATCH 4/5] pactl: Validate volume before setting

Arun Raghavan arun.raghavan at collabora.co.uk
Sat Oct 9 11:27:13 PDT 2010


This makes sure that a valid volume is provided before setting on
sink/sink-input/source.
---
 src/utils/pactl.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index cae96f2..98c4d45 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -1248,6 +1248,11 @@ int main(int argc, char *argv[]) {
                 goto quit;
             }
 
+            if (!PA_VOLUME_IS_VALID(v)) {
+                pa_log(_("Volume outside permissible range.\n"));
+                goto quit;
+            }
+
             sink_name = pa_xstrdup(argv[optind+1]);
             volume = (pa_volume_t) v;
 
@@ -1265,6 +1270,11 @@ int main(int argc, char *argv[]) {
                 goto quit;
             }
 
+            if (!PA_VOLUME_IS_VALID(v)) {
+                pa_log(_("Volume outside permissible range.\n"));
+                goto quit;
+            }
+
             source_name = pa_xstrdup(argv[optind+1]);
             volume = (pa_volume_t) v;
 
@@ -1287,6 +1297,11 @@ int main(int argc, char *argv[]) {
                 goto quit;
             }
 
+            if (!PA_VOLUME_IS_VALID(v)) {
+                pa_log(_("Volume outside permissible range.\n"));
+                goto quit;
+            }
+
             volume = (pa_volume_t) v;
 
         } else if (pa_streq(argv[optind], "set-sink-mute")) {
-- 
1.7.3.1




More information about the pulseaudio-discuss mailing list