mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 986705 - Implement web audio server events for connecting to an AudioParam in the web audio editor. r=vp
This commit is contained in:
parent
e7d4511bac
commit
6e6b4e58df
@ -9,6 +9,7 @@ support-files =
|
||||
doc_media-node-creation.html
|
||||
doc_destroy-nodes.html
|
||||
doc_connect-toggle.html
|
||||
doc_connect-param.html
|
||||
440hz_sine.ogg
|
||||
head.js
|
||||
|
||||
@ -20,6 +21,7 @@ support-files =
|
||||
[browser_audionode-actor-is-source.js]
|
||||
[browser_webaudio-actor-simple.js]
|
||||
[browser_webaudio-actor-destroy-node.js]
|
||||
[browser_webaudio-actor-connect-param.js]
|
||||
|
||||
[browser_wa_destroy-node-01.js]
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test the `connect-param` event on the web audio actor.
|
||||
*/
|
||||
|
||||
function spawnTest () {
|
||||
let [target, debuggee, front] = yield initBackend(CONNECT_PARAM_URL);
|
||||
let [_, _, [destNode, carrierNode, modNode, gainNode], _, connectParam] = yield Promise.all([
|
||||
front.setup({ reload: true }),
|
||||
once(front, "start-context"),
|
||||
getN(front, "create-node", 4),
|
||||
get2(front, "connect-node"),
|
||||
once(front, "connect-param")
|
||||
]);
|
||||
|
||||
info(connectParam);
|
||||
|
||||
is(connectParam.source.actorID, modNode.actorID, "`connect-param` has correct actor for `source`");
|
||||
is(connectParam.dest.actorID, gainNode.actorID, "`connect-param` has correct actor for `dest`");
|
||||
is(connectParam.param, "gain", "`connect-param` has correct parameter name for `param`");
|
||||
|
||||
yield removeTab(target.tab);
|
||||
finish();
|
||||
}
|
28
browser/devtools/webaudioeditor/test/doc_connect-param.html
Normal file
28
browser/devtools/webaudioeditor/test/doc_connect-param.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Web Audio Editor test page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<script type="text/javascript;version=1.8">
|
||||
"use strict";
|
||||
|
||||
let ctx = new AudioContext();
|
||||
let carrier = ctx.createOscillator();
|
||||
let modulator = ctx.createOscillator();
|
||||
let gain = ctx.createGain();
|
||||
carrier.connect(gain);
|
||||
gain.connect(ctx.destination);
|
||||
modulator.connect(gain.gain);
|
||||
modulator.start(0);
|
||||
carrier.start(0);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -28,6 +28,7 @@ const MEDIA_NODES_URL = EXAMPLE_URL + "doc_media-node-creation.html";
|
||||
const BUFFER_AND_ARRAY_URL = EXAMPLE_URL + "doc_buffer-and-array.html";
|
||||
const DESTROY_NODES_URL = EXAMPLE_URL + "doc_destroy-nodes.html";
|
||||
const CONNECT_TOGGLE_URL = EXAMPLE_URL + "doc_connect-toggle.html";
|
||||
const CONNECT_PARAM_URL = EXAMPLE_URL + "doc_connect-param.html";
|
||||
|
||||
// All tests are asynchronous.
|
||||
waitForExplicitFinish();
|
||||
|
@ -363,7 +363,7 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
|
||||
let { caller, args, window, name } = functionCall.details;
|
||||
let source = caller;
|
||||
let dest = args[0];
|
||||
let isAudioParam = dest instanceof window.AudioParam;
|
||||
let isAudioParam = dest ? getConstructorName(dest) === "AudioParam" : false;
|
||||
|
||||
// audionode.connect(param)
|
||||
if (name === "connect" && isAudioParam) {
|
||||
@ -433,8 +433,9 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
|
||||
},
|
||||
"connect-param": {
|
||||
type: "connectParam",
|
||||
source: Arg(0, "audionode"),
|
||||
param: Arg(1, "string")
|
||||
source: Option(0, "audionode"),
|
||||
dest: Option(0, "audionode"),
|
||||
param: Option(0, "string")
|
||||
},
|
||||
"change-param": {
|
||||
type: "changeParam",
|
||||
@ -461,12 +462,30 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
|
||||
// Ensure AudioNode is wrapped.
|
||||
node = new XPCNativeWrapper(node);
|
||||
|
||||
this._instrumentParams(node);
|
||||
|
||||
let actor = new AudioNodeActor(this.conn, node);
|
||||
this.manage(actor);
|
||||
this._nativeToActorID.set(node.id, actor.actorID);
|
||||
return actor;
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes an XrayWrapper node, and attaches the node's `nativeID`
|
||||
* to the AudioParams as `_parentID`, as well as the the type of param
|
||||
* as a string on `_paramName`.
|
||||
*/
|
||||
_instrumentParams: function (node) {
|
||||
let type = getConstructorName(node);
|
||||
Object.keys(NODE_PROPERTIES[type])
|
||||
.filter(isAudioParam.bind(null, node))
|
||||
.forEach(paramName => {
|
||||
let param = node[paramName];
|
||||
param._parentID = node.id;
|
||||
param._paramName = paramName;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes an AudioNode and returns the stored actor for it.
|
||||
* In some cases, we won't have an actor stored (for example,
|
||||
@ -505,10 +524,15 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
|
||||
|
||||
/**
|
||||
* Called when an audio node is connected to an audio param.
|
||||
* Implement in bug 986705
|
||||
*/
|
||||
_onConnectParam: function (source, dest) {
|
||||
// TODO bug 986705
|
||||
_onConnectParam: function (source, param) {
|
||||
let sourceActor = this._getActorByNativeID(source.id);
|
||||
let destActor = this._getActorByNativeID(param._parentID);
|
||||
emit(this, "connect-param", {
|
||||
source: sourceActor,
|
||||
dest: destActor,
|
||||
param: param._paramName
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user