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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 DCHECK(isMainThread()); 277 DCHECK(isMainThread());
278 DCHECK(audioData); 278 DCHECK(audioData);
279 279
280 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 280 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
281 ScriptPromise promise = resolver->promise(); 281 ScriptPromise promise = resolver->promise();
282 282
283 float rate = isContextClosed() ? closedContextSampleRate() : sampleRate(); 283 float rate = isContextClosed() ? closedContextSampleRate() : sampleRate();
284 284
285 DCHECK_GT(rate, 0); 285 DCHECK_GT(rate, 0);
286 286
287 m_decodeAudioResolvers.insert(resolver); 287 if (audioData->isShared()) {
288 m_audioDecoder.decodeAsync(audioData, rate, successCallback, errorCallback, 288 // 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
289 resolver, this); 289 // error TypeError.
290 DOMException* error =
291 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 :)
292 resolver->reject(error);
293 if (errorCallback) {
294 errorCallback->handleEvent(error);
295 }
296 } else {
297 // Detach the audio array buffer from the main thread and start
298 // async decoding of the data.
299 WTF::ArrayBufferContents buf;
300 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.
301 DOMArrayBuffer* audio = DOMArrayBuffer::create(buf);
302
303 m_decodeAudioResolvers.insert(resolver);
304 m_audioDecoder.decodeAsync(audio, rate, successCallback, errorCallback,
305 resolver, this);
306 }
290 307
291 return promise; 308 return promise;
292 } 309 }
293 310
294 void BaseAudioContext::handleDecodeAudioData( 311 void BaseAudioContext::handleDecodeAudioData(
295 AudioBuffer* audioBuffer, 312 AudioBuffer* audioBuffer,
296 ScriptPromiseResolver* resolver, 313 ScriptPromiseResolver* resolver,
297 AudioBufferCallback* successCallback, 314 AudioBufferCallback* successCallback,
298 AudioBufferCallback* errorCallback) { 315 AudioBufferCallback* errorCallback) {
299 DCHECK(isMainThread()); 316 DCHECK(isMainThread());
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 } 918 }
902 919
903 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const { 920 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const {
904 if (getExecutionContext()) 921 if (getExecutionContext())
905 return getExecutionContext()->getSecurityOrigin(); 922 return getExecutionContext()->getSecurityOrigin();
906 923
907 return nullptr; 924 return nullptr;
908 } 925 }
909 926
910 } // namespace blink 927 } // namespace blink
OLDNEW
« 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