Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Unified Diff: third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp

Issue 2712933003: PeriodicWave returns sine wave generator if no coefficients given (Closed)
Patch Set: Address review comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/constructor/periodicwave.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d55f92cb1be9ce48800ab23a2fc2785b7c136972..4a9e8db73300490a2b3c6b7a2de366ddb321e9fc 100644
--- a/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp
@@ -99,13 +99,6 @@ PeriodicWave* PeriodicWave::create(BaseAudioContext* context,
? options.disableNormalization()
: false;
- if (!options.hasReal() && !options.hasImag()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "At least one of real and imag members must be specified.");
- return nullptr;
- }
-
Vector<float> realCoef;
Vector<float> imagCoef;
@@ -115,11 +108,16 @@ PeriodicWave* PeriodicWave::create(BaseAudioContext* context,
imagCoef = options.imag();
else
imagCoef.resize(realCoef.size());
- } else {
- // We know real is not given, so imag must exist (because we checked for
- // this above).
+ } else if (options.hasImag()) {
+ // |real| not given, but we have |imag|.
imagCoef = options.imag();
realCoef.resize(imagCoef.size());
+ } else {
+ // Neither |real| nor |imag| given. Return an object that would
+ // generate a sine wave, which means real = [0,0], and imag = [0, 1]
+ realCoef.resize(2);
+ imagCoef.resize(2);
+ imagCoef[1] = 1;
}
return create(*context, realCoef.size(), realCoef.data(), imagCoef.size(),
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/constructor/periodicwave.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698