| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/webaudio/AudioWorkletProcessor.h" | 5 #include "modules/webaudio/AudioWorkletProcessor.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Dictionary.h" |
| 7 #include "modules/webaudio/AudioWorkletGlobalScope.h" | 8 #include "modules/webaudio/AudioWorkletGlobalScope.h" |
| 9 #include "modules/webaudio/AudioWorkletProcessorDefinition.h" |
| 10 #include "modules/webaudio/AudioBuffer.h" |
| 8 | 11 |
| 9 namespace blink { | 12 namespace blink { |
| 10 | 13 |
| 11 // This static factory should be called after an instance of |AudioWorkletNode| | 14 // 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 | 15 // gets created by user-supplied JS code in the main thread. This factory must |
| 13 // not be called by user in |AudioWorkletGlobalScope|. | 16 // not be called by user in |AudioWorkletGlobalScope|. |
| 14 AudioWorkletProcessor* AudioWorkletProcessor::Create( | 17 AudioWorkletProcessor* AudioWorkletProcessor::Create( |
| 15 AudioWorkletGlobalScope* global_scope, | 18 AudioWorkletGlobalScope* global_scope, |
| 16 const String& name) { | 19 AudioWorkletProcessorDefinition* definition) { |
| 17 DCHECK(!IsMainThread()); | 20 DCHECK(!IsMainThread()); |
| 18 DCHECK(global_scope); | 21 DCHECK(global_scope); |
| 19 return new AudioWorkletProcessor(global_scope, name); | 22 return new AudioWorkletProcessor(global_scope, definition); |
| 20 } | 23 } |
| 21 | 24 |
| 22 AudioWorkletProcessor::AudioWorkletProcessor( | 25 AudioWorkletProcessor::AudioWorkletProcessor( |
| 23 AudioWorkletGlobalScope* global_scope, | 26 AudioWorkletGlobalScope* global_scope, |
| 24 const String& name) | 27 AudioWorkletProcessorDefinition* definition) |
| 25 : global_scope_(global_scope), name_(name) {} | 28 : global_scope_(global_scope), definition_(definition) {} |
| 26 | 29 |
| 27 AudioWorkletProcessor::~AudioWorkletProcessor() {} | 30 AudioWorkletProcessor::~AudioWorkletProcessor() {} |
| 28 | 31 |
| 29 void AudioWorkletProcessor::SetInstance(v8::Isolate* isolate, | 32 void AudioWorkletProcessor::SetInstance(v8::Isolate* isolate, |
| 30 v8::Local<v8::Object> instance) { | 33 v8::Local<v8::Object> instance) { |
| 31 DCHECK(global_scope_->IsContextThread()); | 34 DCHECK(global_scope_->IsContextThread()); |
| 32 instance_.Set(isolate, instance); | 35 instance_.Set(isolate, instance); |
| 33 } | 36 } |
| 34 | 37 |
| 35 v8::Local<v8::Object> AudioWorkletProcessor::InstanceLocal( | 38 v8::Local<v8::Object> AudioWorkletProcessor::InstanceLocal( |
| 36 v8::Isolate* isolate) { | 39 v8::Isolate* isolate) { |
| 37 DCHECK(global_scope_->IsContextThread()); | 40 DCHECK(global_scope_->IsContextThread()); |
| 38 return instance_.NewLocal(isolate); | 41 return instance_.NewLocal(isolate); |
| 39 } | 42 } |
| 40 | 43 |
| 41 void AudioWorkletProcessor::Process(AudioBuffer* input_buffer, | 44 void AudioWorkletProcessor::Process(AudioBuffer* input_buffer, |
| 42 AudioBuffer* output_buffer) { | 45 AudioBuffer* output_buffer) { |
| 43 DCHECK(global_scope_->IsContextThread()); | 46 DCHECK(global_scope_->IsContextThread()); |
| 44 global_scope_->Process(this, input_buffer, output_buffer); | 47 global_scope_->Process(this, input_buffer, output_buffer); |
| 45 } | 48 } |
| 46 | 49 |
| 50 const String& AudioWorkletProcessor::GetName() const { |
| 51 return definition_->GetName(); |
| 52 } |
| 53 |
| 54 // const HeapVector<AudioParamDescriptor>& AudioWorkletProcessor:: |
| 55 // GetAudioParamDescriptors() const { |
| 56 // return definition_->GetAudioParamDescriptors(); |
| 57 // } |
| 58 |
| 47 DEFINE_TRACE(AudioWorkletProcessor) { | 59 DEFINE_TRACE(AudioWorkletProcessor) { |
| 48 visitor->Trace(global_scope_); | 60 visitor->Trace(global_scope_); |
| 61 visitor->Trace(definition_); |
| 49 } | 62 } |
| 50 | 63 |
| 51 } // namespace blink | 64 } // namespace blink |
| OLD | NEW |