mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1125817 - Fix async/sync consistencies with web audio tool client node events. r=vp
This commit is contained in:
parent
84b102a4c0
commit
efbee6e909
@ -93,32 +93,24 @@ let WebAudioEditorController = {
|
||||
PropertiesView.resetUI();
|
||||
},
|
||||
|
||||
// Since node create and connect are probably executed back to back,
|
||||
// and the controller's `_onCreateNode` needs to look up type,
|
||||
// the edge creation could be called before the graph node is actually
|
||||
// created. This way, we can check and listen for the event before
|
||||
// adding an edge.
|
||||
_waitForNodeCreation: function (sourceActor, destActor) {
|
||||
let deferred = defer();
|
||||
let source = gAudioNodes.get(sourceActor.actorID);
|
||||
let dest = gAudioNodes.get(destActor.actorID);
|
||||
// Since node events (create, disconnect, connect) are all async,
|
||||
// we have to make sure to wait that the node has finished creating
|
||||
// before performing an operation on it.
|
||||
getNode: function* (nodeActor) {
|
||||
let id = nodeActor.actorID;
|
||||
let node = gAudioNodes.get(id);
|
||||
|
||||
if (!source || !dest) {
|
||||
if (!node) {
|
||||
let { resolve, promise } = defer();
|
||||
gAudioNodes.on("add", function createNodeListener (createdNode) {
|
||||
if (sourceActor.actorID === createdNode.id)
|
||||
source = createdNode;
|
||||
if (destActor.actorID === createdNode.id)
|
||||
dest = createdNode;
|
||||
if (source && dest) {
|
||||
if (createdNode.id === id) {
|
||||
gAudioNodes.off("add", createNodeListener);
|
||||
deferred.resolve([source, dest]);
|
||||
resolve(createdNode);
|
||||
}
|
||||
});
|
||||
node = yield promise;
|
||||
}
|
||||
else {
|
||||
deferred.resolve([source, dest]);
|
||||
}
|
||||
return deferred.promise;
|
||||
return node;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -202,7 +194,8 @@ let WebAudioEditorController = {
|
||||
* Called when a node is connected to another node.
|
||||
*/
|
||||
_onConnectNode: Task.async(function* ({ source: sourceActor, dest: destActor }) {
|
||||
let [source, dest] = yield WebAudioEditorController._waitForNodeCreation(sourceActor, destActor);
|
||||
let source = yield WebAudioEditorController.getNode(sourceActor);
|
||||
let dest = yield WebAudioEditorController.getNode(destActor);
|
||||
source.connect(dest);
|
||||
}),
|
||||
|
||||
@ -210,22 +203,24 @@ let WebAudioEditorController = {
|
||||
* Called when a node is conneceted to another node's AudioParam.
|
||||
*/
|
||||
_onConnectParam: Task.async(function* ({ source: sourceActor, dest: destActor, param }) {
|
||||
let [source, dest] = yield WebAudioEditorController._waitForNodeCreation(sourceActor, destActor);
|
||||
let source = yield WebAudioEditorController.getNode(sourceActor);
|
||||
let dest = yield WebAudioEditorController.getNode(destActor);
|
||||
source.connect(dest, param);
|
||||
}),
|
||||
|
||||
/**
|
||||
* Called when a node is disconnected.
|
||||
*/
|
||||
_onDisconnectNode: function(nodeActor) {
|
||||
let node = gAudioNodes.get(nodeActor.actorID);
|
||||
_onDisconnectNode: Task.async(function* (nodeActor) {
|
||||
let node = yield WebAudioEditorController.getNode(nodeActor);
|
||||
node.disconnect();
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Called when a node param is changed.
|
||||
*/
|
||||
_onChangeParam: function({ actor, param, value }) {
|
||||
window.emit(EVENTS.CHANGE_PARAM, gAudioNodes.get(actor.actorID), param, value);
|
||||
}
|
||||
_onChangeParam: Task.async(function* ({ actor, param, value }) {
|
||||
let node = yield WebAudioEditorController.getNode(actor);
|
||||
window.emit(EVENTS.CHANGE_PARAM, node, param, value);
|
||||
})
|
||||
};
|
||||
|
@ -11,6 +11,7 @@ support-files =
|
||||
doc_connect-multi-param.html
|
||||
doc_iframe-context.html
|
||||
doc_automation.html
|
||||
doc_bug_1125817.html
|
||||
440hz_sine.ogg
|
||||
head.js
|
||||
|
||||
@ -39,6 +40,7 @@ support-files =
|
||||
[browser_wa_reset-03.js]
|
||||
[browser_wa_reset-04.js]
|
||||
[browser_wa_navigate.js]
|
||||
[browser_wa_controller-01.js]
|
||||
|
||||
[browser_wa_graph-click.js]
|
||||
[browser_wa_graph-markers.js]
|
||||
|
@ -0,0 +1,27 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 1125817
|
||||
* Tests to ensure that disconnecting a node immediately
|
||||
* after creating it does not fail.
|
||||
*/
|
||||
|
||||
const BUG_1125817_URL = EXAMPLE_URL + "doc_bug_1125817.html";
|
||||
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initWebAudioEditor(BUG_1125817_URL);
|
||||
let { panelWin } = panel;
|
||||
let { gFront, $, $$, EVENTS, gAudioNodes } = panelWin;
|
||||
|
||||
reload(target);
|
||||
|
||||
let [actors] = yield Promise.all([
|
||||
once(gAudioNodes, "add", 2),
|
||||
once(gAudioNodes, "disconnect")
|
||||
]);
|
||||
|
||||
ok(true, "Successfully disconnected a just-created node.");
|
||||
|
||||
yield teardown(target);
|
||||
});
|
23
browser/devtools/webaudioeditor/test/doc_bug_1125817.html
Normal file
23
browser/devtools/webaudioeditor/test/doc_bug_1125817.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!-- 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 osc = ctx.createOscillator();
|
||||
osc.frequency.value = 200;
|
||||
osc.disconnect();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user