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> { |
haraken
2015/06/17 06:46:09
There would be no reason not to use an oilpan by d
hongchan
2015/06/17 20:10:39
I couldn't change this because I am getting a comp
haraken
2015/06/17 20:13:53
Just to clarify: You need to pass both oilpan buli
|
+ public: |
+ static PassOwnPtr<ScheduledSuspendContainer> create(size_t suspendFrame, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>); |
haraken
2015/06/17 06:46:09
PassOwnPtr<ScheduledSuspendContainer> => Scheduled
hongchan
2015/06/17 20:10:39
For the same reason above, it breaks the compilati
|
+ ~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. |
haraken
2015/06/17 06:46:09
it => them
hongchan
2015/06/17 20:10:39
Oops. Done.
|
+ void resolvePendingSuspendPromisesOnMainThread(); |
+ |
+ WillBeHeapVector<OwnPtrWillBeMember<ScheduledSuspendContainer>> m_scheduledSuspends; |
haraken
2015/06/17 06:46:09
HeapVector<Member<ScheduledSuspendContainer>>
haraken
2015/06/17 06:46:09
Wouldn't it be better to use a HashSet instead of
hongchan
2015/06/17 20:10:39
I agree. Will look into it.
|
+ 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 |