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

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

Issue 1497803002: Throw exceptions for invalid number of channels for ConvolverNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/convolver-channels-expected.txt ('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/ConvolverNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp b/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp
index 392f5d64fff9d52d965decf113cd12c5a65616f0..6cd7edcfd009b3a714b2e994d4f79b31dc4c7452 100644
--- a/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp
@@ -111,11 +111,16 @@ void ConvolverHandler::setBuffer(AudioBuffer* buffer, ExceptionState& exceptionS
unsigned numberOfChannels = buffer->numberOfChannels();
size_t bufferLength = buffer->length();
- // The current implementation supports up to four channel impulse responses, which are interpreted as true-stereo (see Reverb class).
- bool isBufferGood = numberOfChannels > 0 && numberOfChannels <= 4 && bufferLength;
- ASSERT(isBufferGood);
- if (!isBufferGood)
+ // The current implementation supports only 1-, 2-, or 4-channel impulse responses, with the
+ // 4-channel response being interpreted as true-stereo (see Reverb class).
+ bool isChannelCountGood = numberOfChannels == 1 || numberOfChannels == 2 || numberOfChannels == 4;
+
+ if (!isChannelCountGood) {
+ exceptionState.throwDOMException(
+ NotSupportedError,
+ "The buffer must have 1, 2, or 4 channels, not " + String::number(numberOfChannels));
return;
+ }
// Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and not a memcpy().
// This memory is simply used in the Reverb constructor and no reference to it is kept for later use in that class.
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/convolver-channels-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698