summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.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/AudioScheduledSourceNode.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h')
-rw-r--r--Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h51
1 files changed, 17 insertions, 34 deletions
diff --git a/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h b/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h
index 05bff2b37..f6a1b2c1b 100644
--- a/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h
+++ b/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -26,22 +26,18 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef AudioScheduledSourceNode_h
-#define AudioScheduledSourceNode_h
+#pragma once
#include "AudioNode.h"
-#include "ExceptionCode.h"
namespace WebCore {
-class AudioBus;
-
class AudioScheduledSourceNode : public AudioNode {
public:
// These are the possible states an AudioScheduledSourceNode can be in:
//
// UNSCHEDULED_STATE - Initial playback state. Created, but not yet scheduled.
- // SCHEDULED_STATE - Scheduled to play (via noteOn() or noteGrainOn()), but not yet playing.
+ // SCHEDULED_STATE - Scheduled to play but not yet playing.
// PLAYING_STATE - Generating sound.
// FINISHED_STATE - Finished generating sound.
//
@@ -55,58 +51,45 @@ public:
FINISHED_STATE = 3
};
- AudioScheduledSourceNode(AudioContext*, float sampleRate);
-
- // Scheduling.
- void start(double when, ExceptionCode&);
- void stop(double when, ExceptionCode&);
+ AudioScheduledSourceNode(AudioContext&, float sampleRate);
-#if ENABLE(LEGACY_WEB_AUDIO)
- void noteOn(double when, ExceptionCode&);
- void noteOff(double when, ExceptionCode&);
-#endif
+ ExceptionOr<void> start(double when);
+ ExceptionOr<void> stop(double when);
unsigned short playbackState() const { return static_cast<unsigned short>(m_playbackState); }
bool isPlayingOrScheduled() const { return m_playbackState == PLAYING_STATE || m_playbackState == SCHEDULED_STATE; }
bool hasFinished() const { return m_playbackState == FINISHED_STATE; }
- EventListener* onended() { return getAttributeEventListener(eventNames().endedEvent); }
- void setOnended(PassRefPtr<EventListener> listener);
-
protected:
// Get frame information for the current time quantum.
// We handle the transition into PLAYING_STATE and FINISHED_STATE here,
// zeroing out portions of the outputBus which are outside the range of startFrame and endFrame.
- //
// Each frame time is relative to the context's currentSampleFrame().
- // quantumFrameOffset : Offset frame in this time quantum to start rendering.
- // nonSilentFramesToProcess : Number of frames rendering non-silence (will be <= quantumFrameSize).
- void updateSchedulingInfo(size_t quantumFrameSize,
- AudioBus* outputBus,
- size_t& quantumFrameOffset,
- size_t& nonSilentFramesToProcess);
+ // quantumFrameOffset: Offset frame in this time quantum to start rendering.
+ // nonSilentFramesToProcess: Number of frames rendering non-silence (will be <= quantumFrameSize).
+ void updateSchedulingInfo(size_t quantumFrameSize, AudioBus& outputBus, size_t& quantumFrameOffset, size_t& nonSilentFramesToProcess);
// Called when we have no more sound to play or the noteOff() time has been reached.
virtual void finish();
- static void notifyEndedDispatch(void*);
- void notifyEnded();
-
- PlaybackState m_playbackState;
+ PlaybackState m_playbackState { UNSCHEDULED_STATE };
// m_startTime is the time to start playing based on the context's timeline (0 or a time less than the context's current time means "now").
- double m_startTime; // in seconds
+ double m_startTime { 0 }; // in seconds
// m_endTime is the time to stop playing based on the context's timeline (0 or a time less than the context's current time means "now").
// If it hasn't been set explicitly, then the sound will not stop playing (if looping) or will stop when the end of the AudioBuffer
// has been reached.
double m_endTime; // in seconds
- bool m_hasEndedListener;
+ bool m_hasEndedListener { false };
static const double UnknownTime;
+
+private:
+ bool addEventListener(const AtomicString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
+ bool removeEventListener(const AtomicString& eventType, EventListener&, const ListenerOptions&) override;
+ void removeAllEventListeners() override;
};
} // namespace WebCore
-
-#endif // AudioScheduledSourceNode_h