webrtc_apm: make APM process output to mono
To work around an issue that APM might pick the 1st channel of
input, process and then writes to all output channels.
The exact condition to trigger this:
(1) More than one channel in input
(2) More than one channel in output
(3) multi_channel_capture is false
We're not ready to turn on multi_channel_capture so the best option
is to address (2). This is an acceptable fix because it makes APM's
behavior align with browser APM.
BUG=b:190929775
TEST=Test with CRAS change to fake one channel to 0x00
cras_test_client -C /tmp/1 --effects aec
hexdump /tmp/1 to verify it's not full of 0x00
Cq-Depend: chromium:3082081
Change-Id: If5f79af87507e33e7027ea8f12080811d0300cf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/webrtc-apm/+/3067379
Reviewed-by: Per Åhgren <peah@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Per Åhgren <peah@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
diff --git a/webrtc_apm.cc b/webrtc_apm.cc
index 93cbc77..c8d3e8d 100644
--- a/webrtc_apm.cc
+++ b/webrtc_apm.cc
@@ -122,7 +122,8 @@
}
err = apm->Initialize(frame_rate, frame_rate, frame_rate,
- channel_layout, channel_layout, channel_layout);
+ channel_layout, webrtc::AudioProcessing::kMono,
+ channel_layout);
if (err) {
delete apm;
return NULL;
@@ -161,10 +162,12 @@
{
webrtc::AudioProcessing *apm;
- webrtc::StreamConfig config =
+ webrtc::StreamConfig iconfig =
webrtc::StreamConfig(rate, num_channels);
+ webrtc::StreamConfig oconfig =
+ webrtc::StreamConfig(rate, 1);
apm = reinterpret_cast<webrtc::AudioProcessing *>(ptr);
- return apm->ProcessStream(data, config, config, data);
+ return apm->ProcessStream(data, iconfig, oconfig, data);
}
void webrtc_apm_destroy(webrtc_apm ptr)