Index: Source/modules/webaudio/AudioBufferSourceNode.cpp |
diff --git a/Source/modules/webaudio/AudioBufferSourceNode.cpp b/Source/modules/webaudio/AudioBufferSourceNode.cpp |
index 19aa3e6816aa3fe60e7acc8903a4862976a52c31..e9bb788e033e897f967969f35a96ee6554fb5b2a 100644 |
--- a/Source/modules/webaudio/AudioBufferSourceNode.cpp |
+++ b/Source/modules/webaudio/AudioBufferSourceNode.cpp |
@@ -28,6 +28,7 @@ |
#include "modules/webaudio/AudioBufferSourceNode.h" |
+#include "bindings/v8/ExceptionState.h" |
#include "core/page/PageConsole.h" |
#include "platform/audio/AudioUtilities.h" |
#include "modules/webaudio/AudioContext.h" |
@@ -335,9 +336,15 @@ void AudioBufferSourceNode::reset() |
m_lastGain = gain()->value(); |
} |
-bool AudioBufferSourceNode::setBuffer(AudioBuffer* buffer) |
+void AudioBufferSourceNode::setBuffer(AudioBuffer* buffer, ExceptionState& es) |
{ |
ASSERT(isMainThread()); |
+ // FIXME: It does not look like we should throw if the buffer is null as |
+ // the attribute is nullable in the specification. |
+ if (!buffer) { |
+ es.throwTypeError("buffer cannot be null"); |
+ return; |
+ } |
// The context must be locked since changing the buffer can re-configure the number of channels that are output. |
AudioContext::AutoLocker contextLocker(context()); |
@@ -349,8 +356,12 @@ bool AudioBufferSourceNode::setBuffer(AudioBuffer* buffer) |
// Do any necesssary re-configuration to the buffer's number of channels. |
unsigned numberOfChannels = buffer->numberOfChannels(); |
- if (numberOfChannels > AudioContext::maxNumberOfChannels()) |
- return false; |
+ if (numberOfChannels > AudioContext::maxNumberOfChannels()) { |
+ es.throwTypeError("number of input channels (" + String::number(numberOfChannels) |
+ + ") exceeds maximum (" |
+ + String::number(AudioContext::maxNumberOfChannels()) + ")."); |
+ return; |
+ } |
output(0)->setNumberOfChannels(numberOfChannels); |
@@ -363,8 +374,6 @@ bool AudioBufferSourceNode::setBuffer(AudioBuffer* buffer) |
m_virtualReadIndex = 0; |
m_buffer = buffer; |
- |
- return true; |
} |
unsigned AudioBufferSourceNode::numberOfChannels() |