summaryrefslogtreecommitdiffstats
path: root/devtools/shared/fronts/webaudio.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/shared/fronts/webaudio.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/shared/fronts/webaudio.js')
-rw-r--r--devtools/shared/fronts/webaudio.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/devtools/shared/fronts/webaudio.js b/devtools/shared/fronts/webaudio.js
new file mode 100644
index 000000000..73594c513
--- /dev/null
+++ b/devtools/shared/fronts/webaudio.js
@@ -0,0 +1,83 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const {
+ audionodeSpec,
+ webAudioSpec,
+ AUTOMATION_METHODS,
+ NODE_CREATION_METHODS,
+ NODE_ROUTING_METHODS,
+} = require("devtools/shared/specs/webaudio");
+const protocol = require("devtools/shared/protocol");
+const AUDIO_NODE_DEFINITION = require("devtools/server/actors/utils/audionodes.json");
+
+/**
+ * The corresponding Front object for the AudioNodeActor.
+ *
+ * @attribute {String} type
+ * The type of audio node, like "OscillatorNode", "MediaElementAudioSourceNode"
+ * @attribute {Boolean} source
+ * Boolean indicating if the node is a source node, like BufferSourceNode,
+ * MediaElementAudioSourceNode, OscillatorNode, etc.
+ * @attribute {Boolean} bypassable
+ * Boolean indicating if the audio node is bypassable (splitter,
+ * merger and destination nodes, for example, are not)
+ */
+const AudioNodeFront = protocol.FrontClassWithSpec(audionodeSpec, {
+ form: function (form, detail) {
+ if (detail === "actorid") {
+ this.actorID = form;
+ return;
+ }
+
+ this.actorID = form.actor;
+ this.type = form.type;
+ this.source = form.source;
+ this.bypassable = form.bypassable;
+ },
+
+ initialize: function (client, form) {
+ protocol.Front.prototype.initialize.call(this, client, form);
+ // if we were manually passed a form, this was created manually and
+ // needs to own itself for now.
+ if (form) {
+ this.manage(this);
+ }
+ }
+});
+
+exports.AudioNodeFront = AudioNodeFront;
+
+/**
+ * The corresponding Front object for the WebAudioActor.
+ */
+const WebAudioFront = protocol.FrontClassWithSpec(webAudioSpec, {
+ initialize: function (client, { webaudioActor }) {
+ protocol.Front.prototype.initialize.call(this, client, { actor: webaudioActor });
+ this.manage(this);
+ },
+
+ /**
+ * If connecting to older geckos (<Fx43), where audio node actor's do not
+ * contain `type`, `source` and `bypassable` properties, fetch
+ * them manually here.
+ */
+ _onCreateNode: protocol.preEvent("create-node", function (audionode) {
+ if (!audionode.type) {
+ return audionode.getType().then(type => {
+ audionode.type = type;
+ audionode.source = !!AUDIO_NODE_DEFINITION[type].source;
+ audionode.bypassable = !AUDIO_NODE_DEFINITION[type].unbypassable;
+ });
+ }
+ return null;
+ }),
+});
+
+WebAudioFront.AUTOMATION_METHODS = new Set(AUTOMATION_METHODS);
+WebAudioFront.NODE_CREATION_METHODS = new Set(NODE_CREATION_METHODS);
+WebAudioFront.NODE_ROUTING_METHODS = new Set(NODE_ROUTING_METHODS);
+
+exports.WebAudioFront = WebAudioFront;