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

Side by Side Diff: Source/modules/webaudio/AudioBuffer.cpp

Issue 1183763003: Remove ArrayBufferDeallocationObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: s_ prefix Created 5 years, 6 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 | « Source/modules/webaudio/AudioBuffer.h ('k') | Source/platform/testing/RunAllTests.cpp » ('j') | 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 14 matching lines...) Expand all
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #if ENABLE(WEB_AUDIO) 30 #if ENABLE(WEB_AUDIO)
31 #include "modules/webaudio/AudioBuffer.h" 31 #include "modules/webaudio/AudioBuffer.h"
32 32
33 #include "bindings/core/v8/ExceptionMessages.h" 33 #include "bindings/core/v8/ExceptionMessages.h"
34 #include "bindings/core/v8/ExceptionState.h" 34 #include "bindings/core/v8/ExceptionState.h"
35 #include "core/dom/DOMArrayBufferDeallocationObserver.h"
36 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
37 #include "modules/webaudio/AudioContext.h" 36 #include "modules/webaudio/AudioContext.h"
38 #include "platform/audio/AudioBus.h" 37 #include "platform/audio/AudioBus.h"
39 #include "platform/audio/AudioFileReader.h" 38 #include "platform/audio/AudioFileReader.h"
40 #include "platform/audio/AudioUtilities.h" 39 #include "platform/audio/AudioUtilities.h"
41 #include "wtf/Float32Array.h" 40 #include "wtf/Float32Array.h"
42 41
43 namespace blink { 42 namespace blink {
44 43
45 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame s, float sampleRate) 44 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame s, float sampleRate)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 void AudioBuffer::zero() 318 void AudioBuffer::zero()
320 { 319 {
321 for (unsigned i = 0; i < m_channels.size(); ++i) { 320 for (unsigned i = 0; i < m_channels.size(); ++i) {
322 if (DOMFloat32Array* array = getChannelData(i)) { 321 if (DOMFloat32Array* array = getChannelData(i)) {
323 float* data = array->data(); 322 float* data = array->data();
324 memset(data, 0, length() * sizeof(*data)); 323 memset(data, 0, length() * sizeof(*data));
325 } 324 }
326 } 325 }
327 } 326 }
328 327
329 v8::Local<v8::Object> AudioBuffer::associateWithWrapper(v8::Isolate* isolate, co nst WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper)
330 {
331 ScriptWrappable::associateWithWrapper(isolate, wrapperType, wrapper);
332
333 if (!wrapper.IsEmpty()) {
334 // We only setDeallocationObservers on array buffers that are held by
335 // some object in the V8 heap, not in the ArrayBuffer constructor
336 // itself. This is because V8 GC only cares about memory it can free on
337 // GC, and until the object is exposed to JavaScript, V8 GC doesn't
338 // affect it.
339 for (unsigned i = 0, n = numberOfChannels(); i < n; ++i) {
340 getChannelData(i)->buffer()->setDeallocationObserver(DOMArrayBufferD eallocationObserver::instance());
341 }
342 }
343 return wrapper;
344 }
345
346 } // namespace blink 328 } // namespace blink
347 329
348 #endif // ENABLE(WEB_AUDIO) 330 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.h ('k') | Source/platform/testing/RunAllTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698