Commit 458f093d authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[webaudio] Use lengthAsSizeT in WaveShaperNode

This CL replaces calls to deprecatedLengthAsUnsigned by calls to
lengthAsSizeT. Unfortunately the current implementation cannot deal
with huge ArrayBuffers yet. Therefore I reject the incoming
ArrayBuffers with a RangeError if its size is too big.

Background: we prepare ArrayBuffers to be bigger than 4GB. Therefore we
changed the size field to size_t. Now we are changing all uses of
ByteLength to be able to deal with size_t, either by accepting a size_t,
or by throwing an exception if the size is too big.

R=rtoy@chromium.org

Bug: chromium:1008840
Change-Id: If2518d9ea341212b9024f2b2f9e0f8d07db9899b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1975883
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726450}
parent 8b295bcc
......@@ -82,16 +82,26 @@ WaveShaperProcessor* WaveShaperNode::GetWaveShaperProcessor() const {
}
void WaveShaperNode::SetCurveImpl(const float* curve_data,
unsigned curve_length,
size_t curve_length,
ExceptionState& exception_state) {
DCHECK(IsMainThread());
if (curve_data && curve_length < 2) {
exception_state.ThrowDOMException(
DOMExceptionCode::kInvalidAccessError,
ExceptionMessages::IndexExceedsMinimumBound<unsigned>("curve length",
curve_length, 2));
return;
unsigned length = static_cast<unsigned>(curve_length);
if (curve_data) {
if (!base::CheckedNumeric<unsigned>(curve_length).AssignIfValid(&length)) {
exception_state.ThrowDOMException(
DOMExceptionCode::kNotSupportedError,
"The curve length exceeds the maximum supported length");
return;
}
if (length < 2) {
exception_state.ThrowDOMException(
DOMExceptionCode::kInvalidAccessError,
ExceptionMessages::IndexExceedsMinimumBound<unsigned>("curve length",
length, 2));
return;
}
}
// This is to synchronize with the changes made in
......@@ -99,7 +109,7 @@ void WaveShaperNode::SetCurveImpl(const float* curve_data,
// Initialize() and Uninitialize(), changing the number of kernels.
BaseAudioContext::GraphAutoLocker context_locker(context());
GetWaveShaperProcessor()->SetCurve(curve_data, curve_length);
GetWaveShaperProcessor()->SetCurve(curve_data, length);
}
void WaveShaperNode::setCurve(NotShared<DOMFloat32Array> curve,
......@@ -107,8 +117,8 @@ void WaveShaperNode::setCurve(NotShared<DOMFloat32Array> curve,
DCHECK(IsMainThread());
if (curve) {
SetCurveImpl(curve.View()->Data(),
curve.View()->deprecatedLengthAsUnsigned(), exception_state);
SetCurveImpl(curve.View()->Data(), curve.View()->lengthAsSizeT(),
exception_state);
} else {
SetCurveImpl(nullptr, 0, exception_state);
}
......
......@@ -71,7 +71,7 @@ class WaveShaperNode final : public AudioNode {
private:
void SetCurveImpl(const float* curve_data,
unsigned curve_length,
size_t curve_length,
ExceptionState&);
WaveShaperProcessor* GetWaveShaperProcessor() const;
};
......
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