Chromium Code Reviews| Index: Source/modules/webaudio/AudioListener.cpp |
| diff --git a/Source/modules/webaudio/AudioListener.cpp b/Source/modules/webaudio/AudioListener.cpp |
| index e13794597bb1b41b6a0220899bc5ebee84b12aca..440ef0953ee30dd20f3c06ee51be215f27875d5e 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" |
|
Raymond Toy
2014/04/16 17:36:15
Is this necessary?
KhNo
2014/04/17 13:41:03
Yes, it is for m_panners[i]->updatePannerDirty(typ
|
| #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::updatePannersDirty(unsigned type) |
|
Raymond Toy
2014/04/16 17:36:15
I think updateDirtyPanners is a better name.
KhNo
2014/04/17 13:41:03
Changed to markPannersAsDirty
|
| +{ |
| + for (unsigned i = 0; i < m_panners.size(); ++i) |
| + m_panners[i]->updatePannerDirty(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; |
| + updatePannersDirty(PannerNode::AzimuthElevationDirty | PannerNode::DistanceConeGainDirty | PannerNode::DopplerRateDirty); |
|
Raymond Toy
2014/04/16 17:36:15
udpatePannersDirty is protected by m_processLock (
KhNo
2014/04/17 13:41:03
Actually, I have tried to using pannerNode's proce
|
| +} |
| + |
| +void AudioListener::setOrientation(const FloatPoint3D &orientation) |
| +{ |
| + if (m_orientation == orientation) |
| + return; |
| + |
| + // This synchronizes with panner's process(). |
| + MutexLocker listenerLocker(m_listenerLock); |
| + m_orientation = orientation; |
| + updatePannersDirty(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; |
| + updatePannersDirty(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; |
| + updatePannersDirty(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; |
| + updatePannersDirty(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; |
| + updatePannersDirty(PannerNode::DopplerRateDirty); |
| +} |
| + |
| } // namespace WebCore |
| #endif // ENABLE(WEB_AUDIO) |