[pulseaudio-discuss] [PATCH 2/5] pactl: Cleanup patch

Peter Meerwald pmeerw at pmeerw.net
Fri Feb 14 01:11:48 PST 2014


to be folded after review

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/utils/pactl.c | 43 +++++++++++++++----------------------------
 1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index f199f77..f0f4878 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -838,17 +838,15 @@ static void volume_relative_adjust(pa_cvolume *cv) {
      * and multiplicative for LINEAR or DECIBEL */
     if ((volume_flags & 0x0F) == VOL_UINT || (volume_flags & 0x0F) == VOL_PERCENT) {
         unsigned i;
-        for (i = 0; i < cv->channels; i++)
-        {
+        for (i = 0; i < cv->channels; i++) {
             if (cv->values[i] + volume.values[i] < PA_VOLUME_NORM)
                 cv->values[i] = PA_VOLUME_MUTED;
             else
                 cv->values[i] += volume.values[i] - PA_VOLUME_NORM;
         }
     }
-    if ((volume_flags & 0x0F) == VOL_LINEAR || (volume_flags & 0x0F) == VOL_DECIBEL) {
+    if ((volume_flags & 0x0F) == VOL_LINEAR || (volume_flags & 0x0F) == VOL_DECIBEL)
         pa_sw_cvolume_multiply(cv, cv, &volume);
-    }
 }
 
 static void unload_module_by_name_callback(pa_context *c, const pa_module_info *i, int is_last, void *userdata) {
@@ -1851,7 +1849,7 @@ int main(int argc, char *argv[]) {
             source_name = pa_xstrdup(argv[optind+1]);
 
         } else if (pa_streq(argv[optind], "set-sink-volume")) {
-            unsigned i=0;
+            unsigned i;
             action = SET_SINK_VOLUME;
 
             if (argc < optind+3) {
@@ -1863,16 +1861,14 @@ int main(int argc, char *argv[]) {
 
             volume.channels = argc-3;
 
-            for(i=0; i < volume.channels; i++)
-            {
-                if (argv[optind+2+i] == NULL)
-                    volume.channels--;
-                else if (parse_volume(argv[optind+2+i], &volume.values[i], &volume_flags) < 0)
+            for (i = 0; i < volume.channels; i++) {
+                if (parse_volume(argv[optind+2+i],
+                    &volume.values[i], &volume_flags) < 0)
                     goto quit;
             }
 
         } else if (pa_streq(argv[optind], "set-source-volume")) {
-            unsigned i=0;
+            unsigned i;
             action = SET_SOURCE_VOLUME;
 
             if (argc < optind+3) {
@@ -1884,16 +1880,13 @@ int main(int argc, char *argv[]) {
 
             volume.channels = argc-3;
 
-            for(i=0; i < volume.channels; i++)
-            {
-                if (argv[optind+2+i] == NULL)
-                    volume.channels--;
-                else if (parse_volume(argv[optind+2+i], &volume.values[i], &volume_flags) < 0)
+            for (i = 0; i < volume.channels; i++) {
+                if (parse_volume(argv[optind+2+i], &volume.values[i], &volume_flags) < 0)
                     goto quit;
             }
 
         } else if (pa_streq(argv[optind], "set-sink-input-volume")) {
-            unsigned i=0;
+            unsigned i;
             action = SET_SINK_INPUT_VOLUME;
 
             if (argc < optind+3) {
@@ -1908,16 +1901,13 @@ int main(int argc, char *argv[]) {
 
             volume.channels = argc-3;
 
-            for(i=0; i < volume.channels; i++)
-            {
-                if (argv[optind+2+i] == NULL)
-                    volume.channels--;
-                else if (parse_volume(argv[optind+2+i], &volume.values[i], &volume_flags) < 0)
+            for (i = 0; i < volume.channels; i++) {
+                if (parse_volume(argv[optind+2+i], &volume.values[i], &volume_flags) < 0)
                     goto quit;
             }
 
         } else if (pa_streq(argv[optind], "set-source-output-volume")) {
-            unsigned i=0;
+            unsigned i;
             action = SET_SOURCE_OUTPUT_VOLUME;
 
             if (argc < optind+3) {
@@ -1932,11 +1922,8 @@ int main(int argc, char *argv[]) {
 
             volume.channels = argc-3;
 
-            for(i=0; i < volume.channels; i++)
-            {
-                if (argv[optind+2+i] == NULL)
-                    volume.channels--;
-                else if (parse_volume(argv[optind+2+i], &volume.values[i], &volume_flags) < 0)
+            for (i = 0; i < volume.channels; i++) {
+                if (parse_volume(argv[optind+2+i], &volume.values[i], &volume_flags) < 0)
                     goto quit;
             }
 
-- 
1.8.3.2



More information about the pulseaudio-discuss mailing list