Commit 6c0a76b1 authored by Gustaf Ullberg's avatar Gustaf Ullberg Committed by Chromium LUCI CQ

Explicitly set the number of output channels for discrete channel layout

This change makes sure that the number of output channels of the media
stream audio processor is set correctly when using a discrete channel
layout as input.

This fixes a crash when making calls with audio processing enabled while
using a discrete channel layout for input.

Bug: 1169678
Change-Id: I68e37e1ecff74e86ec0248838e4c9d3c740547a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2643280Reviewed-by: default avatarHenrik Andreasson <henrika@chromium.org>
Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Commit-Queue: Gustaf Ullberg <gustaf@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846125}
parent cb0a8400
......@@ -725,6 +725,10 @@ void MediaStreamAudioProcessor::InitializeCaptureFifo(
output_format_ = media::AudioParameters(
media::AudioParameters::AUDIO_PCM_LOW_LATENCY, output_channel_layout,
output_sample_rate, output_frames);
if (output_channel_layout == media::CHANNEL_LAYOUT_DISCRETE) {
// Explicitly set number of channels for discrete channel layouts.
output_format_.set_channels_for_discrete(input_format.channels());
}
capture_fifo_.reset(
new MediaStreamAudioFifo(input_format.channels(), fifo_output_channels,
......
......@@ -532,4 +532,26 @@ TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgcSimdNotAllowed) {
EXPECT_FALSE(apm_config->gain_controller2.adaptive_digital.neon_allowed);
}
// Ensure that discrete channel layouts do not crash with audio processing
// enabled.
TEST_F(MediaStreamAudioProcessorTest, DiscreteChannelLayout) {
blink::AudioProcessingProperties properties;
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new rtc::RefCountedObject<WebRtcAudioDeviceImpl>());
scoped_refptr<MediaStreamAudioProcessor> audio_processor(
new rtc::RefCountedObject<MediaStreamAudioProcessor>(
properties, webrtc_audio_device.get()));
EXPECT_TRUE(audio_processor->has_audio_processing());
media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
media::CHANNEL_LAYOUT_DISCRETE, 48000, 480);
// Test both 1 and 2 discrete channels.
for (int channels = 1; channels <= 2; ++channels) {
params.set_channels_for_discrete(channels);
audio_processor->OnCaptureFormatChanged(params);
}
audio_processor->Stop();
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment