Chromium Code Reviews| Index: Source/modules/webaudio/PannerNode.h |
| diff --git a/Source/modules/webaudio/PannerNode.h b/Source/modules/webaudio/PannerNode.h |
| index f1981df10f0ebeff06acececf5e3765b3bc8cd40..00173186267b3d2939d553953c97d5b2ecbce02f 100644 |
| --- a/Source/modules/webaudio/PannerNode.h |
| +++ b/Source/modules/webaudio/PannerNode.h |
| @@ -25,13 +25,14 @@ |
| #ifndef PannerNode_h |
| #define PannerNode_h |
| +#include "modules/webaudio/AudioContext.h" |
|
KhNo
2014/04/14 11:23:30
webkit style checker error.
|
| +#include "modules/webaudio/AudioListener.h" |
| +#include "modules/webaudio/AudioNode.h" |
| #include "platform/audio/AudioBus.h" |
| #include "platform/audio/Cone.h" |
| #include "platform/audio/Distance.h" |
| #include "platform/audio/HRTFDatabaseLoader.h" |
| #include "platform/audio/Panner.h" |
| -#include "modules/webaudio/AudioListener.h" |
| -#include "modules/webaudio/AudioNode.h" |
| #include "platform/geometry/FloatPoint3D.h" |
| #include "wtf/HashMap.h" |
| #include "wtf/OwnPtr.h" |
| @@ -49,16 +50,22 @@ class PannerNode FINAL : public AudioNode { |
| public: |
| // These must be defined as in the .idl file and must match those in the Panner class. |
| enum { |
| - EQUALPOWER = 0, |
| + EqualPower = 0, |
|
KhNo
2014/04/14 11:23:30
webkit style checker error.
|
| HRTF = 1, |
| }; |
| // These must be defined as in the .idl file and must match those |
| // in the DistanceEffect class. |
| enum { |
| - LINEAR_DISTANCE = 0, |
| - INVERSE_DISTANCE = 1, |
| - EXPONENTIAL_DISTANCE = 2, |
| + LinearDistance = 0, |
|
KhNo
2014/04/14 11:23:30
webkit style checker error.
|
| + InverseDistance = 1, |
| + ExponentialDistance = 2, |
| + }; |
| + |
| + enum { |
| + AzimuthElevationDirty = 0x00000001, |
| + DistanceConeGainDirty = 0x00000002, |
| + DopplerRateDirty = 0x00000004, |
| }; |
| static PassRefPtr<PannerNode> create(AudioContext* context, float sampleRate) |
| @@ -74,20 +81,13 @@ public: |
| virtual void initialize() OVERRIDE; |
| virtual void uninitialize() OVERRIDE; |
| - // AudioContext's listener |
|
KhNo
2014/04/14 11:23:30
moved to private
|
| - AudioListener* listener(); |
| - |
| // Panning model |
| String panningModel() const; |
| void setPanningModel(const String&); |
| - // Position |
| + // Position, orientation and velocity |
| void setPosition(float x, float y, float z); |
| - |
| - // Orientation |
| void setOrientation(float x, float y, float z); |
| - |
| - // Velocity |
| void setVelocity(float x, float y, float z); |
| // Distance parameters |
| @@ -95,23 +95,25 @@ public: |
| void setDistanceModel(const String&); |
| double refDistance() { return m_distanceEffect.refDistance(); } |
| - void setRefDistance(double refDistance) { m_distanceEffect.setRefDistance(refDistance); } |
| + void setRefDistance(double); |
| double maxDistance() { return m_distanceEffect.maxDistance(); } |
| - void setMaxDistance(double maxDistance) { m_distanceEffect.setMaxDistance(maxDistance); } |
| + void setMaxDistance(double); |
| double rolloffFactor() { return m_distanceEffect.rolloffFactor(); } |
| - void setRolloffFactor(double rolloffFactor) { m_distanceEffect.setRolloffFactor(rolloffFactor); } |
| + void setRolloffFactor(double); |
| // Sound cones - angles in degrees |
| double coneInnerAngle() const { return m_coneEffect.innerAngle(); } |
| - void setConeInnerAngle(double angle) { m_coneEffect.setInnerAngle(angle); } |
| + void setConeInnerAngle(double); |
| double coneOuterAngle() const { return m_coneEffect.outerAngle(); } |
| - void setConeOuterAngle(double angle) { m_coneEffect.setOuterAngle(angle); } |
| + void setConeOuterAngle(double); |
| double coneOuterGain() const { return m_coneEffect.outerGain(); } |
| - void setConeOuterGain(double angle) { m_coneEffect.setOuterGain(angle); } |
| + void setConeOuterGain(double); |
| + |
| + void updatePannerDirty(unsigned); |
| // It must be called on audio thread, currently called only process() in AudioBufferSourceNode. |
| double dopplerRate(); |
| @@ -122,27 +124,27 @@ public: |
| private: |
| PannerNode(AudioContext*, float sampleRate); |
| + // AudioContext's listener |
| + AudioListener* listener() { return context()->listener(); } |
| + |
| bool setPanningModel(unsigned); // Returns true on success. |
| bool setDistanceModel(unsigned); // Returns true on success. |
| + |
|
KhNo
2014/04/14 11:23:30
It seems to be needed one blank.
|
| void calculateAzimuthElevation(double* outAzimuth, double* outElevation); |
| - // Returns the combined distance and cone gain attenuation. |
| - float calculateDistanceConeGain(); |
| + float calculateDistanceConeGain(); // Returns the combined distance and cone gain attenuation. |
| double calculateDopplerRate(); |
| void azimuthElevation(double* outAzimuth, double* outElevation); |
| float distanceConeGain(); |
| - bool isAzimuthElevationDirty(); |
| - bool isDistanceConeGainDirty(); |
| - bool isDopplerRateDirty(); |
| + bool isAzimuthElevationDirty() const { return m_isAzimuthElevationDirty; } |
| + bool isDistanceConeGainDirty() const { return m_isDistanceConeGainDirty; } |
| + bool isDopplerRateDirty() const { return m_isDopplerRateDirty; } |
| // Notifies any AudioBufferSourceNodes connected to us either directly or indirectly about our existence. |
| // This is in order to handle the pitch change necessary for the doppler shift. |
| void notifyAudioSourcesConnectedToNode(AudioNode*, HashMap<AudioNode*, bool> &visitedNodes); |
| - void updateCachedListener(); |
| - void updateCachedSourceLocationInfo(); |
| - |
| OwnPtr<Panner> m_panner; |
| unsigned m_panningModel; |
| unsigned m_distanceModel; |
| @@ -152,10 +154,9 @@ private: |
| FloatPoint3D m_orientation; |
| FloatPoint3D m_velocity; |
| - // Cached source location information |
| - FloatPoint3D m_cachedPosition; |
|
KhNo
2014/04/14 11:23:30
All cached attributes are removed. That will be ch
|
| - FloatPoint3D m_cachedOrientation; |
| - FloatPoint3D m_cachedVelocity; |
| + bool m_isAzimuthElevationDirty; |
| + bool m_isDistanceConeGainDirty; |
| + bool m_isDopplerRateDirty; |
| // Gain |
| DistanceEffect m_distanceEffect; |
| @@ -167,15 +168,12 @@ private: |
| float m_cachedDistanceConeGain; |
| double m_cachedDopplerRate; |
| - // Cached listener parameters after processing. |
| - RefPtr<AudioListener> m_cachedListener; |
|
KhNo
2014/04/14 11:23:30
AudioListener is checking dirty itself. no require
|
| - |
| RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader; |
| // AudioContext's connection count |
| unsigned m_connectionCount; |
| - // Synchronize process() with setting of the panning model, distance model and caching of the source location/orientation info. |
| + // Synchronize process() with setting of the panning model, source's location information, listener, distance parameters and sound cones. |
| mutable Mutex m_processLock; |
| }; |