Merge pull request #71 from LLK/bugfix/disconnect-on-dispose

Disconnect audio nodes on dispose
This commit is contained in:
Eric Rosenbaum 2018-01-10 09:56:15 -05:00 committed by GitHub
commit 77a1f17b1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -52,6 +52,16 @@ class PanEffect {
connect (node) {
this.channelMerger.connect(node);
}
/**
* Clean up and disconnect audio nodes.
*/
dispose () {
this.input.disconnect();
this.leftGain.disconnect();
this.rightGain.disconnect();
this.channelMerger.disconnect();
}
}
module.exports = PanEffect;

View file

@ -133,6 +133,14 @@ class AudioPlayer {
if (this.audioEngine === null) return;
this.effectsNode.gain.setTargetAtTime(value / 100, 0, this.audioEngine.DECAY_TIME);
}
/**
* Clean up and disconnect audio nodes.
*/
dispose () {
this.panEffect.dispose();
this.effectsNode.disconnect();
}
}