Bug 1055211 - Add bypass method on AudioNodeActors. r=vp

This commit is contained in:
Jordan Santell 2014-09-19 15:08:00 +02:00
parent afc4eee46a
commit fc3aa417ca
3 changed files with 70 additions and 2 deletions

View File

@ -20,9 +20,10 @@ support-files =
[browser_audionode-actor-get-set-param.js]
[browser_audionode-actor-get-type.js]
[browser_audionode-actor-is-source.js]
[browser_webaudio-actor-connect-param.js]
[browser_webaudio-actor-destroy-node.js]
[browser_audionode-actor-bypass.js]
[browser_webaudio-actor-simple.js]
[browser_webaudio-actor-destroy-node.js]
[browser_webaudio-actor-connect-param.js]
[browser_wa_destroy-node-01.js]

View File

@ -0,0 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test AudioNode#bypass(), AudioNode#isBypassed()
*/
function spawnTest () {
let [target, debuggee, front] = yield initBackend(SIMPLE_CONTEXT_URL);
let [_, [destNode, oscNode, gainNode]] = yield Promise.all([
front.setup({ reload: true }),
get3(front, "create-node")
]);
is((yield gainNode.isBypassed()), false, "Nodes start off unbypassed.");
info("Calling node#bypass(true)");
yield gainNode.bypass(true);
is((yield gainNode.isBypassed()), true, "Node is now bypassed.");
info("Calling node#bypass(false)");
yield gainNode.bypass(false);
is((yield gainNode.isBypassed()), false, "Node back to being unbypassed.");
yield removeTab(target.tab);
finish();
}

View File

@ -156,6 +156,44 @@ let AudioNodeActor = exports.AudioNodeActor = protocol.ActorClass({
response: { source: RetVal("boolean") }
}),
/**
* Returns a boolean indicating if the AudioNode has been "bypassed",
* via `AudioNodeActor#bypass` method.
*
* @return Boolean
*/
isBypassed: method(function () {
let node = this.node.get();
if (node === null) {
return false;
}
return node.passThrough;
}, {
response: { bypassed: RetVal("boolean") }
}),
/**
* Takes a boolean, either enabling or disabling the "passThrough" option
* on an AudioNode. If a node is bypassed, an effects processing node (like gain, biquad),
* will allow the audio stream to pass through the node, unaffected.
*
* @param Boolean enable
* Whether the bypass value should be set on or off.
*/
bypass: method(function (enable) {
let node = this.node.get();
if (node === null) {
return;
}
node.passThrough = enable;
}, {
request: { enable: Arg(0, "boolean") },
oneway: true
}),
/**
* Changes a param on the audio node. Responds with either `undefined`
* on success, or a description of the error upon param set failure.