mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1068270 - Add connectNode and disconnect methods to AudioNodeActor. r=vp
This commit is contained in:
parent
41996aa938
commit
3ac167fef8
@ -22,6 +22,7 @@ support-files =
|
|||||||
[browser_audionode-actor-get-type.js]
|
[browser_audionode-actor-get-type.js]
|
||||||
[browser_audionode-actor-is-source.js]
|
[browser_audionode-actor-is-source.js]
|
||||||
[browser_audionode-actor-bypass.js]
|
[browser_audionode-actor-bypass.js]
|
||||||
|
[browser_audionode-actor-connectnode-disconnect.js]
|
||||||
[browser_webaudio-actor-simple.js]
|
[browser_webaudio-actor-simple.js]
|
||||||
[browser_webaudio-actor-destroy-node.js]
|
[browser_webaudio-actor-destroy-node.js]
|
||||||
[browser_webaudio-actor-connect-param.js]
|
[browser_webaudio-actor-connect-param.js]
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that AudioNodeActor#connectNode() and AudioNodeActor#disconnect() work.
|
||||||
|
* Uses the editor front as the actors do not retain connect state.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function spawnTest() {
|
||||||
|
let { target, panel } = yield initWebAudioEditor(SIMPLE_CONTEXT_URL);
|
||||||
|
let { panelWin } = panel;
|
||||||
|
let { gFront, $, $$, EVENTS, gAudioNodes } = panelWin;
|
||||||
|
|
||||||
|
reload(target);
|
||||||
|
|
||||||
|
let [actors] = yield Promise.all([
|
||||||
|
get3(gFront, "create-node"),
|
||||||
|
waitForGraphRendered(panelWin, 3, 2)
|
||||||
|
]);
|
||||||
|
|
||||||
|
let [dest, osc, gain] = actors;
|
||||||
|
|
||||||
|
info("Disconnecting oscillator...");
|
||||||
|
osc.disconnect();
|
||||||
|
yield Promise.all([
|
||||||
|
waitForGraphRendered(panelWin, 3, 1),
|
||||||
|
once(gAudioNodes, "disconnect")
|
||||||
|
]);
|
||||||
|
ok(true, "Oscillator disconnected, event emitted.");
|
||||||
|
|
||||||
|
|
||||||
|
info("Reconnecting oscillator...");
|
||||||
|
osc.connectNode(gain);
|
||||||
|
yield Promise.all([
|
||||||
|
waitForGraphRendered(panelWin, 3, 2),
|
||||||
|
once(gAudioNodes, "connect")
|
||||||
|
]);
|
||||||
|
ok(true, "Oscillator reconnected.");
|
||||||
|
|
||||||
|
|
||||||
|
yield teardown(panel);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,7 @@ const { CallWatcherActor, CallWatcherFront } = require("devtools/server/actors/c
|
|||||||
const { ThreadActor } = require("devtools/server/actors/script");
|
const { ThreadActor } = require("devtools/server/actors/script");
|
||||||
|
|
||||||
const { on, once, off, emit } = events;
|
const { on, once, off, emit } = events;
|
||||||
const { method, Arg, Option, RetVal } = protocol;
|
const { types, method, Arg, Option, RetVal } = protocol;
|
||||||
|
|
||||||
const AUDIO_GLOBALS = [
|
const AUDIO_GLOBALS = [
|
||||||
"AudioContext", "AudioNode"
|
"AudioContext", "AudioNode"
|
||||||
@ -109,6 +109,7 @@ const NODE_PROPERTIES = {
|
|||||||
* An Audio Node actor allowing communication to a specific audio node in the
|
* An Audio Node actor allowing communication to a specific audio node in the
|
||||||
* Audio Context graph.
|
* Audio Context graph.
|
||||||
*/
|
*/
|
||||||
|
types.addActorType("audionode");
|
||||||
let AudioNodeActor = exports.AudioNodeActor = protocol.ActorClass({
|
let AudioNodeActor = exports.AudioNodeActor = protocol.ActorClass({
|
||||||
typeName: "audionode",
|
typeName: "audionode",
|
||||||
|
|
||||||
@ -289,7 +290,60 @@ let AudioNodeActor = exports.AudioNodeActor = protocol.ActorClass({
|
|||||||
({ param: prop, value: this.getParam(prop), flags: this.getParamFlags(prop) }));
|
({ param: prop, value: this.getParam(prop), flags: this.getParamFlags(prop) }));
|
||||||
}, {
|
}, {
|
||||||
response: { params: RetVal("json") }
|
response: { params: RetVal("json") }
|
||||||
|
}),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connects this audionode to another via `node.connect(dest)`.
|
||||||
|
*/
|
||||||
|
connectNode: method(function (destActor, output, input) {
|
||||||
|
let srcNode = this.node.get();
|
||||||
|
let destNode = destActor.node.get();
|
||||||
|
|
||||||
|
if (srcNode === null || destNode === null) {
|
||||||
|
return CollectedAudioNodeError();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Connect via the unwrapped node, so we can call the
|
||||||
|
// patched method that fires the webaudio actor's `connect-node` event.
|
||||||
|
// Connect directly to the wrapped `destNode`, otherwise
|
||||||
|
// the patched method thinks this is a new node and won't be
|
||||||
|
// able to find it in `_nativeToActorID`.
|
||||||
|
XPCNativeWrapper.unwrap(srcNode).connect(destNode, output, input);
|
||||||
|
} catch (e) {
|
||||||
|
return constructError(e);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
request: {
|
||||||
|
destActor: Arg(0, "audionode"),
|
||||||
|
output: Arg(1, "nullable:number"),
|
||||||
|
input: Arg(2, "nullable:number")
|
||||||
|
},
|
||||||
|
response: { error: RetVal("nullable:json") }
|
||||||
|
}),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnects this audionode from all connections via `node.disconnect()`.
|
||||||
|
*/
|
||||||
|
disconnect: method(function (destActor, output) {
|
||||||
|
let node = this.node.get();
|
||||||
|
|
||||||
|
if (node === null) {
|
||||||
|
return CollectedAudioNodeError();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Disconnect via the unwrapped node, so we can call the
|
||||||
|
// patched method that fires the webaudio actor's `disconnect` event.
|
||||||
|
XPCNativeWrapper.unwrap(node).disconnect(output);
|
||||||
|
} catch (e) {
|
||||||
|
return constructError(e);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
request: { output: Arg(0, "nullable:number") },
|
||||||
|
response: { error: RetVal("nullable:json") }
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -553,6 +607,7 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
|
|||||||
_onConnectNode: function (source, dest) {
|
_onConnectNode: function (source, dest) {
|
||||||
let sourceActor = this._getActorByNativeID(source.id);
|
let sourceActor = this._getActorByNativeID(source.id);
|
||||||
let destActor = this._getActorByNativeID(dest.id);
|
let destActor = this._getActorByNativeID(dest.id);
|
||||||
|
|
||||||
emit(this, "connect-node", {
|
emit(this, "connect-node", {
|
||||||
source: sourceActor,
|
source: sourceActor,
|
||||||
dest: destActor
|
dest: destActor
|
||||||
|
Loading…
Reference in New Issue
Block a user