Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "modules/webaudio/AudioContext.h" | 29 #include "modules/webaudio/AudioContext.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 class ExceptionState; | 33 class ExceptionState; |
| 34 | 34 |
| 35 class MODULES_EXPORT OfflineAudioContext final : public AudioContext { | 35 class MODULES_EXPORT OfflineAudioContext final : public AudioContext { |
| 36 DEFINE_WRAPPERTYPEINFO(); | 36 DEFINE_WRAPPERTYPEINFO(); |
| 37 public: | 37 public: |
| 38 static OfflineAudioContext* create(ExecutionContext*, unsigned numberOfChann els, size_t numberOfFrames, float sampleRate, ExceptionState&); | 38 static OfflineAudioContext* create(ExecutionContext*, unsigned numberOfChann els, size_t numberOfFrames, float sampleRate, ExceptionState&); |
| 39 | |
| 40 virtual ~OfflineAudioContext(); | 39 virtual ~OfflineAudioContext(); |
| 41 | 40 |
| 41 // Check all the scheduled suspends if the context should suspend at | |
| 42 // currentTime(). Then post tasks to resolve promises on the main thread | |
| 43 // if necessary. | |
| 44 virtual bool shouldSuspendNow(); | |
| 45 | |
| 46 // Fire completion event when the rendering is finished. | |
| 47 virtual void fireCompletionEvent(); | |
| 48 | |
| 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(complete); | |
| 50 | |
| 42 ScriptPromise startOfflineRendering(ScriptState*); | 51 ScriptPromise startOfflineRendering(ScriptState*); |
| 52 ScriptPromise suspendOfflineRendering(ScriptState*, double); | |
| 53 ScriptPromise resumeOfflineRendering(ScriptState*); | |
| 54 | |
| 43 private: | 55 private: |
| 44 OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFra mes, float sampleRate); | 56 OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFra mes, float sampleRate); |
| 57 | |
| 58 // A container class for a pair of time information and the suspend promise | |
| 59 // resolver. | |
| 60 class ScheduledSuspendContainer | |
| 61 : public NoBaseWillBeGarbageCollected<ScheduledSuspendContainer> { | |
| 62 public: | |
| 63 static PassOwnPtr<ScheduledSuspendContainer> create(size_t, PassRefPtrWi llBeRawPtr<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.
| |
| 64 ~ScheduledSuspendContainer(); | |
| 65 PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_reso lver; } | |
| 66 | |
| 67 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.
| |
| 68 | |
| 69 DECLARE_TRACE(); | |
| 70 | |
| 71 private: | |
| 72 ScheduledSuspendContainer(size_t, PassRefPtrWillBeRawPtr<ScriptPromiseRe solver>); | |
|
Raymond Toy
2015/05/28 16:37:36
Add parameter name for size_t.
hongchan
2015/06/09 20:50:00
Done.
| |
| 73 | |
| 74 // 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.
| |
| 75 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
| |
| 76 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; | |
| 77 }; | |
| 78 | |
| 79 // Resolve a suspend at the given index in the scheduled suspend list. This | |
| 80 // 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.
| |
| 81 void resolveSuspendOnMainThread(unsigned); | |
| 82 | |
| 83 // Check if there are scheduled suspends with the same frame. | |
| 84 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?
| |
| 85 | |
| 86 WillBeHeapVector<OwnPtrWillBeMember<ScheduledSuspendContainer>> m_scheduledS uspends; | |
| 87 RefPtrWillBeMember<ScriptPromiseResolver> m_completeResolver; | |
| 88 | |
| 89 // This flag is necessary to indicate the rendering has actually started. | |
| 90 // Note that initial state of context is 'Suspended', which is the same | |
| 91 // state when the context is suspended. | |
| 92 bool m_isRenderingStarted; | |
| 93 | |
| 94 // Total render sample length. | |
| 95 size_t m_totalRenderFrames; | |
| 45 }; | 96 }; |
| 46 | 97 |
| 47 } // namespace blink | 98 } // namespace blink |
| 48 | 99 |
| 49 #endif // OfflineAudioContext_h | 100 #endif // OfflineAudioContext_h |
| OLD | NEW |