summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/webaudio/OscillatorNode.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/OscillatorNode.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/Modules/webaudio/OscillatorNode.h')
-rw-r--r--Source/WebCore/Modules/webaudio/OscillatorNode.h54
1 files changed, 21 insertions, 33 deletions
diff --git a/Source/WebCore/Modules/webaudio/OscillatorNode.h b/Source/WebCore/Modules/webaudio/OscillatorNode.h
index 05969266f..790f01507 100644
--- a/Source/WebCore/Modules/webaudio/OscillatorNode.h
+++ b/Source/WebCore/Modules/webaudio/OscillatorNode.h
@@ -22,47 +22,34 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef OscillatorNode_h
-#define OscillatorNode_h
+#pragma once
-#include "AudioBus.h"
-#include "AudioParam.h"
#include "AudioScheduledSourceNode.h"
-#include <mutex>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
+#include <wtf/Lock.h>
namespace WebCore {
-class AudioContext;
class PeriodicWave;
// OscillatorNode is an audio generator of periodic waveforms.
-class OscillatorNode : public AudioScheduledSourceNode {
+class OscillatorNode final : public AudioScheduledSourceNode {
public:
// The waveform type.
- // These must be defined as in the .idl file.
- enum {
- SINE = 0,
- SQUARE = 1,
- SAWTOOTH = 2,
- TRIANGLE = 3,
- CUSTOM = 4
+ enum class Type {
+ Sine,
+ Square,
+ Sawtooth,
+ Triangle,
+ Custom
};
- static PassRefPtr<OscillatorNode> create(AudioContext*, float sampleRate);
+ static Ref<OscillatorNode> create(AudioContext&, float sampleRate);
virtual ~OscillatorNode();
-
- // AudioNode
- virtual void process(size_t framesToProcess) override;
- virtual void reset() override;
-
- String type() const;
- bool setType(unsigned); // Returns true on success.
- void setType(const String&);
+ Type type() const { return m_type; }
+ ExceptionOr<void> setType(Type);
AudioParam* frequency() { return m_frequency.get(); }
AudioParam* detune() { return m_detune.get(); }
@@ -70,18 +57,21 @@ public:
void setPeriodicWave(PeriodicWave*);
private:
- OscillatorNode(AudioContext*, float sampleRate);
+ OscillatorNode(AudioContext&, float sampleRate);
- virtual double tailTime() const override { return 0; }
- virtual double latencyTime() const override { return 0; }
+ void process(size_t framesToProcess) final;
+ void reset() final;
+
+ double tailTime() const final { return 0; }
+ double latencyTime() const final { return 0; }
// Returns true if there are sample-accurate timeline parameter changes.
bool calculateSampleAccuratePhaseIncrements(size_t framesToProcess);
- virtual bool propagatesSilence() const override;
+ bool propagatesSilence() const final;
// One of the waveform types defined in the enum.
- unsigned short m_type;
+ Type m_type { Type::Sine };
// Frequency value in Hertz.
RefPtr<AudioParam> m_frequency;
@@ -96,7 +86,7 @@ private:
double m_virtualReadIndex;
// This synchronizes process().
- mutable std::mutex m_processMutex;
+ mutable Lock m_processMutex;
// Stores sample-accurate values calculated according to frequency and detune.
AudioFloatArray m_phaseIncrements;
@@ -112,5 +102,3 @@ private:
};
} // namespace WebCore
-
-#endif // OscillatorNode_h