From dbf7cad04f2cc63f31f28246bf6ff3b0bf048613 Mon Sep 17 00:00:00 2001 From: Marcelo Fernandez Date: Sat, 17 Nov 2018 21:16:06 -0300 Subject: [PATCH] Fix distorted sound with PulseAudio and uneven channels --- drivers/pulseaudio/audio_driver_pulseaudio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index d78316945f3..010f7bdb0a7 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -346,9 +346,9 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) { for (int j = 0; j < ad->pa_map.channels - 1; j++) { ad->samples_out.write[out_idx++] = ad->samples_in[in_idx++] >> 16; } - uint32_t l = ad->samples_in[in_idx++]; - uint32_t r = ad->samples_in[in_idx++]; - ad->samples_out.write[out_idx++] = ((l >> 1) + (r >> 1)) >> 16; + uint32_t l = ad->samples_in[in_idx++] >> 16; + uint32_t r = ad->samples_in[in_idx++] >> 16; + ad->samples_out.write[out_idx++] = (l + r) / 2; } } }