summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/webaudio/AudioContext.h
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-06-02 12:07:03 +0100
committerBen Murdoch <benm@google.com>2011-06-10 10:47:21 +0100
commit2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch)
treee4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/webaudio/AudioContext.h
parent87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff)
downloadexternal_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/webaudio/AudioContext.h')
-rw-r--r--Source/WebCore/webaudio/AudioContext.h39
1 files changed, 37 insertions, 2 deletions
diff --git a/Source/WebCore/webaudio/AudioContext.h b/Source/WebCore/webaudio/AudioContext.h
index ddd474c..4f89091 100644
--- a/Source/WebCore/webaudio/AudioContext.h
+++ b/Source/WebCore/webaudio/AudioContext.h
@@ -28,6 +28,8 @@
#include "ActiveDOMObject.h"
#include "AudioBus.h"
#include "AudioDestinationNode.h"
+#include "EventListener.h"
+#include "EventTarget.h"
#include "HRTFDatabaseLoader.h"
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
@@ -59,13 +61,19 @@ class JavaScriptAudioNode;
// AudioContext is the cornerstone of the web audio API and all AudioNodes are created from it.
// For thread safety between the audio thread and the main thread, it has a rendering graph locking mechanism.
-class AudioContext : public ActiveDOMObject, public RefCounted<AudioContext> {
+class AudioContext : public ActiveDOMObject, public RefCounted<AudioContext>, public EventTarget {
public:
+ // Create an AudioContext for rendering to the audio hardware.
static PassRefPtr<AudioContext> create(Document*);
+ // Create an AudioContext for offline (non-realtime) rendering.
+ static PassRefPtr<AudioContext> createOfflineContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, double sampleRate);
+
virtual ~AudioContext();
bool isInitialized() const;
+
+ bool isOfflineContext() { return m_isOfflineContext; }
// Returns true when initialize() was called AND all asynchronous initialization has completed.
bool isRunnable() const;
@@ -73,7 +81,7 @@ public:
// Document notification
virtual void stop();
- Document* document(); // ASSERTs if document no longer exists.
+ Document* document() const; // ASSERTs if document no longer exists.
bool hasDocument();
AudioDestinationNode* destination() { return m_destinationNode.get(); }
@@ -180,9 +188,27 @@ public:
// Only accessed when the graph lock is held.
void markAudioNodeInputDirty(AudioNodeInput*);
void markAudioNodeOutputDirty(AudioNodeOutput*);
+
+ // EventTarget
+ virtual ScriptExecutionContext* scriptExecutionContext() const;
+ virtual AudioContext* toAudioContext();
+ virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
+ virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData; }
+
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(complete);
+
+ // Reconcile ref/deref which are defined both in AudioNode and EventTarget.
+ using RefCounted<AudioContext>::ref;
+ using RefCounted<AudioContext>::deref;
+
+ void startRendering();
+ void fireCompletionEvent();
private:
AudioContext(Document*);
+ AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, double sampleRate);
+ void constructCommon();
+
void lazyInitialize();
void uninitialize();
@@ -252,6 +278,15 @@ private:
// HRTF Database loader
RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader;
+
+ // EventTarget
+ virtual void refEventTarget() { ref(); }
+ virtual void derefEventTarget() { deref(); }
+ EventTargetData m_eventTargetData;
+
+ RefPtr<AudioBuffer> m_renderTarget;
+
+ bool m_isOfflineContext;
};
} // WebCore