]> code.delx.au - pulseaudio/commitdiff
pactl: Validate volume before setting
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Sat, 9 Oct 2010 17:41:26 +0000 (23:11 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Thu, 14 Oct 2010 19:40:00 +0000 (01:10 +0530)
This makes sure that a valid volume is provided before setting on
sink/sink-input/source.

src/utils/pactl.c

index cae96f293fa00eef3fff572995e354ef7dbf9f78..98c4d455ac43edb55bb965e4a732a22fe905e3a2 100644 (file)
@@ -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")) {