Skip to content

Commit

Permalink
Fix crash in PulseAudio when ChannelLayout is "DISCRETE"
Browse files Browse the repository at this point in the history
When AudioParameters is created, the channel count defaults to zero
when a given ChannelLayout is DISCRETE. This makes the build crash
because of CHECK() failure. This CL fixes the crash and also contains
the channel layout handling in PulseAudio for the DISCRETE case.

Bug: 827668
Test: The repro case on the issue does not crash anymore.
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I222422f76df746c9113ca6586be311790048c6e4
Reviewed-on: https://chromium-review.googlesource.com/988306
Reviewed-by: Dale Curtis <[email protected]>
Commit-Queue: Hongchan Choi <[email protected]>
Cr-Commit-Position: refs/heads/master@{#550866}
  • Loading branch information
hoch authored and Commit Bot committed Apr 14, 2018
1 parent d4d01fd commit 6b9f571
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions content/renderer/media/audio_renderer_mixer_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ media::AudioParameters GetMixerOutputParams(
input_params.channel_layout(),
output_sample_rate, 16, output_buffer_size);

// Use the actual channel count when the channel layout is "DISCRETE".
if (input_params.channel_layout() == media::CHANNEL_LAYOUT_DISCRETE)
params.set_channels_for_discrete(input_params.channels());

// Specify the latency info to be passed to the browser side.
params.set_latency_tag(latency);
return params;
Expand Down
8 changes: 7 additions & 1 deletion media/audio/pulse/audio_manager_pulse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters(

if (input_params.IsValid()) {
bits_per_sample = input_params.bits_per_sample();
channel_layout = input_params.channel_layout();

// Use the system's output channel count for the DISCRETE layout. This is to
// avoid a crash due to the lack of support on the multi-channel beyond 8 in
// the PulseAudio layer.
if (input_params.channel_layout() != CHANNEL_LAYOUT_DISCRETE)
channel_layout = input_params.channel_layout();

buffer_size =
std::min(kMaximumOutputBufferSize,
std::max(buffer_size, input_params.frames_per_buffer()));
Expand Down

0 comments on commit 6b9f571

Please sign in to comment.