Chromium Code Reviews| 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 db4c8b2cc9a016be3fa4e516175edb83966d166c..d1100fe249fbdac8eb4da5c244cd38ca3e6958c1 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; |
| + ASSERT(isMainThread()); |
|
hongchan
2016/05/13 01:20:12
DCHECK.
Raymond Toy
2016/05/20 23:12:01
Done.
|
| + |
| + 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) |