Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: Source/modules/webaudio/PannerNode.cpp

Issue 176683003: HRTFDatabaseLoader is not an absolute condition to run audioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webaudio/PannerNode.h ('k') | Source/modules/webaudio/RealtimeAnalyser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/PannerNode.cpp
diff --git a/Source/modules/webaudio/PannerNode.cpp b/Source/modules/webaudio/PannerNode.cpp
index 80e5099488100a0b98b6fe253d10b98f0d5688eb..5a89003317f8ea24c92c731a817fd2a1eb51c07b 100644
--- a/Source/modules/webaudio/PannerNode.cpp
+++ b/Source/modules/webaudio/PannerNode.cpp
@@ -52,6 +52,10 @@ PannerNode::PannerNode(AudioContext* context, float sampleRate)
, m_lastGain(-1.0)
, m_connectionCount(0)
{
+ // Load the HRTF database asynchronously so we don't block the Javascript thread while creating the HRTF database.
+ // The HRTF panner will return zeroes until the database is loaded.
+ m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(context->sampleRate());
+
ScriptWrappable::init(this);
addInput(adoptPtr(new AudioNodeInput(this)));
addOutput(adoptPtr(new AudioNodeOutput(this, 2)));
@@ -106,12 +110,21 @@ void PannerNode::process(size_t framesToProcess)
}
AudioBus* source = input(0)->bus();
-
if (!source) {
destination->zero();
return;
}
+ // HRTFDatabase should be loaded before proceeding for offline audio context when panningModel() is "HRTF".
+ if (panningModel() == "HRTF" && !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 +154,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 +209,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;
}
« no previous file with comments | « Source/modules/webaudio/PannerNode.h ('k') | Source/modules/webaudio/RealtimeAnalyser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698