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

Fix incorrect DCHECK in GetFrequencyResponse

The DCHECK was checking that the arrays have positive lengths, but the
spec allows zero-length arrays too.  So change the spec to check for
non-negative values.  And also modify getFrequencyResponse to return
quickly if the length is 0.

This applies to both BiquadFilterNodes and IIRFilterNodes.

Bug: 1073557
Change-Id: I8c98cf01021c9ece5731ccf8fdbc1fe8fe97f39c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2163054Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762019}
parent 17edc742
...@@ -195,7 +195,7 @@ void BiquadDSPKernel::GetFrequencyResponse(BiquadDSPKernel& kernel, ...@@ -195,7 +195,7 @@ void BiquadDSPKernel::GetFrequencyResponse(BiquadDSPKernel& kernel,
// updating |kernel| while we're computing the response. // updating |kernel| while we're computing the response.
DCHECK(IsMainThread()); DCHECK(IsMainThread());
DCHECK_GT(n_frequencies, 0); DCHECK_GE(n_frequencies, 0);
DCHECK(frequency_hz); DCHECK(frequency_hz);
DCHECK(mag_response); DCHECK(mag_response);
DCHECK(phase_response); DCHECK(phase_response);
......
...@@ -284,9 +284,13 @@ void BiquadFilterNode::getFrequencyResponse( ...@@ -284,9 +284,13 @@ void BiquadFilterNode::getFrequencyResponse(
"frequencyHz length exceeds the maximum supported length"); "frequencyHz length exceeds the maximum supported length");
return; return;
} }
GetBiquadProcessor()->GetFrequencyResponse(
frequency_hz_length_as_int, frequency_hz.View()->Data(), // If the length is 0, there's nothing to do.
mag_response.View()->Data(), phase_response.View()->Data()); if (frequency_hz_length_as_int > 0) {
GetBiquadProcessor()->GetFrequencyResponse(
frequency_hz_length_as_int, frequency_hz.View()->Data(),
mag_response.View()->Data(), phase_response.View()->Data());
}
} }
void BiquadFilterNode::ReportDidCreate() { void BiquadFilterNode::ReportDidCreate() {
......
...@@ -28,7 +28,7 @@ void IIRDSPKernel::GetFrequencyResponse(int n_frequencies, ...@@ -28,7 +28,7 @@ void IIRDSPKernel::GetFrequencyResponse(int n_frequencies,
const float* frequency_hz, const float* frequency_hz,
float* mag_response, float* mag_response,
float* phase_response) { float* phase_response) {
DCHECK_GT(n_frequencies, 0); DCHECK_GE(n_frequencies, 0);
DCHECK(frequency_hz); DCHECK(frequency_hz);
DCHECK(mag_response); DCHECK(mag_response);
DCHECK(phase_response); DCHECK(phase_response);
......
...@@ -276,9 +276,13 @@ void IIRFilterNode::getFrequencyResponse( ...@@ -276,9 +276,13 @@ void IIRFilterNode::getFrequencyResponse(
"frequencyHz length exceeds the maximum supported length"); "frequencyHz length exceeds the maximum supported length");
return; return;
} }
GetIIRFilterProcessor()->GetFrequencyResponse(
frequency_hz_length_as_int, frequency_hz.View()->Data(), // Nothing to do if the length is 0.
mag_response.View()->Data(), phase_response.View()->Data()); if (frequency_hz_length_as_int > 0) {
GetIIRFilterProcessor()->GetFrequencyResponse(
frequency_hz_length_as_int, frequency_hz.View()->Data(),
mag_response.View()->Data(), phase_response.View()->Data());
}
} }
void IIRFilterNode::ReportDidCreate() { void IIRFilterNode::ReportDidCreate() {
......
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