Skip to content

Commit

Permalink
Fix #369 - AudioListener would have a connection to a dropped PannerNode
Browse files Browse the repository at this point in the history
  • Loading branch information
orottier committed Oct 11, 2023
1 parent 4718f7a commit c30aa91
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/render/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,16 @@ impl Graph {
// Nodes are only dropped when they do not have incoming connections.
// But they may have AudioParams feeding into them, these can de dropped too.
nodes.retain(|id, n| {
id.0 < 2 // never drop Listener and Destination node
|| !n
.borrow()
.outgoing_edges
.iter()
.any(|e| e.other_id == *index)
// Check if this node was connected to the dropped node. In that case, it is
// either an AudioParam (which can be dropped), or the AudioListener that feeds
// into a PannerNode (which can be disconnected).
let outgoing_edges = &mut n.borrow_mut().outgoing_edges;
let prev_len = outgoing_edges.len();
outgoing_edges.retain(|e| e.other_id != *index);
let was_connected = outgoing_edges.len() != prev_len;

let special = id.0 < 2; // never drop Listener and Destination node
special || !was_connected
});
}
});
Expand Down

0 comments on commit c30aa91

Please sign in to comment.