summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/webaudio/PannerNode.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/Modules/webaudio/PannerNode.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/Modules/webaudio/PannerNode.h')
-rw-r--r--Source/WebCore/Modules/webaudio/PannerNode.h65
1 files changed, 27 insertions, 38 deletions
diff --git a/Source/WebCore/Modules/webaudio/PannerNode.h b/Source/WebCore/Modules/webaudio/PannerNode.h
index 190eb79d5..d5f6d2862 100644
--- a/Source/WebCore/Modules/webaudio/PannerNode.h
+++ b/Source/WebCore/Modules/webaudio/PannerNode.h
@@ -22,8 +22,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PannerNode_h
-#define PannerNode_h
+#pragma once
+
+#if ENABLE(WEB_AUDIO)
#include "AudioBus.h"
#include "AudioListener.h"
@@ -32,9 +33,11 @@
#include "Cone.h"
#include "Distance.h"
#include "FloatPoint3D.h"
+#include "HRTFDatabaseLoader.h"
#include "Panner.h"
#include <memory>
-#include <mutex>
+#include <wtf/HashSet.h>
+#include <wtf/Lock.h>
namespace WebCore {
@@ -47,42 +50,26 @@ namespace WebCore {
class PannerNode : public AudioNode {
public:
- // These must be defined as in the .idl file and must match those in the Panner class.
- enum {
- EQUALPOWER = 0,
- HRTF = 1,
- SOUNDFIELD = 2,
- };
-
- // 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,
- };
-
- static PassRefPtr<PannerNode> create(AudioContext* context, float sampleRate)
+ static Ref<PannerNode> create(AudioContext& context, float sampleRate)
{
- return adoptRef(new PannerNode(context, sampleRate));
+ return adoptRef(*new PannerNode(context, sampleRate));
}
virtual ~PannerNode();
// AudioNode
- virtual void process(size_t framesToProcess) override;
- virtual void pullInputs(size_t framesToProcess) override;
- virtual void reset() override;
- virtual void initialize() override;
- virtual void uninitialize() override;
+ void process(size_t framesToProcess) override;
+ void pullInputs(size_t framesToProcess) override;
+ void reset() override;
+ void initialize() override;
+ void uninitialize() override;
// Listener
AudioListener* listener();
// Panning model
- String panningModel() const;
- bool setPanningModel(unsigned); // Returns true on success.
- void setPanningModel(const String&);
+ PanningModelType panningModel() const { return m_panningModel; }
+ void setPanningModel(PanningModelType);
// Position
FloatPoint3D position() const { return m_position; }
@@ -97,9 +84,8 @@ public:
void setVelocity(float x, float y, float z) { m_velocity = FloatPoint3D(x, y, z); }
// Distance parameters
- String distanceModel() const;
- bool setDistanceModel(unsigned); // Returns true on success.
- void setDistanceModel(const String&);
+ DistanceModelType distanceModel() const;
+ void setDistanceModel(DistanceModelType);
double refDistance() { return m_distanceEffect.refDistance(); }
void setRefDistance(double refDistance) { m_distanceEffect.setRefDistance(refDistance); }
@@ -127,21 +113,21 @@ public:
AudioParam* distanceGain() { return m_distanceGain.get(); }
AudioParam* coneGain() { return m_coneGain.get(); }
- virtual double tailTime() const override { return m_panner ? m_panner->tailTime() : 0; }
- virtual double latencyTime() const override { return m_panner ? m_panner->latencyTime() : 0; }
+ double tailTime() const override { return m_panner ? m_panner->tailTime() : 0; }
+ double latencyTime() const override { return m_panner ? m_panner->latencyTime() : 0; }
private:
- PannerNode(AudioContext*, float sampleRate);
+ PannerNode(AudioContext&, float sampleRate);
// Returns the combined distance and cone gain attenuation.
float distanceConeGain();
// 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*);
+ void notifyAudioSourcesConnectedToNode(AudioNode*, HashSet<AudioNode*>& visitedNodes);
std::unique_ptr<Panner> m_panner;
- unsigned m_panningModel;
+ PanningModelType m_panningModel;
FloatPoint3D m_position;
FloatPoint3D m_orientation;
@@ -154,12 +140,15 @@ private:
ConeEffect m_coneEffect;
float m_lastGain;
+ // HRTF Database loader
+ RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader;
+
unsigned m_connectionCount;
// Synchronize process() and setPanningModel() which can change the panner.
- mutable std::mutex m_pannerMutex;
+ mutable Lock m_pannerMutex;
};
} // namespace WebCore
-#endif // PannerNode_h
+#endif