summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp')
-rw-r--r--Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp38
1 files changed, 13 insertions, 25 deletions
diff --git a/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp b/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp
index fd3123a91..505230419 100644
--- a/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp
+++ b/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp
@@ -38,7 +38,7 @@ namespace WebCore {
const size_t renderQuantumSize = 128;
-OfflineAudioDestinationNode::OfflineAudioDestinationNode(AudioContext* context, AudioBuffer* renderTarget)
+OfflineAudioDestinationNode::OfflineAudioDestinationNode(AudioContext& context, AudioBuffer* renderTarget)
: AudioDestinationNode(context, renderTarget->sampleRate())
, m_renderTarget(renderTarget)
, m_renderThread(0)
@@ -101,7 +101,12 @@ void OfflineAudioDestinationNode::offlineRender()
ASSERT(m_renderBus.get());
if (!m_renderBus.get())
return;
-
+
+ bool isAudioContextInitialized = context().isInitialized();
+ ASSERT(isAudioContextInitialized);
+ if (!isAudioContextInitialized)
+ return;
+
bool channelsMatch = m_renderBus->numberOfChannels() == m_renderTarget->numberOfChannels();
ASSERT(channelsMatch);
if (!channelsMatch)
@@ -112,15 +117,6 @@ void OfflineAudioDestinationNode::offlineRender()
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();
@@ -135,7 +131,7 @@ void OfflineAudioDestinationNode::offlineRender()
for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) {
const float* source = m_renderBus->channel(channelIndex)->data();
- float* destination = m_renderTarget->getChannelData(channelIndex)->data();
+ float* destination = m_renderTarget->channelData(channelIndex)->data();
memcpy(destination + n, source, sizeof(float) * framesAvailableToCopy);
}
@@ -144,23 +140,15 @@ void OfflineAudioDestinationNode::offlineRender()
}
// Our work is done. Let the AudioContext know.
- callOnMainThread(notifyCompleteDispatch, this);
-}
-
-void OfflineAudioDestinationNode::notifyCompleteDispatch(void* userData)
-{
- OfflineAudioDestinationNode* destinationNode = static_cast<OfflineAudioDestinationNode*>(userData);
- ASSERT(destinationNode);
- if (!destinationNode)
- return;
-
- destinationNode->notifyComplete();
- destinationNode->deref();
+ callOnMainThread([this] {
+ notifyComplete();
+ deref();
+ });
}
void OfflineAudioDestinationNode::notifyComplete()
{
- context()->fireCompletionEvent();
+ context().fireCompletionEvent();
}
} // namespace WebCore