Skip to content

Commit

Permalink
b/388556893
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Michael Wilson authored and sideb0ard committed Jan 9, 2025
1 parent 148c54e commit cfc2ab9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions third_party/blink/renderer/platform/audio/audio_destination.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<PushPullFIFO>(number_of_output_channels,
kFIFOSize,
render_quantum_frames)),
fifo_(std::make_unique<PushPullFIFO>(
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)),
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit cfc2ab9

Please sign in to comment.