From 0a02a3302301103d60a8e663f80820a25b69ac87 Mon Sep 17 00:00:00 2001
From: Dragos Oancea <dragos@signalwire.com>
Date: Tue, 19 Mar 2019 13:05:51 +0000
Subject: [PATCH] FS-11480: revert change for FS-11424 which introduced
 screeching after muxing (thanks Sergey KHripchenko)

---
 src/switch_resample.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/switch_resample.c b/src/switch_resample.c
index 0b763e597a..2c9529b8e2 100644
--- a/src/switch_resample.c
+++ b/src/switch_resample.c
@@ -281,11 +281,9 @@ SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, switch_size_t samples, u
 	if (orig_channels > channels) {
 		if (channels == 1) {
 			for (i = 0; i < samples; i++) {
-				int32_t z = 0; int16_t y, last = 0;
+				int32_t z = 0;
 				for (j = 0; j < orig_channels; j++) {
-					y = (int16_t) data[i * orig_channels + j];
-					if (y != last) z += y;
-					last = y;
+					z += (int16_t) data[i * orig_channels + j];
 				}
 				switch_normalize_to_16bit(z);
 				data[i] = (int16_t) z;
@@ -293,16 +291,12 @@ SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, switch_size_t samples, u
 		} else if (channels == 2) {
 			int mark_buf = 0;
 			for (i = 0; i < samples; i++) {
-				int32_t z_left = 0, z_right = 0; int16_t y_left, y_right, last_left = 0, last_right = 0;
+				int32_t z_left = 0, z_right = 0;
 				for (j = 0; j < orig_channels; j++) {
 					if (j % 2) {
-						y_left = (int16_t) data[i * orig_channels + j];
-						if (y_left != last_left) z_left += y_left;
-						last_left = y_left;
+						z_left += (int16_t) data[i * orig_channels + j];
 					} else {
-						y_right = (int16_t) data[i * orig_channels + j];
-						if (y_right != last_right) z_right += y_right;
-						last_right = y_right;
+						z_right += (int16_t) data[i * orig_channels + j];
 					}
 				}
 				/* mark_buf will always be smaller than the size of data in bytes because orig_channels > channels */