Index: Source/modules/webaudio/PannerNode.cpp |
diff --git a/Source/modules/webaudio/PannerNode.cpp b/Source/modules/webaudio/PannerNode.cpp |
index 80e5099488100a0b98b6fe253d10b98f0d5688eb..d4bd5a1b0da42c9d1764ca2dad66ab3d6b67b303 100644 |
--- a/Source/modules/webaudio/PannerNode.cpp |
+++ b/Source/modules/webaudio/PannerNode.cpp |
@@ -52,6 +52,9 @@ PannerNode::PannerNode(AudioContext* context, float sampleRate) |
, m_lastGain(-1.0) |
, m_connectionCount(0) |
{ |
+ // HRTFDatabaseLoader should be created and load database for pannerNode asynchronously. |
+ m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(context->sampleRate()); |
+ |
ScriptWrappable::init(this); |
addInput(adoptPtr(new AudioNodeInput(this))); |
addOutput(adoptPtr(new AudioNodeOutput(this, 2))); |
@@ -106,12 +109,21 @@ void PannerNode::process(size_t framesToProcess) |
} |
AudioBus* source = input(0)->bus(); |
- |
if (!source) { |
destination->zero(); |
return; |
} |
+ // HRTFDatabaseLoader and HRTFDatabase should be loaded before proceed. |
Raymond Toy (Google)
2014/02/24 23:01:22
Comment seems incorrect. Change "before proceed"
KhNo
2014/02/25 02:00:25
Yes. It seems to be not correct comment. I will fi
|
+ if (!m_hrtfDatabaseLoader->isLoaded()) { |
+ if (context()->isOfflineContext()) { |
+ m_hrtfDatabaseLoader->waitForLoaderThreadCompletion(); |
+ } else { |
+ destination->zero(); |
+ return; |
+ } |
+ } |
+ |
// The audio thread can't block on this lock, so we call tryLock() instead. |
MutexTryLocker tryLocker(m_pannerLock); |
if (tryLocker.locked()) { |
@@ -141,7 +153,7 @@ void PannerNode::initialize() |
if (isInitialized()) |
return; |
- m_panner = Panner::create(m_panningModel, sampleRate(), context()->hrtfDatabaseLoader()); |
+ m_panner = Panner::create(m_panningModel, sampleRate(), m_hrtfDatabaseLoader.get()); |
AudioNode::initialize(); |
} |
@@ -196,7 +208,7 @@ bool PannerNode::setPanningModel(unsigned model) |
// This synchronizes with process(). |
MutexLocker processLocker(m_pannerLock); |
- OwnPtr<Panner> newPanner = Panner::create(model, sampleRate(), context()->hrtfDatabaseLoader()); |
+ OwnPtr<Panner> newPanner = Panner::create(model, sampleRate(), m_hrtfDatabaseLoader.get()); |
m_panner = newPanner.release(); |
m_panningModel = model; |
} |