Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Unified Diff: Source/modules/webaudio/AudioContext.cpp

Issue 1140723003: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Bring ToT Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | Source/modules/webaudio/AudioNode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioContext.cpp
diff --git a/Source/modules/webaudio/AudioContext.cpp b/Source/modules/webaudio/AudioContext.cpp
index e92fae7bc331226efa5a5c1436b738bfd4a1752e..074ca8f51269c70cad414aee773292e65d11c250 100644
--- a/Source/modules/webaudio/AudioContext.cpp
+++ b/Source/modules/webaudio/AudioContext.cpp
@@ -77,6 +77,29 @@ DEFINE_TRACE(AudioContext)
AbstractAudioContext::trace(visitor);
}
+ScriptPromise AudioContext::closeContext(ScriptState* scriptState)
+{
+ if (isContextClosed()) {
+ // We've already closed the context previously, but it hasn't yet been resolved, so just
+ // create a new promise and reject it.
+ return ScriptPromise::rejectWithDOMException(
+ scriptState,
+ DOMException::create(InvalidStateError,
+ "Cannot close a context that is being closed or has already been closed."));
+ }
+
+ m_closeResolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = m_closeResolver->promise();
+
+ // Stop the audio context. This will stop the destination node from pulling audio anymore. And
+ // since we have disconnected the destination from the audio graph, and thus has no references,
+ // the destination node can GCed if JS has no references. uninitialize() will also resolve the Promise
+ // created here.
+ uninitialize();
+
+ return promise;
+}
+
ScriptPromise AudioContext::suspendContext(ScriptState* scriptState)
{
ASSERT(isMainThread());
@@ -101,6 +124,15 @@ ScriptPromise AudioContext::suspendContext(ScriptState* scriptState)
return promise;
}
+ScriptPromise AudioContext::suspendContext(ScriptState* scriptState, double suspendTime)
+{
+ // This CANNOT be called on AudioContext; it is to implement the pure
+ // virtual interface from AbstractAudioContext.
+ RELEASE_ASSERT_NOT_REACHED();
+
+ return ScriptPromise();
+}
+
ScriptPromise AudioContext::resumeContext(ScriptState* scriptState)
{
ASSERT(isMainThread());
@@ -123,36 +155,13 @@ ScriptPromise AudioContext::resumeContext(ScriptState* scriptState)
// Save the resolver which will get resolved when the destination node starts pulling on the
// graph again.
{
- AutoLocker locker(this);
+ AutoLocker(this);
m_resumeResolvers.append(resolver);
}
return promise;
}
-ScriptPromise AudioContext::closeContext(ScriptState* scriptState)
-{
- if (isContextClosed()) {
- // We've already closed the context previously, but it hasn't yet been resolved, so just
- // create a new promise and reject it.
- return ScriptPromise::rejectWithDOMException(
- scriptState,
- DOMException::create(InvalidStateError,
- "Cannot close a context that is being closed or has already been closed."));
- }
-
- m_closeResolver = ScriptPromiseResolver::create(scriptState);
- ScriptPromise promise = m_closeResolver->promise();
-
- // Stop the audio context. This will stop the destination node from pulling audio anymore. And
- // since we have disconnected the destination from the audio graph, and thus has no references,
- // the destination node can GCed if JS has no references. uninitialize() will also resolve the Promise
- // created here.
- uninitialize();
-
- return promise;
-}
-
void AudioContext::didClose()
{
// This is specific to AudioContexts. OfflineAudioContexts
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | Source/modules/webaudio/AudioNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698