| Index: Source/modules/webaudio/OfflineAudioDestinationNode.cpp
|
| diff --git a/Source/modules/webaudio/OfflineAudioDestinationNode.cpp b/Source/modules/webaudio/OfflineAudioDestinationNode.cpp
|
| index 4cc77ffed90b6107229f11a81e7f675b1fc1eaec..f5b574596fc6cbce78180a3f7090c7eb4a694e20 100644
|
| --- a/Source/modules/webaudio/OfflineAudioDestinationNode.cpp
|
| +++ b/Source/modules/webaudio/OfflineAudioDestinationNode.cpp
|
| @@ -35,10 +35,10 @@
|
| #include "wtf/MainThread.h"
|
|
|
| using namespace std;
|
| -
|
| +
|
| namespace WebCore {
|
| -
|
| -const size_t renderQuantumSize = 128;
|
| +
|
| +const size_t renderQuantumSize = 128;
|
|
|
| OfflineAudioDestinationNode::OfflineAudioDestinationNode(AudioContext* context, AudioBuffer* renderTarget)
|
| : AudioDestinationNode(context, renderTarget->sampleRate())
|
| @@ -81,7 +81,7 @@ void OfflineAudioDestinationNode::startRendering()
|
| ASSERT(m_renderTarget.get());
|
| if (!m_renderTarget.get())
|
| return;
|
| -
|
| +
|
| if (!m_startedRendering) {
|
| m_startedRendering = true;
|
| ref(); // See corresponding deref() call in notifyCompleteDispatch().
|
| @@ -103,26 +103,26 @@ void OfflineAudioDestinationNode::offlineRender()
|
| ASSERT(m_renderBus.get());
|
| if (!m_renderBus.get())
|
| return;
|
| -
|
| +
|
| bool channelsMatch = m_renderBus->numberOfChannels() == m_renderTarget->numberOfChannels();
|
| ASSERT(channelsMatch);
|
| if (!channelsMatch)
|
| return;
|
| -
|
| +
|
| bool isRenderBusAllocated = m_renderBus->length() >= renderQuantumSize;
|
| ASSERT(isRenderBusAllocated);
|
| if (!isRenderBusAllocated)
|
| return;
|
| -
|
| +
|
| // Synchronize with HRTFDatabaseLoader.
|
| // The database must be loaded before we can proceed.
|
| HRTFDatabaseLoader* loader = context()->hrtfDatabaseLoader();
|
| ASSERT(loader);
|
| if (!loader)
|
| return;
|
| -
|
| +
|
| loader->waitForLoaderThreadCompletion();
|
| -
|
| +
|
| // Break up the render target into smaller "render quantize" sized pieces.
|
| // Render until we're finished.
|
| size_t framesToProcess = m_renderTarget->length();
|
| @@ -132,19 +132,19 @@ void OfflineAudioDestinationNode::offlineRender()
|
| while (framesToProcess > 0) {
|
| // Render one render quantum.
|
| render(0, m_renderBus.get(), renderQuantumSize);
|
| -
|
| +
|
| size_t framesAvailableToCopy = min(framesToProcess, renderQuantumSize);
|
| -
|
| +
|
| for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) {
|
| const float* source = m_renderBus->channel(channelIndex)->data();
|
| float* destination = m_renderTarget->getChannelData(channelIndex)->data();
|
| memcpy(destination + n, source, sizeof(float) * framesAvailableToCopy);
|
| }
|
| -
|
| +
|
| n += framesAvailableToCopy;
|
| framesToProcess -= framesAvailableToCopy;
|
| }
|
| -
|
| +
|
| // Our work is done. Let the AudioContext know.
|
| callOnMainThread(notifyCompleteDispatch, this);
|
| }
|
|
|