Skip to content

Commit

Permalink
Allow WebAudio FIFO size to match callback buffer if it is very large…
Browse files Browse the repository at this point in the history
… (#4676)

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.

This change is backported from m123+.

(cherry picked from commit 01cb952)

Bug: 324797343 
Reviewed-on:
https://chromium-review.googlesource.com/c/chromium/src/+/5293168

Co-authored-by: Michael Wilson <[email protected]>
  • Loading branch information
sideb0ard and Michael Wilson authored Jan 13, 2025
1 parent 8b317b2 commit 208fd28
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 208fd28

Please sign in to comment.