Index: Source/modules/webaudio/AudioContext.cpp |
diff --git a/Source/modules/webaudio/AudioContext.cpp b/Source/modules/webaudio/AudioContext.cpp |
index a6e0aebbeeab2c4dc1278d17ec43f392fd25f5df..0dc37ab270b142f7f8c956fd19ed73bf4a5aa714 100644 |
--- a/Source/modules/webaudio/AudioContext.cpp |
+++ b/Source/modules/webaudio/AudioContext.cpp |
@@ -730,15 +730,9 @@ void AudioContext::notifyStateChange() |
ScriptPromise AudioContext::suspendContext(ScriptState* scriptState) |
{ |
ASSERT(isMainThread()); |
- AutoLocker locker(this); |
+ ASSERT(!isOfflineContext()); |
- if (isOfflineContext()) { |
- return ScriptPromise::rejectWithDOMException( |
- scriptState, |
- DOMException::create( |
- InvalidAccessError, |
- "cannot suspend an OfflineAudioContext")); |
- } |
+ AutoLocker locker(this); |
RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
ScriptPromise promise = resolver->promise(); |
@@ -854,7 +848,7 @@ void AudioContext::handlePreRenderTasks() |
// At the beginning of every render quantum, try to update the internal rendering graph state (from main thread changes). |
// It's OK if the tryLock() fails, we'll just take slightly longer to pick up the changes. |
- if (tryLock()) { |
+ if (!isOfflineContext() && tryLock()) { |
Raymond Toy
2015/06/12 21:11:36
Add comment on why we have this test now for isOff
hongchan
2015/06/15 18:40:46
Done.
|
deferredTaskHandler().handleDeferredTasks(); |
resolvePromisesForResume(); |
@@ -863,7 +857,18 @@ void AudioContext::handlePreRenderTasks() |
handleStoppableSourceNodes(); |
unlock(); |
+ |
+ return; |
} |
+ |
+ // If this is Offline Audio Context, simply lock the graph and do the tasks. |
Raymond Toy
2015/06/12 21:11:36
I think this is wrong. If we're running online, a
hongchan
2015/06/15 18:40:46
Done.
|
+ deferredTaskHandler().forceLock(); |
+ |
+ deferredTaskHandler().handleDeferredTasks(); |
+ resolvePromisesForResume(); |
+ handleStoppableSourceNodes(); |
+ |
+ unlock(); |
} |
void AudioContext::handlePostRenderTasks() |
@@ -873,7 +878,7 @@ void AudioContext::handlePostRenderTasks() |
// Must use a tryLock() here too. Don't worry, the lock will very rarely be contended and this method is called frequently. |
// The worst that can happen is that there will be some nodes which will take slightly longer than usual to be deleted or removed |
// from the render graph (in which case they'll render silence). |
- if (tryLock()) { |
+ if (!isOfflineContext() && tryLock()) { |
Raymond Toy
2015/06/12 21:11:36
Same comment as for handlePreRenderTasks(). And f
hongchan
2015/06/15 18:40:46
Done.
|
// Take care of AudioNode tasks where the tryLock() failed previously. |
deferredTaskHandler().breakConnections(); |
@@ -884,7 +889,19 @@ void AudioContext::handlePostRenderTasks() |
deferredTaskHandler().requestToDeleteHandlersOnMainThread(); |
unlock(); |
+ |
+ return; |
} |
+ |
+ // If this is Offline Audio Context, simply lock the graph and do the tasks. |
+ deferredTaskHandler().forceLock(); |
+ |
+ deferredTaskHandler().breakConnections(); |
+ releaseFinishedSourceNodes(); |
+ deferredTaskHandler().handleDeferredTasks(); |
+ deferredTaskHandler().requestToDeleteHandlersOnMainThread(); |
+ |
+ unlock(); |
} |
void AudioContext::resolvePromisesForResumeOnMainThread() |
@@ -945,9 +962,10 @@ ExecutionContext* AudioContext::executionContext() const |
void AudioContext::startRendering() |
{ |
- // This is called for both online and offline contexts. |
+ // This is only for the real-time context. |
ASSERT(isMainThread()); |
ASSERT(m_destinationNode); |
+ ASSERT(!isOfflineContext()); |
if (m_contextState == Suspended) { |
destination()->audioDestinationHandler().startRendering(); |
@@ -970,32 +988,23 @@ void AudioContext::stopRendering() |
void AudioContext::fireCompletionEvent() |
{ |
- ASSERT(isMainThread()); |
- if (!isMainThread()) |
- return; |
- |
- AudioBuffer* renderedBuffer = m_renderTarget.get(); |
- |
- // For an offline context, we set the state to closed here so that the oncomplete handler sees |
- // that the context has been closed. |
- setContextState(Closed); |
+ ASSERT_WITH_MESSAGE(1, "fireCompletionEvent() only valid for offline audio context"); |
+} |
- ASSERT(renderedBuffer); |
- if (!renderedBuffer) |
- return; |
+bool AudioContext::shouldSuspendNow() |
+{ |
+ ASSERT_WITH_MESSAGE(1, "shouldSuspendNow() only valid for offline audio context"); |
+ return false; |
+} |
- // Avoid firing the event if the document has already gone away. |
- if (executionContext()) { |
- // Call the offline rendering completion event listener and resolve the promise too. |
- dispatchEvent(OfflineAudioCompletionEvent::create(renderedBuffer)); |
- m_offlineResolver->resolve(renderedBuffer); |
- } |
+void AudioContext::resolvePendingSuspendPromises() |
+{ |
+ ASSERT_WITH_MESSAGE(1, "clearResolvedSuspend() only valid for offline audio context"); |
} |
DEFINE_TRACE(AudioContext) |
{ |
visitor->trace(m_closeResolver); |
- visitor->trace(m_offlineResolver); |
visitor->trace(m_renderTarget); |
visitor->trace(m_destinationNode); |
visitor->trace(m_listener); |