Commit 37087033 authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

More debugging of ComputeOutput

Add some more checks and a logging message if indices are out of
range.  We're trying to figure out what's happening here.  I've been
unable to reproduce the issue.

Bug: 1116104
Change-Id: Ic5343d03b2a944bb4aa421e86ac8259803cb9363
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2411424Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808067}
parent 4b413cbc
...@@ -406,7 +406,8 @@ unsigned AudioBufferSourceHandler::ComputeOutput( ...@@ -406,7 +406,8 @@ unsigned AudioBufferSourceHandler::ComputeOutput(
const struct InterpolationInfo& interp_info, const struct InterpolationInfo& interp_info,
int frames_processed, int frames_processed,
unsigned write_index, unsigned write_index,
unsigned number_of_channels) const { unsigned number_of_channels,
unsigned buffer_length) const {
unsigned* read0 = interp_info.read0; unsigned* read0 = interp_info.read0;
unsigned* read1 = interp_info.read1; unsigned* read1 = interp_info.read1;
float* interp_factor = interp_info.interp_factor; float* interp_factor = interp_info.interp_factor;
...@@ -421,12 +422,21 @@ unsigned AudioBufferSourceHandler::ComputeOutput( ...@@ -421,12 +422,21 @@ unsigned AudioBufferSourceHandler::ComputeOutput(
if (read0[k] == read1[k] && read0[k] >= 1) { if (read0[k] == read1[k] && read0[k] >= 1) {
// We're at the end of the buffer, so just linearly extrapolate from // We're at the end of the buffer, so just linearly extrapolate from
// the last two samples. // the last two samples.
DCHECK_LT(read0[k], buffer_length);
float sample1 = source[read0[k] - 1]; float sample1 = source[read0[k] - 1];
float sample2 = source[read0[k]]; float sample2 = source[read0[k]];
sample = sample2 + (sample2 - sample1) * interp_factor[k]; sample = sample2 + (sample2 - sample1) * interp_factor[k];
} else { } else {
DCHECK_LT(read0[k], buffer_length);
DCHECK_LT(read1[k], buffer_length);
// TODO(crbug.com/1116104). If read1[k] is out-of-bounds, just return
// 0. Remove this when the underlying problem is fixed.
if (read1[k] >= buffer_length) {
VLOG(1) << "k = " << k << "frames = " << frames_processed
<< "read1 = " << read1[k];
}
float sample1 = source[read0[k]]; float sample1 = source[read0[k]];
float sample2 = source[read1[k]]; float sample2 = read1[k] < buffer_length ? source[read1[k]] : 0;
sample = sample1 + interp_factor[k] * (sample2 - sample1); sample = sample1 + interp_factor[k] * (sample2 - sample1);
} }
destination[write_index] = sample; destination[write_index] = sample;
...@@ -465,9 +475,13 @@ double AudioBufferSourceHandler::RenderFromBufferKernel( ...@@ -465,9 +475,13 @@ double AudioBufferSourceHandler::RenderFromBufferKernel(
ComputeIndices(interp_info, indices_info, frames_to_process, ComputeIndices(interp_info, indices_info, frames_to_process,
buffer_length, Loop()); buffer_length, Loop());
write_index = // TODO(crbug.com/1116104): Debugging possible error cases. Remove this (or
ComputeOutput(destination_channels, source_channels, interp_info, // convert to DCHECK) when the underlying issue is fixed.
frames_processed, write_index, number_of_channels); CHECK_LE(frames_processed,
static_cast<int>(audio_utilities::kRenderQuantumFrames));
write_index = ComputeOutput(destination_channels, source_channels,
interp_info, frames_processed, write_index,
number_of_channels, buffer_length);
if (end_of_buffer_reached) { if (end_of_buffer_reached) {
RenderSilenceAndFinishIfNotLooping(bus, write_index, RenderSilenceAndFinishIfNotLooping(bus, write_index,
......
...@@ -179,7 +179,8 @@ class AudioBufferSourceHandler final : public AudioScheduledSourceHandler { ...@@ -179,7 +179,8 @@ class AudioBufferSourceHandler final : public AudioScheduledSourceHandler {
const struct InterpolationInfo& interp_info, const struct InterpolationInfo& interp_info,
int frames_processed, int frames_processed,
unsigned write_index, unsigned write_index,
unsigned number_of_channels) const; unsigned number_of_channels,
unsigned buffer_length) const;
// Render silence starting from "index" frame in AudioBus. // Render silence starting from "index" frame in AudioBus.
inline bool RenderSilenceAndFinishIfNotLooping(AudioBus*, inline bool RenderSilenceAndFinishIfNotLooping(AudioBus*,
......
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