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

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

Issue 232453003: Add logic to cache elements of panner node from calculation with own attributes and AudioListener (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Unrelated fix has been separated. Created 6 years, 8 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/AudioListener.h ('k') | Source/modules/webaudio/PannerNode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioListener.cpp
diff --git a/Source/modules/webaudio/AudioListener.cpp b/Source/modules/webaudio/AudioListener.cpp
index e13794597bb1b41b6a0220899bc5ebee84b12aca..94466c9a19f43f53fb90ce37373392f2ece23a7e 100644
--- a/Source/modules/webaudio/AudioListener.cpp
+++ b/Source/modules/webaudio/AudioListener.cpp
@@ -32,6 +32,7 @@
#include "modules/webaudio/AudioListener.h"
+#include "modules/webaudio/PannerNode.h"
#include "platform/audio/AudioBus.h"
namespace WebCore {
@@ -47,6 +48,101 @@ AudioListener::AudioListener()
ScriptWrappable::init(this);
}
+AudioListener::~AudioListener()
+{
+ m_panners.clear();
+}
+
+void AudioListener::addPanner(PannerNode* panner)
+{
+ if (!panner)
+ return;
+
+ m_panners.append(panner);
+}
+
+void AudioListener::removePanner(PannerNode* panner)
+{
+ for (unsigned i = 0; i < m_panners.size(); ++i) {
+ if (panner == m_panners[i]) {
+ m_panners.remove(i);
+ break;
+ }
+ }
+}
+
+void AudioListener::markPannersAsDirty(unsigned type)
+{
+ for (unsigned i = 0; i < m_panners.size(); ++i)
+ m_panners[i]->markPannerAsDirty(type);
+}
+
+void AudioListener::setPosition(const FloatPoint3D &position)
+{
+ if (m_position == position)
+ return;
+
+ // This synchronizes with panner's process().
+ MutexLocker listenerLocker(m_listenerLock);
+ m_position = position;
+ markPannersAsDirty(PannerNode::AzimuthElevationDirty | PannerNode::DistanceConeGainDirty | PannerNode::DopplerRateDirty);
+}
+
+void AudioListener::setOrientation(const FloatPoint3D &orientation)
+{
+ if (m_orientation == orientation)
+ return;
+
+ // This synchronizes with panner's process().
+ MutexLocker listenerLocker(m_listenerLock);
+ m_orientation = orientation;
+ markPannersAsDirty(PannerNode::AzimuthElevationDirty);
+}
+
+void AudioListener::setUpVector(const FloatPoint3D &upVector)
+{
+ if (m_upVector == upVector)
+ return;
+
+ // This synchronizes with panner's process().
+ MutexLocker listenerLocker(m_listenerLock);
+ m_upVector = upVector;
+ markPannersAsDirty(PannerNode::AzimuthElevationDirty);
+}
+
+void AudioListener::setVelocity(const FloatPoint3D &velocity)
+{
+ if (m_velocity == velocity)
+ return;
+
+ // This synchronizes with panner's process().
+ MutexLocker listenerLocker(m_listenerLock);
+ m_velocity = velocity;
+ markPannersAsDirty(PannerNode::DopplerRateDirty);
+}
+
+void AudioListener::setDopplerFactor(double dopplerFactor)
+{
+ if (m_dopplerFactor == dopplerFactor)
+ return;
+
+ // This synchronizes with panner's process().
+ MutexLocker listenerLocker(m_listenerLock);
+ m_dopplerFactor = dopplerFactor;
+ markPannersAsDirty(PannerNode::DopplerRateDirty);
+}
+
+void AudioListener::setSpeedOfSound(double speedOfSound)
+{
+ if (m_speedOfSound == speedOfSound)
+ return;
+
+ // This synchronizes with panner's process().
+ MutexLocker listenerLocker(m_listenerLock);
+ m_speedOfSound = speedOfSound;
+ markPannersAsDirty(PannerNode::DopplerRateDirty);
+}
+
} // namespace WebCore
#endif // ENABLE(WEB_AUDIO)
« no previous file with comments | « Source/modules/webaudio/AudioListener.h ('k') | Source/modules/webaudio/PannerNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698