| Index: Source/modules/webaudio/AudioBufferSourceNode.cpp
|
| diff --git a/Source/modules/webaudio/AudioBufferSourceNode.cpp b/Source/modules/webaudio/AudioBufferSourceNode.cpp
|
| index 9541cdb3377d309e529c88ff0a06cc5ef854c8e7..37437a2e3072ea6aea496f20b309a33f44832dac 100644
|
| --- a/Source/modules/webaudio/AudioBufferSourceNode.cpp
|
| +++ b/Source/modules/webaudio/AudioBufferSourceNode.cpp
|
| @@ -58,6 +58,7 @@ PassRefPtr<AudioBufferSourceNode> AudioBufferSourceNode::create(AudioContext* co
|
| AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* context, float sampleRate)
|
| : AudioScheduledSourceNode(context, sampleRate)
|
| , m_buffer(nullptr)
|
| + , m_nullableBuffer(nullptr)
|
| , m_isLooping(false)
|
| , m_loopStart(0)
|
| , m_loopEnd(0)
|
| @@ -156,7 +157,10 @@ bool AudioBufferSourceNode::renderSilenceAndFinishIfNotLooping(AudioBus*, unsign
|
| memset(m_destinationChannels[i] + index, 0, sizeof(float) * framesToProcess);
|
| }
|
|
|
| - finish();
|
| + // If buffer was set to null, it sould keep to render slience to ready rendering with proper buffer with setBuffer().
|
| + if (m_buffer != m_nullableBuffer)
|
| + finish();
|
| +
|
| return true;
|
| }
|
| return false;
|
| @@ -334,11 +338,19 @@ bool AudioBufferSourceNode::renderFromBuffer(AudioBus* bus, unsigned destination
|
| void AudioBufferSourceNode::setBuffer(AudioBuffer* buffer, ExceptionState& exceptionState)
|
| {
|
| 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 a buffer is null, it is one channel of silence according to specification.
|
| if (!buffer) {
|
| - exceptionState.throwTypeError("buffer cannot be null");
|
| - return;
|
| + // Set mono channel, default frame = 512 and destination's sampleRate.
|
| + if (!m_nullableBuffer)
|
| + m_nullableBuffer = context()->createBuffer(1, 512, context()->sampleRate(), exceptionState);
|
| +
|
| + if (!m_nullableBuffer) {
|
| + exceptionState.throwTypeError("failed creation of nullable buffer");
|
| + return;
|
| + }
|
| +
|
| + buffer = m_nullableBuffer.get();
|
| }
|
|
|
| // The context must be locked since changing the buffer can re-configure the number of channels that are output.
|
|
|