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

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.h

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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.h
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.h b/third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.h
index 590a3a3300b7a5496d6a87b6782cb93b1cc04045..d838e14354c221a3e893604f53e517bb1dd935e8 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.h
+++ b/third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.h
@@ -5,11 +5,22 @@
#ifndef AudioWorkletGlobalScope_h
#define AudioWorkletGlobalScope_h
+#include "bindings/core/v8/ScriptValue.h"
+#include "core/dom/ExecutionContext.h"
#include "core/workers/ThreadedWorkletGlobalScope.h"
+#include "modules/ModulesExport.h"
namespace blink {
-class AudioWorkletGlobalScope final : public ThreadedWorkletGlobalScope {
+class AudioBuffer;
+class AudioWorkletProcessor;
+class AudioWorkletProcessorDefinition;
+class ExceptionState;
+
+// This is constructed and destroyed on a worker thread, and all methods also
+// must be called on the worker thread.
+class MODULES_EXPORT AudioWorkletGlobalScope final
+ : public ThreadedWorkletGlobalScope {
DEFINE_WRAPPERTYPEINFO();
public:
@@ -19,6 +30,26 @@ class AudioWorkletGlobalScope final : public ThreadedWorkletGlobalScope {
v8::Isolate*,
WorkerThread*);
~AudioWorkletGlobalScope() override;
+ void dispose() final;
+ bool isAudioWorkletGlobalScope() const final { return true; }
+ void registerProcessor(const String& name,
+ const ScriptValue& classDefinition,
+ ExceptionState&);
+
+ // Creates an instance of AudioWorkletProcessor from a registered name. This
+ // function may return nullptr when 1) a definition cannot be found or 2) a
+ // new V8 object cannot be constructed for some reason.
+ AudioWorkletProcessor* createInstance(const String& name);
+
+ // Invokes the JS audio processing function from an instance of
+ // AudioWorkletProcessor, along with given AudioBuffer from the audio graph.
+ bool process(AudioWorkletProcessor*,
+ AudioBuffer* inputBuffer,
+ AudioBuffer* outputBuffer);
+
+ AudioWorkletProcessorDefinition* findDefinition(const String& name);
+
+ DECLARE_TRACE();
private:
AudioWorkletGlobalScope(const KURL&,
@@ -26,6 +57,13 @@ class AudioWorkletGlobalScope final : public ThreadedWorkletGlobalScope {
PassRefPtr<SecurityOrigin>,
v8::Isolate*,
WorkerThread*);
+
+ typedef HeapHashMap<String, Member<AudioWorkletProcessorDefinition>>
+ ProcessorDefinitionMap;
+ typedef HeapVector<Member<AudioWorkletProcessor>> ProcessorInstances;
+
+ ProcessorDefinitionMap m_processorDefinitionMap;
+ ProcessorInstances m_processorInstances;
};
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/BUILD.gn ('k') | third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698