From cfc2ab92c0d2ff107d7ba724a8cd51402b6b1863 Mon Sep 17 00:00:00 2001 From: Michael Wilson Date: Wed, 14 Feb 2024 21:10:41 +0000 Subject: [PATCH] b/388556893 Allow WebAudio FIFO size to match callback buffer if it is very large The Web Audio FIFO is over-allocated to allow for growing if there are buffer xruns. However, on some Android devices there is a very large callback buffer which will fail a CHECK. Just match the callback buffer size in this case, to avoid crashing. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5293168 (cherry picked from commit 01cb952243ee9efca53b66f50d3026aeb5443049) --- .../blink/renderer/platform/audio/audio_destination.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/third_party/blink/renderer/platform/audio/audio_destination.cc b/third_party/blink/renderer/platform/audio/audio_destination.cc index 1073f50d0eee..59b5d9882ed9 100644 --- a/third_party/blink/renderer/platform/audio/audio_destination.cc +++ b/third_party/blink/renderer/platform/audio/audio_destination.cc @@ -316,9 +316,10 @@ AudioDestination::AudioDestination( context_sample_rate.has_value() ? context_sample_rate.value() : (web_audio_device_ ? web_audio_device_->SampleRate() : 0)), - fifo_(std::make_unique(number_of_output_channels, - kFIFOSize, - render_quantum_frames)), + fifo_(std::make_unique( + number_of_output_channels, + std::max(kFIFOSize, callback_buffer_size_ + render_quantum_frames), + render_quantum_frames)), output_bus_(AudioBus::Create(number_of_output_channels, render_quantum_frames, false)), @@ -355,9 +356,6 @@ AudioDestination::AudioDestination( fifo_->Push(render_bus_.get()); } - // Check if the requested buffer size is too large. - DCHECK_LE(callback_buffer_size_ + render_quantum_frames, kFIFOSize); - double scale_factor = 1.0; if (context_sample_rate_ != web_audio_device_->SampleRate()) {