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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp

Issue 2727733002: Implement AudioWorkletProcessor interface (Closed)
Patch Set: Addressing feedback from rtoy@ 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/webaudio/AudioWorkletProcessor.h"
6
7 #include "modules/webaudio/AudioWorkletGlobalScope.h"
8
9 namespace blink {
10
11 // This static factory should be called after an instance of |AudioWorkletNode|
12 // gets created by user-supplied JS code in the main thread. This factory must
13 // not be called by user in |AudioWorkletGlobalScope|.
14 AudioWorkletProcessor* AudioWorkletProcessor::create(
15 AudioWorkletGlobalScope* globalScope,
16 const String& name) {
17 DCHECK(!isMainThread());
18 DCHECK(globalScope);
19 return new AudioWorkletProcessor(globalScope, name);
20 }
21
22 AudioWorkletProcessor::AudioWorkletProcessor(
23 AudioWorkletGlobalScope* globalScope,
24 const String& name)
25 : m_globalScope(globalScope), m_name(name) {}
26
27 AudioWorkletProcessor::~AudioWorkletProcessor() {}
28
29 void AudioWorkletProcessor::setInstance(v8::Isolate* isolate,
30 v8::Local<v8::Object> instance) {
31 DCHECK(m_globalScope->isContextThread());
32 m_instance.set(isolate, instance);
33 }
34
35 v8::Local<v8::Object> AudioWorkletProcessor::instanceLocal(
36 v8::Isolate* isolate) {
37 DCHECK(m_globalScope->isContextThread());
38 return m_instance.newLocal(isolate);
39 }
40
41 void AudioWorkletProcessor::process(AudioBuffer* inputBuffer,
42 AudioBuffer* outputBuffer) {
43 DCHECK(m_globalScope->isContextThread());
44 m_globalScope->process(this, inputBuffer, outputBuffer);
45 }
46
47 DEFINE_TRACE(AudioWorkletProcessor) {
48 visitor->trace(m_globalScope);
49 }
50
51 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698