Commit 331dd506 authored by Hongchan Choi's avatar Hongchan Choi Committed by Commit Bot

Prime PushPullFIFO before starting AudioDestination

Currently AudioDestination starts with an empty PushPullFIFO, so
the first callback from the AudioDeviceThread always ends up with
a bogus "glitch report" on the histogram.

This CL fixes the issue by priming (prefill) the PushPullFIFO to cover
the first callback from the ADT.

Bug: 833766
Change-Id: I17e40df31586c9dd3e3678706d47f08693b96d45
Reviewed-on: https://chromium-review.googlesource.com/1015201Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551504}
parent a0b27a2c
......@@ -82,6 +82,15 @@ AudioDestination::AudioDestination(AudioIOCallback& callback,
DCHECK(web_audio_device_);
callback_buffer_size_ = web_audio_device_->FramesPerBuffer();
// Primes the FIFO for the given callback buffer size. This is to prevent
// first FIFO pulls from causing "underflow" errors.
unsigned priming_render_quanta =
ceil(callback_buffer_size_/(float)AudioUtilities::kRenderQuantumFrames);
for (unsigned i = 0; i < priming_render_quanta; ++i) {
fifo_->Push(render_bus_.get());
}
if (!CheckBufferSize()) {
NOTREACHED();
}
......
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