summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.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/AudioBufferSourceNode.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h')
-rw-r--r--Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h54
1 files changed, 23 insertions, 31 deletions
diff --git a/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h b/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h
index 15fc56a0b..f4e63a859 100644
--- a/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h
+++ b/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h
@@ -22,40 +22,32 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef AudioBufferSourceNode_h
-#define AudioBufferSourceNode_h
+#pragma once
-#include "AudioBuffer.h"
-#include "AudioBus.h"
-#include "AudioParam.h"
#include "AudioScheduledSourceNode.h"
-#include "ExceptionCode.h"
-#include "PannerNode.h"
-#include <memory>
-#include <mutex>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
+#include <wtf/Lock.h>
namespace WebCore {
-class AudioContext;
+class AudioBuffer;
+class PannerNode;
// AudioBufferSourceNode is an AudioNode representing an audio source from an in-memory audio asset represented by an AudioBuffer.
// It generally will be used for short sounds which require a high degree of scheduling flexibility (can playback in rhythmically perfect ways).
-class AudioBufferSourceNode : public AudioScheduledSourceNode {
+class AudioBufferSourceNode final : public AudioScheduledSourceNode {
public:
- static PassRefPtr<AudioBufferSourceNode> create(AudioContext*, float sampleRate);
+ static Ref<AudioBufferSourceNode> create(AudioContext&, float sampleRate);
virtual ~AudioBufferSourceNode();
// AudioNode
- virtual void process(size_t framesToProcess) override;
- virtual void reset() override;
+ void process(size_t framesToProcess) final;
+ void reset() final;
// setBuffer() is called on the main thread. This is the buffer we use for playback.
// returns true on success.
- bool setBuffer(AudioBuffer*);
+ void setBuffer(RefPtr<AudioBuffer>&&);
AudioBuffer* buffer() { return m_buffer.get(); }
// numberOfChannels() returns the number of output channels. This value equals the number of channels from the buffer.
@@ -63,12 +55,7 @@ public:
unsigned numberOfChannels();
// Play-state
- void startGrain(double when, double grainOffset, ExceptionCode&);
- void startGrain(double when, double grainOffset, double grainDuration, ExceptionCode&);
-
-#if ENABLE(LEGACY_WEB_AUDIO)
- void noteGrainOn(double when, double grainOffset, double grainDuration, ExceptionCode&);
-#endif
+ ExceptionOr<void> start(double when, double grainOffset, std::optional<double> grainDuration);
// Note: the attribute was originally exposed as .looping, but to be more consistent in naming with <audio>
// and with how it's described in the specification, the proper attribute name is .loop
@@ -94,16 +81,23 @@ public:
void clearPannerNode();
// If we are no longer playing, propogate silence ahead to downstream nodes.
- virtual bool propagatesSilence() const override;
+ bool propagatesSilence() const final;
// AudioScheduledSourceNode
- virtual void finish() override;
+ void finish() final;
private:
- AudioBufferSourceNode(AudioContext*, float sampleRate);
+ AudioBufferSourceNode(AudioContext&, float sampleRate);
+
+ double tailTime() const final { return 0; }
+ double latencyTime() const final { return 0; }
- virtual double tailTime() const override { return 0; }
- virtual double latencyTime() const override { return 0; }
+ enum BufferPlaybackMode {
+ Entire,
+ Partial
+ };
+
+ ExceptionOr<void> startPlaying(BufferPlaybackMode, double when, double grainOffset, double grainDuration);
// Returns true on success.
bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t numberOfFrames);
@@ -150,9 +144,7 @@ private:
PannerNode* m_pannerNode;
// This synchronizes process() with setBuffer() which can cause dynamic channel count changes.
- mutable std::mutex m_processMutex;
+ mutable Lock m_processMutex;
};
} // namespace WebCore
-
-#endif // AudioBufferSourceNode_h