| Index: Source/modules/webaudio/OfflineAudioContext.h
|
| diff --git a/Source/modules/webaudio/OfflineAudioContext.h b/Source/modules/webaudio/OfflineAudioContext.h
|
| index 99276e7cbb5e19dc7edf2934b67a726f2eed8d2a..7de70700dc0499d64c5e22f9baa82d23b2b2f0af 100644
|
| --- a/Source/modules/webaudio/OfflineAudioContext.h
|
| +++ b/Source/modules/webaudio/OfflineAudioContext.h
|
| @@ -39,9 +39,73 @@ public:
|
|
|
| virtual ~OfflineAudioContext();
|
|
|
| + // Check all the scheduled suspends if the context should suspend at
|
| + // currentTime(). Then post tasks to resolve promises on the main thread
|
| + // if necessary.
|
| + bool shouldSuspendNow();
|
| +
|
| + // Clear suspensions marked as 'resolved' in the list.
|
| + void resolvePendingSuspendPromises();
|
| +
|
| + // Fire completion event when the rendering is finished.
|
| + void fireCompletionEvent();
|
| +
|
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(complete);
|
| +
|
| ScriptPromise startOfflineRendering(ScriptState*);
|
| + ScriptPromise suspendOfflineRendering(ScriptState*, double);
|
| + ScriptPromise resumeOfflineRendering(ScriptState*);
|
| +
|
| private:
|
| OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
|
| +
|
| + // A container class for a pair of time information and the suspend promise
|
| + // resolver.
|
| + class ScheduledSuspendContainer
|
| + : public NoBaseWillBeGarbageCollected<ScheduledSuspendContainer> {
|
| + public:
|
| + static PassOwnPtr<ScheduledSuspendContainer> create(size_t suspendFrame, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>);
|
| + ~ScheduledSuspendContainer();
|
| + PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_resolver; }
|
| +
|
| + // Query if the rendering should be suspended at |whenFrame|.
|
| + bool shouldSuspendAt(size_t whenFrame) const;
|
| +
|
| + // Query if the suspend is pending for the promise resolution.
|
| + bool isPending() const;
|
| +
|
| + // Mark the suspend as pending. Containers with 'pending' flag will
|
| + // be collectively resolved when the actual suspension happens.
|
| + void markAsPending();
|
| +
|
| + DECLARE_TRACE();
|
| +
|
| + private:
|
| + ScheduledSuspendContainer(size_t suspendFrame, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>);
|
| +
|
| + // Suspend time in samples.
|
| + size_t m_suspendFrame;
|
| +
|
| + // Associated promise resolver.
|
| + RefPtrWillBeMember<ScriptPromiseResolver> m_resolver;
|
| +
|
| + // A pending marker for the safe batch removal.
|
| + bool m_isPending;
|
| + };
|
| +
|
| + // Resolve pending suspend promises and removes it from the list.
|
| + void resolvePendingSuspendPromisesOnMainThread();
|
| +
|
| + WillBeHeapVector<OwnPtrWillBeMember<ScheduledSuspendContainer>> m_scheduledSuspends;
|
| + RefPtrWillBeMember<ScriptPromiseResolver> m_completeResolver;
|
| +
|
| + // This flag is necessary to indicate the rendering has actually started.
|
| + // Note that initial state of context is 'Suspended', which is the same
|
| + // state when the context is suspended.
|
| + bool m_isRenderingStarted;
|
| +
|
| + // Total render sample length.
|
| + size_t m_totalRenderFrames;
|
| };
|
|
|
| } // namespace blink
|
|
|