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

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

Issue 1097873003: Revert of AudioContext.decodeAudioData returns a Promise (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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/AudioContext.idl » ('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 e4fd7b7dee28250b02e6a236100dc514e36243b3..306485e48560889c5626c5c53bb6a3836b9f377e 100644
--- a/Source/modules/webaudio/AudioContext.cpp
+++ b/Source/modules/webaudio/AudioContext.cpp
@@ -115,7 +115,6 @@
, m_isOfflineContext(false)
, m_contextState(Suspended)
, m_cachedSampleFrame(0)
- , m_closedContextSampleRate(-1)
{
m_didInitializeContextGraphMutex = true;
m_destinationNode = DefaultAudioDestinationNode::create(this);
@@ -137,7 +136,6 @@
, m_isOfflineContext(true)
, m_contextState(Suspended)
, m_cachedSampleFrame(0)
- , m_closedContextSampleRate(-1)
{
m_didInitializeContextGraphMutex = true;
// Create a new destination for offline rendering.
@@ -154,14 +152,12 @@
fprintf(stderr, "%p: AudioContext::~AudioContext(): %u\n", this, m_contextId);
#endif
// AudioNodes keep a reference to their context, so there should be no way to be in the destructor if there are still AudioNodes around.
-
ASSERT(!m_isInitialized);
ASSERT(!m_referencedNodes.size());
ASSERT(!m_finishedNodes.size());
ASSERT(!m_suspendResolvers.size());
ASSERT(!m_isResolvingResumePromises);
ASSERT(!m_resumeResolvers.size());
- ASSERT(!m_audioDecoderResolvers.size());
}
void AudioContext::initialize()
@@ -237,14 +233,6 @@
ASSERT(m_listener);
m_listener->waitForHRTFDatabaseLoaderThreadCompletion();
- // Reject any decodeAudioData promises that haven't been fulfilled yet.
- for (auto& resolver : m_audioDecoderResolvers) {
- resolver->reject(DOMException::create(InvalidStateError, "Audio context is going away"));
- }
- m_audioDecoderResolvers.clear();
-
- // Uninitialization done, so clear flags to indicate that the AudioContext has no pending
- // activity anymore.
clear();
}
@@ -281,30 +269,20 @@
return AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate, exceptionState);
}
-ScriptPromise AudioContext::decodeAudioData(ScriptState* scriptState, DOMArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionState& exceptionState)
-{
+void AudioContext::decodeAudioData(DOMArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionState& exceptionState)
+{
+ if (isContextClosed()) {
+ throwExceptionForClosedState(exceptionState);
+ return;
+ }
+
if (!audioData) {
- RefPtrWillBeRawPtr<DOMException> error = DOMException::create(
- NotSupportedError,
+ exceptionState.throwDOMException(
+ SyntaxError,
"invalid ArrayBuffer for audioData.");
- if (errorCallback) {
- errorCallback->handleEvent(error.get());
- }
- return ScriptPromise::rejectWithDOMException(scriptState, error);
- }
-
- RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
- ScriptPromise promise = resolver->promise();
-
- m_audioDecoderResolvers.append(resolver);
-
- float rate = isContextClosed() ? m_closedContextSampleRate : sampleRate();
-
- ASSERT(rate > 0);
-
- m_audioDecoder.decodeAsync(audioData, rate, successCallback, errorCallback, resolver.get(), this);
-
- return promise;
+ return;
+ }
+ m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCallback);
}
AudioBufferSourceNode* AudioContext::createBufferSource(ExceptionState& exceptionState)
@@ -934,19 +912,6 @@
}
}
}
-
-void AudioContext::removeAudioDecoderResolver(ScriptPromiseResolver* resolver)
-{
- ASSERT(isMainThread());
-
- for (size_t k = 0; k < m_audioDecoderResolvers.size(); ++k) {
- if (resolver == m_audioDecoderResolvers.at(k)) {
- m_audioDecoderResolvers.remove(k);
- break;
- }
- }
-}
-
void AudioContext::handlePreRenderTasks()
{
ASSERT(isAudioThread());
@@ -1164,7 +1129,8 @@
{
ASSERT(isMainThread());
- // Audio context is closing down so reject any promises that are still pending.
+ // Audio context is closing down so reject any suspend or resume promises that are still
+ // pending.
for (auto& resolver : m_suspendResolvers) {
resolver->reject(DOMException::create(InvalidStateError, "Audio context is going away"));
@@ -1238,7 +1204,6 @@
DEFINE_TRACE(AudioContext)
{
- visitor->trace(m_audioDecoderResolvers);
visitor->trace(m_closeResolver);
visitor->trace(m_offlineResolver);
visitor->trace(m_renderTarget);
@@ -1306,9 +1271,6 @@
"Cannot close a context that is being closed or has already been closed."));
}
- // Save the current sample rate for any subsequent decodeAudioData calls.
- m_closedContextSampleRate = sampleRate();
-
m_closeResolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = m_closeResolver->promise();
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | Source/modules/webaudio/AudioContext.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698