Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / webaudio / AudioListener.h
index dcd68dd..214db39 100644 (file)
 
 #include "bindings/v8/ScriptWrappable.h"
 #include "platform/geometry/FloatPoint3D.h"
+#include "platform/heap/Handle.h"
 #include "wtf/PassRefPtr.h"
 #include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
+class PannerNode;
+
 // AudioListener maintains the state of the listener in the audio scene as defined in the OpenAL specification.
 
-class AudioListener : public ScriptWrappable, public RefCounted<AudioListener> {
+class AudioListener : public RefCountedWillBeGarbageCollectedFinalized<AudioListener>, public ScriptWrappable {
 public:
-    static PassRefPtr<AudioListener> create()
+    static PassRefPtrWillBeRawPtr<AudioListener> create()
     {
-        return adoptRef(new AudioListener());
+        return adoptRefWillBeNoop(new AudioListener());
     }
+    virtual ~AudioListener();
 
     // Position
     void setPosition(float x, float y, float z) { setPosition(FloatPoint3D(x, y, z)); }
-    void setPosition(const FloatPoint3D &position) { m_position = position; }
     const FloatPoint3D& position() const { return m_position; }
 
-    // Orientation
+    // Orientation and Up-vector
     void setOrientation(float x, float y, float z, float upX, float upY, float upZ)
     {
         setOrientation(FloatPoint3D(x, y, z));
         setUpVector(FloatPoint3D(upX, upY, upZ));
     }
-    void setOrientation(const FloatPoint3D &orientation) { m_orientation = orientation; }
     const FloatPoint3D& orientation() const { return m_orientation; }
-
-    // Up-vector
-    void setUpVector(const FloatPoint3D &upVector) { m_upVector = upVector; }
     const FloatPoint3D& upVector() const { return m_upVector; }
 
     // Velocity
     void setVelocity(float x, float y, float z) { setVelocity(FloatPoint3D(x, y, z)); }
-    void setVelocity(const FloatPoint3D &velocity) { m_velocity = velocity; }
     const FloatPoint3D& velocity() const { return m_velocity; }
 
     // Doppler factor
-    void setDopplerFactor(double dopplerFactor) { m_dopplerFactor = dopplerFactor; }
+    void setDopplerFactor(double);
     double dopplerFactor() const { return m_dopplerFactor; }
 
     // Speed of sound
-    void setSpeedOfSound(double speedOfSound) { m_speedOfSound = speedOfSound; }
+    void setSpeedOfSound(double);
     double speedOfSound() const { return m_speedOfSound; }
 
+    Mutex& listenerLock() { return m_listenerLock; }
+    void addPanner(PannerNode*);
+    void removePanner(PannerNode*);
+
+    void trace(Visitor*) { }
+
 private:
     AudioListener();
 
-    // Position / Orientation
+    void setPosition(const FloatPoint3D&);
+    void setOrientation(const FloatPoint3D&);
+    void setUpVector(const FloatPoint3D&);
+    void setVelocity(const FloatPoint3D&);
+
+    void markPannersAsDirty(unsigned);
+
     FloatPoint3D m_position;
     FloatPoint3D m_orientation;
     FloatPoint3D m_upVector;
-
     FloatPoint3D m_velocity;
-
     double m_dopplerFactor;
     double m_speedOfSound;
+
+    // Synchronize a panner's process() with setting of the state of the listener.
+    mutable Mutex m_listenerLock;
+
+    // List for pannerNodes in context.
+    Vector<PannerNode*> m_panners;
 };
 
 } // WebCore