Index: Source/modules/webaudio/AudioContext.h |
diff --git a/Source/modules/webaudio/AudioContext.h b/Source/modules/webaudio/AudioContext.h |
index 092eece9ac5f427e7bf33a1913c3ae1f5dd9c4b4..ade23d9814739f2f159ac068404afcffc6d1027c 100644 |
--- a/Source/modules/webaudio/AudioContext.h |
+++ b/Source/modules/webaudio/AudioContext.h |
@@ -100,7 +100,6 @@ public: |
DECLARE_VIRTUAL_TRACE(); |
bool isInitialized() const { return m_isInitialized; } |
- bool isOfflineContext() { return m_isOfflineContext; } |
// Document notification |
virtual void stop() override final; |
@@ -130,6 +129,8 @@ public: |
AudioListener* listener() { return m_listener.get(); } |
+ virtual bool hasRealtimeConstraint() = 0; |
+ |
// The AudioNode create methods are called on the main thread (from JavaScript). |
AudioBufferSourceNode* createBufferSource(ExceptionState&); |
MediaElementAudioSourceNode* createMediaElementSource(HTMLMediaElement*, ExceptionState&); |
@@ -157,11 +158,11 @@ public: |
PeriodicWave* createPeriodicWave(DOMFloat32Array* real, DOMFloat32Array* imag, ExceptionState&); |
// Close |
- ScriptPromise closeContext(ScriptState*); |
+ virtual ScriptPromise closeContext(ScriptState*) = 0; |
// Suspend/Resume |
- ScriptPromise suspendContext(ScriptState*); |
- ScriptPromise resumeContext(ScriptState*); |
+ virtual ScriptPromise suspendContext(ScriptState*) = 0; |
+ virtual ScriptPromise resumeContext(ScriptState*) = 0; |
// When a source node has started processing and needs to be protected, |
// this method tells the context to protect the node. |
@@ -230,10 +231,7 @@ public: |
// - closeContext() has been called, even if the audio HW has not yet been |
// stopped. It will be stopped eventually. |
// - it has been stopped (or is stopping) by its execution context. |
- bool isContextClosed() const { return m_closeResolver || m_isStopScheduled || m_isCleared; } |
- |
- static unsigned s_hardwareContextCount; |
- static unsigned s_contextId; |
+ virtual bool isContextClosed() const { return m_isStopScheduled || m_isCleared; } |
// Get the security origin for this audio context. |
SecurityOrigin* securityOrigin() const; |
@@ -242,10 +240,19 @@ protected: |
explicit AudioContext(Document*); |
AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate); |
+ void setContextState(AudioContextState); |
+ virtual void didClose() {} |
+ void uninitialize(); |
+ |
RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; |
+ |
+ // FIXME(dominicc): Move m_resumeResolvers to OnlineAudioContext, because only |
+ // it creates these Promises. |
+ // Vector of promises created by resume(). It takes time to handle them, so we collect all of |
+ // the promises here until they can be resolved or rejected. |
+ WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_resumeResolvers; |
private: |
void initialize(); |
- void uninitialize(); |
// ExecutionContext calls stop twice. |
// We'd like to schedule only one stop action for them. |
@@ -278,16 +285,12 @@ private: |
// this. |
HeapVector<Member<AudioNode>> m_activeSourceNodes; |
- // Stop rendering the audio graph. |
- void stopRendering(); |
- |
+ // FIXME(dominicc): Move these to OnlineAudioContext because only |
+ // it creates these Promises. |
// Handle Promises for resume() and suspend() |
void resolvePromisesForResume(); |
void resolvePromisesForResumeOnMainThread(); |
- // Vector of promises created by resume(). It takes time to handle them, so we collect all of |
- // the promises here until they can be resolved or rejected. |
- WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_resumeResolvers; |
void rejectPendingResolvers(); |
// True if we're in the process of resolving promises for resume(). Resolving can take some |
@@ -303,17 +306,11 @@ private: |
Member<AudioBuffer> m_renderTarget; |
- bool m_isOfflineContext; |
- |
// The state of the AudioContext. |
AudioContextState m_contextState; |
- void setContextState(AudioContextState); |
AsyncAudioDecoder m_audioDecoder; |
- // The Promise that is returned by close(); |
- RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; |
- |
// Tries to handle AudioBufferSourceNodes that were started but became disconnected or was never |
// connected. Because these never get pulled anymore, they will stay around forever. So if we |
// can, try to stop them so they can be collected. |
@@ -322,8 +319,6 @@ private: |
// This is considering 32 is large enough for multiple channels audio. |
// It is somewhat arbitrary and could be increased if necessary. |
enum { MaxNumberOfChannels = 32 }; |
- |
- unsigned m_contextId; |
}; |
} // namespace blink |