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

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

Issue 2727733002: Implement AudioWorkletProcessor interface (Closed)
Patch Set: Added AudioWorkletProcessor and AudioWorkletProcessorDefinition classes Created 3 years, 10 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
Index: third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp b/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..01589714aae924f03b55b380fee76d2dafe12322
--- /dev/null
+++ b/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp
@@ -0,0 +1,45 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/webaudio/AudioWorkletProcessor.h"
+
+#include "modules/webaudio/AudioBuffer.h"
+#include "modules/webaudio/AudioWorkletGlobalScope.h"
+#include "modules/webaudio/AudioWorkletProcessorDefinition.h"
+
+namespace blink {
+
+AudioWorkletProcessor* AudioWorkletProcessor::create(
+ const String& name,
+ AudioWorkletGlobalScope* globalScope) {
+ AudioWorkletProcessorDefinition* definition =
+ globalScope->findDefinition(name);
+
+ if (!definition)
+ return nullptr;
nhiroki 2017/03/06 10:08:44 It looks strange that create() returns a nullptr.
hongchan 2017/03/06 20:06:12 Ah, that's right. This method does not get called
+
+ return new AudioWorkletProcessor(definition);
+}
+
+AudioWorkletProcessor::AudioWorkletProcessor(
+ AudioWorkletProcessorDefinition* definition)
+ : m_definition(definition) {
+ m_instance = m_definition->createInstance();
+}
+
+AudioWorkletProcessor::~AudioWorkletProcessor() {}
+
+bool AudioWorkletProcessor::process(AudioBuffer* inputBuffer,
+ AudioBuffer* outputBuffer) {
+ DCHECK(m_definition);
+ DCHECK(!m_instance.IsEmpty());
+
+ return m_definition->process(m_instance, inputBuffer, outputBuffer);
+}
+
+DEFINE_TRACE(AudioWorkletProcessor) {
+ visitor->trace(m_definition);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698