Index: Source/modules/webaudio/OfflineAudioContext.h |
diff --git a/Source/modules/webaudio/OfflineAudioContext.h b/Source/modules/webaudio/OfflineAudioContext.h |
index 99276e7cbb5e19dc7edf2934b67a726f2eed8d2a..d545a6358863a137acda008e17fec15877bb2b9a 100644 |
--- a/Source/modules/webaudio/OfflineAudioContext.h |
+++ b/Source/modules/webaudio/OfflineAudioContext.h |
@@ -36,12 +36,63 @@ class MODULES_EXPORT OfflineAudioContext final : public AudioContext { |
DEFINE_WRAPPERTYPEINFO(); |
public: |
static OfflineAudioContext* create(ExecutionContext*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState&); |
- |
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. |
+ virtual bool shouldSuspendNow(); |
+ |
+ // Fire completion event when the rendering is finished. |
+ virtual 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, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>); |
Raymond Toy
2015/05/28 16:37:36
I think adding an argument variable for size_t wou
hongchan
2015/06/09 20:49:59
Done.
|
+ ~ScheduledSuspendContainer(); |
+ PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_resolver; } |
+ |
+ bool shouldSuspendAt(size_t) const; |
Raymond Toy
2015/05/28 16:37:36
Add parameter name for size_t.
hongchan
2015/06/09 20:50:00
Done.
|
+ |
+ DECLARE_TRACE(); |
+ |
+ private: |
+ ScheduledSuspendContainer(size_t, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>); |
Raymond Toy
2015/05/28 16:37:36
Add parameter name for size_t.
hongchan
2015/06/09 20:50:00
Done.
|
+ |
+ // Specified suspend time in samples and associated promise resolver. |
Raymond Toy
2015/05/28 16:37:36
This comment looks like it applies to m_when, whic
hongchan
2015/06/09 20:50:00
Done.
|
+ size_t m_when; |
Raymond Toy
2015/05/28 16:37:36
"when" is used for time (in sec) everywhere else.
hongchan
2015/06/09 20:50:00
I used m_whenAsFrame once, but thought it was too
|
+ RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; |
+ }; |
+ |
+ // Resolve a suspend at the given index in the scheduled suspend list. This |
+ // changes the state of context and then remove the promise from the list. |
Raymond Toy
2015/05/28 16:37:36
"remove" -> "removes"
hongchan
2015/06/09 20:50:00
Done.
|
+ void resolveSuspendOnMainThread(unsigned); |
+ |
+ // Check if there are scheduled suspends with the same frame. |
+ bool isValidToScheduleAt(size_t); |
Raymond Toy
2015/05/28 16:37:36
Add parameter name.
hongchan
2015/06/09 20:50:00
Done.
Raymond Toy
2015/06/09 22:34:59
Where did isValidToScheduleAt go to?
|
+ |
+ 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 |