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

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

Issue 2171703003: Load HRTF database only when the panner is set to HRTF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify Created 4 years, 5 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 | « third_party/WebKit/Source/modules/webaudio/AudioListener.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/PannerNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/PannerNode.cpp b/third_party/WebKit/Source/modules/webaudio/PannerNode.cpp
index 939c9a7d80dc99b002963efc786e10ff67cb9fbe..0bccc844e4f6a857d3d52b58b1b3801c4318df04 100644
--- a/third_party/WebKit/Source/modules/webaudio/PannerNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/PannerNode.cpp
@@ -67,10 +67,6 @@ PannerHandler::PannerHandler(
, m_orientationY(orientationY)
, m_orientationZ(orientationZ)
{
- // 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.
- listener()->createAndLoadHRTFDatabaseLoader(node.context()->sampleRate());
-
addInput();
addOutput(2);
@@ -282,33 +278,37 @@ String PannerHandler::panningModel() const
void PannerHandler::setPanningModel(const String& model)
{
+ // WebIDL should guarantee that we are never called with an invalid string
+ // for the model.
if (model == "equalpower")
setPanningModel(Panner::PanningModelEqualPower);
else if (model == "HRTF")
setPanningModel(Panner::PanningModelHRTF);
+ else
+ NOTREACHED();
}
+// This method should only be called from setPanningModel(const String&)!
bool PannerHandler::setPanningModel(unsigned model)
{
DEFINE_STATIC_LOCAL(EnumerationHistogram, panningModelHistogram,
("WebAudio.PannerNode.PanningModel", 2));
panningModelHistogram.count(model);
- switch (model) {
- case Panner::PanningModelEqualPower:
- case Panner::PanningModelHRTF:
- if (!m_panner.get() || model != m_panningModel) {
- // This synchronizes with process().
- MutexLocker processLocker(m_processLock);
- m_panner = Panner::create(model, sampleRate(), listener()->hrtfDatabaseLoader());
- m_panningModel = model;
- }
- break;
- default:
- ASSERT_NOT_REACHED();
- return false;
+ if (model == Panner::PanningModelHRTF) {
+ // Load the HRTF database asynchronously so we don't block the
+ // Javascript thread while creating the HRTF database. It's ok to call
+ // this multiple times; we won't be constantly loading the database over
+ // and over.
+ listener()->createAndLoadHRTFDatabaseLoader(context()->sampleRate());
}
+ if (!m_panner.get() || model != m_panningModel) {
+ // This synchronizes with process().
+ MutexLocker processLocker(m_processLock);
+ m_panner = Panner::create(model, sampleRate(), listener()->hrtfDatabaseLoader());
+ m_panningModel = model;
+ }
return true;
}
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioListener.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698