| Index: third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp
|
| diff --git a/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp b/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp
|
| index f630e8f4acf4983d1b0afc82519145673dcd92ca..cbe3d437b6c15313156e4dd7d2acb873883de5ee 100644
|
| --- a/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp
|
| +++ b/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp
|
| @@ -27,6 +27,10 @@
|
| */
|
|
|
| #include "modules/webaudio/PeriodicWave.h"
|
| +#include "bindings/core/v8/ExceptionMessages.h"
|
| +#include "bindings/core/v8/ExceptionState.h"
|
| +#include "core/dom/ExceptionCode.h"
|
| +#include "modules/webaudio/AbstractAudioContext.h"
|
| #include "modules/webaudio/OscillatorNode.h"
|
| #include "platform/audio/FFTFrame.h"
|
| #include "platform/audio/VectorMath.h"
|
| @@ -45,17 +49,33 @@ const float CentsPerRange = 1200 / kNumberOfOctaveBands;
|
|
|
| using namespace VectorMath;
|
|
|
| -PeriodicWave* PeriodicWave::create(float sampleRate, DOMFloat32Array* real, DOMFloat32Array* imag, bool disableNormalization)
|
| +PeriodicWave* PeriodicWave::create(
|
| + AbstractAudioContext& context,
|
| + DOMFloat32Array* real,
|
| + DOMFloat32Array* imag,
|
| + bool disableNormalization,
|
| + ExceptionState& exceptionState)
|
| {
|
| - bool isGood = real && imag && real->length() == imag->length();
|
| - ASSERT(isGood);
|
| - if (isGood) {
|
| - PeriodicWave* periodicWave = new PeriodicWave(sampleRate);
|
| - size_t numberOfComponents = real->length();
|
| - periodicWave->createBandLimitedTables(real->data(), imag->data(), numberOfComponents, disableNormalization);
|
| - return periodicWave;
|
| + DCHECK(isMainThread());
|
| +
|
| + if (context.isContextClosed()) {
|
| + context.throwExceptionForClosedState(exceptionState);
|
| + return nullptr;
|
| + }
|
| +
|
| + if (real->length() != imag->length()) {
|
| + exceptionState.throwDOMException(
|
| + IndexSizeError,
|
| + "length of real array (" + String::number(real->length())
|
| + + ") and length of imaginary array (" + String::number(imag->length())
|
| + + ") must match.");
|
| + return nullptr;
|
| }
|
| - return nullptr;
|
| +
|
| + PeriodicWave* periodicWave = new PeriodicWave(context.sampleRate());
|
| + size_t numberOfComponents = real->length();
|
| + periodicWave->createBandLimitedTables(real->data(), imag->data(), numberOfComponents, disableNormalization);
|
| + return periodicWave;
|
| }
|
|
|
| PeriodicWave* PeriodicWave::createSine(float sampleRate)
|
|
|