| Index: third_party/WebKit/Source/modules/webaudio/AudioListener.h
|
| diff --git a/third_party/WebKit/Source/modules/webaudio/AudioListener.h b/third_party/WebKit/Source/modules/webaudio/AudioListener.h
|
| index 3173d657e1428554f49e5b1e7fad8931a6b13124..d41a614effea6d942aad989d83c2c411083d9495 100644
|
| --- a/third_party/WebKit/Source/modules/webaudio/AudioListener.h
|
| +++ b/third_party/WebKit/Source/modules/webaudio/AudioListener.h
|
| @@ -30,6 +30,7 @@
|
| #define AudioListener_h
|
|
|
| #include "bindings/core/v8/ScriptWrappable.h"
|
| +#include "modules/webaudio/AudioParam.h"
|
| #include "platform/geometry/FloatPoint3D.h"
|
| #include "platform/heap/Handle.h"
|
| #include "wtf/Vector.h"
|
| @@ -44,15 +45,70 @@ class PannerHandler;
|
| class AudioListener : public GarbageCollectedFinalized<AudioListener>, public ScriptWrappable {
|
| DEFINE_WRAPPERTYPEINFO();
|
| public:
|
| - static AudioListener* create()
|
| + static AudioListener* create(AbstractAudioContext& context)
|
| {
|
| - return new AudioListener();
|
| + return new AudioListener(context);
|
| }
|
| virtual ~AudioListener();
|
|
|
| + // Location of the listener
|
| + AudioParam* positionX() const { return m_positionX; };
|
| + AudioParam* positionY() const { return m_positionY; };
|
| + AudioParam* positionZ() const { return m_positionZ; };
|
| +
|
| + // Forward direction vector of the listener
|
| + AudioParam* forwardX() const { return m_forwardX; };
|
| + AudioParam* forwardY() const { return m_forwardY; };
|
| + AudioParam* forwardZ() const { return m_forwardZ; };
|
| +
|
| + // Up direction vector for the listener
|
| + AudioParam* upX() const { return m_upX; };
|
| + AudioParam* upY() const { return m_upY; };
|
| + AudioParam* upZ() const { return m_upZ; };
|
| +
|
| + // True if any of AudioParams have automations.
|
| + bool hasSampleAccurateValues() const;
|
| +
|
| + // Update the internal state of the listener, including updating the dirty state of all
|
| + // PannerNodes if necessary.
|
| + void updateState();
|
| +
|
| + const FloatPoint3D position() const
|
| + {
|
| + return FloatPoint3D(
|
| + m_positionX->value(),
|
| + m_positionY->value(),
|
| + m_positionZ->value());
|
| + }
|
| + const FloatPoint3D orientation() const
|
| + {
|
| + return FloatPoint3D(
|
| + m_forwardX->value(),
|
| + m_forwardY->value(),
|
| + m_forwardZ->value());
|
| + }
|
| + const FloatPoint3D upVector() const
|
| + {
|
| + return FloatPoint3D(
|
| + m_upX->value(),
|
| + m_upY->value(),
|
| + m_upZ->value());
|
| + }
|
| +
|
| + const float* getPositionXValues(size_t framesToProcess);
|
| + const float* getPositionYValues(size_t framesToProcess);
|
| + const float* getPositionZValues(size_t framesToProcess);
|
| +
|
| + const float* getForwardXValues(size_t framesToProcess);
|
| + const float* getForwardYValues(size_t framesToProcess);
|
| + const float* getForwardZValues(size_t framesToProcess);
|
| +
|
| + const float* getUpXValues(size_t framesToProcess);
|
| + const float* getUpYValues(size_t framesToProcess);
|
| + const float* getUpZValues(size_t framesToProcess);
|
| +
|
| // Position
|
| void setPosition(float x, float y, float z) { setPosition(FloatPoint3D(x, y, z)); }
|
| - const FloatPoint3D& position() const { return m_position; }
|
|
|
| // Orientation and Up-vector
|
| void setOrientation(float x, float y, float z, float upX, float upY, float upZ)
|
| @@ -60,8 +116,6 @@ public:
|
| setOrientation(FloatPoint3D(x, y, z));
|
| setUpVector(FloatPoint3D(upX, upY, upZ));
|
| }
|
| - const FloatPoint3D& orientation() const { return m_orientation; }
|
| - const FloatPoint3D& upVector() const { return m_upVector; }
|
|
|
| // Velocity
|
| void setVelocity(float x, float y, float z);
|
| @@ -87,7 +141,7 @@ public:
|
| DECLARE_TRACE();
|
|
|
| private:
|
| - AudioListener();
|
| + AudioListener(AbstractAudioContext&);
|
|
|
| void setPosition(const FloatPoint3D&);
|
| void setOrientation(const FloatPoint3D&);
|
| @@ -95,12 +149,46 @@ private:
|
|
|
| void markPannersAsDirty(unsigned);
|
|
|
| - FloatPoint3D m_position;
|
| - FloatPoint3D m_orientation;
|
| - FloatPoint3D m_upVector;
|
| + // Location of the listener
|
| + Member<AudioParam> m_positionX;
|
| + Member<AudioParam> m_positionY;
|
| + Member<AudioParam> m_positionZ;
|
| +
|
| + // Forward direction vector of the listener
|
| + Member<AudioParam> m_forwardX;
|
| + Member<AudioParam> m_forwardY;
|
| + Member<AudioParam> m_forwardZ;
|
| +
|
| + // Up direction vector for the listener
|
| + Member<AudioParam> m_upX;
|
| + Member<AudioParam> m_upY;
|
| + Member<AudioParam> m_upZ;
|
| +
|
| double m_dopplerFactor;
|
| double m_speedOfSound;
|
|
|
| + // The position, forward, and up vectors from the last rendering quantum.
|
| + FloatPoint3D m_lastPosition;
|
| + FloatPoint3D m_lastForward;
|
| + FloatPoint3D m_lastUp;
|
| +
|
| + // Last time that the automations were updated.
|
| + double m_lastUpdateTime;
|
| +
|
| + void updateValuesIfNeeded(size_t framesToProcess);
|
| +
|
| + AudioFloatArray m_positionXValues;
|
| + AudioFloatArray m_positionYValues;
|
| + AudioFloatArray m_positionZValues;
|
| +
|
| + AudioFloatArray m_forwardXValues;
|
| + AudioFloatArray m_forwardYValues;
|
| + AudioFloatArray m_forwardZValues;
|
| +
|
| + AudioFloatArray m_upXValues;
|
| + AudioFloatArray m_upYValues;
|
| + AudioFloatArray m_upZValues;
|
| +
|
| // Synchronize a panner's process() with setting of the state of the listener.
|
| mutable Mutex m_listenerLock;
|
| // List for pannerNodes in context. This is updated only in the main thread,
|
|
|