From 77ce54c6984cadb91d105c5ed768a07bdbdfee5a Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 11 May 2014 16:37:52 +0200 Subject: mixer: make code more readable You wouldn't have guessed that the bottom-most "level[i] = 0.f;" line was actually required. It even confused cppcheck. --- audio/mixer.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/audio/mixer.c b/audio/mixer.c index 208aea955a..7a26b83e5e 100644 --- a/audio/mixer.c +++ b/audio/mixer.c @@ -198,9 +198,6 @@ void mixer_getbalance(struct mixer *mixer, float *val) void mixer_setbalance(struct mixer *mixer, float val) { - float level[AF_NCH]; - int i; - af_control_ext_t arg_ext = { .arg = level }; struct af_instance *af_pan_balance; mixer->balance = val; @@ -220,13 +217,12 @@ void mixer_setbalance(struct mixer *mixer, float val) } /* make all other channels pass thru since by default pan blocks all */ - memset(level, 0, sizeof(level)); - for (i = 2; i < AF_NCH; i++) { - arg_ext.ch = i; + for (int i = 2; i < AF_NCH; i++) { + float level[AF_NCH] = {0}; level[i] = 1.f; + af_control_ext_t arg_ext = { .ch = i, .arg = level }; af_pan_balance->control(af_pan_balance, AF_CONTROL_SET_PAN_LEVEL, &arg_ext); - level[i] = 0.f; } af_pan_balance->control(af_pan_balance, AF_CONTROL_SET_PAN_BALANCE, &val); -- cgit v1.2.3