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

Unified Diff: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp

Issue 2746913003: Detach buffer in decodeAudioData (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
index d0acd8dbd40e27c20f1486655552d659e763b0ab..bbca9785cba69655f2c1cc4d9c3c7bb4c13d1937 100644
--- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
@@ -284,9 +284,26 @@ ScriptPromise BaseAudioContext::decodeAudioData(
DCHECK_GT(rate, 0);
- m_decodeAudioResolvers.insert(resolver);
- m_audioDecoder.decodeAsync(audioData, rate, successCallback, errorCallback,
- resolver, this);
+ if (audioData->isShared()) {
+ // If audioData is detached, we need to reject the promise with
haraken 2017/03/14 03:17:49 Is isShared() equivalent to a detached buffer in t
Raymond Toy 2017/03/14 15:01:03 I don't know. I can't seem to find the corresponde
binji 2017/03/14 17:50:55 Right, a SharedArrayBuffer cannot be detached, and
+ // error TypeError.
+ DOMException* error =
+ DOMException::create(V8TypeError, "Cannot decode detached buffer");
haraken 2017/03/14 03:17:49 Nit: resolver->reject(V8ThrowException::createType
Raymond Toy 2017/03/14 19:32:59 I still need an DOMException object for the errorC
haraken 2017/03/14 19:57:51 Ah, then DOMException is fine :)
+ resolver->reject(error);
+ if (errorCallback) {
+ errorCallback->handleEvent(error);
+ }
+ } else {
+ // Detach the audio array buffer from the main thread and start
+ // async decoding of the data.
+ WTF::ArrayBufferContents buf;
+ audioData->transfer(buf);
haraken 2017/03/14 03:17:49 Why was this detachment & transfer not needed befo
Raymond Toy 2017/03/14 15:01:03 The original version of the spec didn't have this.
+ DOMArrayBuffer* audio = DOMArrayBuffer::create(buf);
+
+ m_decodeAudioResolvers.insert(resolver);
+ m_audioDecoder.decodeAsync(audio, rate, successCallback, errorCallback,
+ resolver, this);
+ }
return promise;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698