summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2012-08-08 16:01:38 +0200
committerDavid Henningsson <david.henningsson@canonical.com>2012-08-15 09:27:48 +0200
commitff4af902cf4ac07c5f1da3b6dacbb3195c7c222d (patch)
treed8c952c64d243e22a167c7aaee738e26d9ae2cf0
parent9887cd0a288f6af12b0c53e0b4f3d7fcd3511c71 (diff)
resampler: Fix volume on downmix to mono
Patch credit: kwanghui When downmixing to mono, we should average the signal instead of summing it to avoid clipping. BugLink: http://pulseaudio.org/ticket/934 BugLink: https://bugs.launchpad.net/bugs/416190 Signed-off-by: David Henningsson <david.henningsson@canonical.com>
-rw-r--r--src/pulsecore/resampler.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 9f1955913..7ac5f19cb 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -716,7 +716,7 @@ static void calc_map_table(pa_resampler *r) {
716 * 716 *
717 * 2) Mono Handling: 717 * 2) Mono Handling:
718 * S:Mono: Copy into all D:channels 718 * S:Mono: Copy into all D:channels
719 * D:Mono: Copy in all S:channels 719 * D:Mono: Avg all S:channels
720 * 720 *
721 * 3) Mix D:Left, D:Right: 721 * 3) Mix D:Left, D:Right:
722 * D:Left: If not connected, avg all S:Left 722 * D:Left: If not connected, avg all S:Left
@@ -759,12 +759,19 @@ static void calc_map_table(pa_resampler *r) {
759 * best to pass it to L+R. 759 * best to pass it to L+R.
760 */ 760 */
761 761
762 if (a == b || a == PA_CHANNEL_POSITION_MONO || b == PA_CHANNEL_POSITION_MONO) { 762 if (a == b || a == PA_CHANNEL_POSITION_MONO) {
763 m->map_table_f[oc][ic] = 1.0; 763 m->map_table_f[oc][ic] = 1.0;
764 764
765 oc_connected = TRUE; 765 oc_connected = TRUE;
766 ic_connected[ic] = TRUE; 766 ic_connected[ic] = TRUE;
767 } 767 }
768 else if (b == PA_CHANNEL_POSITION_MONO) {
769 if (n_ic)
770 m->map_table_f[oc][ic] = 1.0f / (float) n_ic;
771
772 oc_connected = TRUE;
773 ic_connected[ic] = TRUE;
774 }
768 } 775 }
769 776
770 if (!oc_connected && remix) { 777 if (!oc_connected && remix) {