From 2f630a0dbba19de65ccf73d824e76d8c6a3cd2c3 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Fri, 30 Dec 2016 12:43:56 +0000 Subject: [PATCH] AudioPlayer now destroys all dispatchers on closing, Broadcasts are also destroyed properly --- src/client/voice/player/AudioPlayer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/voice/player/AudioPlayer.js b/src/client/voice/player/AudioPlayer.js index 6a1ac90b3..b43edb443 100644 --- a/src/client/voice/player/AudioPlayer.js +++ b/src/client/voice/player/AudioPlayer.js @@ -27,6 +27,7 @@ class AudioPlayer extends EventEmitter { timestamp: 0, pausedTime: 0, }; + this.voiceConnection.once('closing', () => this.destroyAllStreams()); } get currentTranscoder() { @@ -34,7 +35,9 @@ class AudioPlayer extends EventEmitter { } destroyStream(stream) { - if (stream instanceof VoiceBroadcast) { + if (stream instanceof VoiceBroadcast && this.streams.has(stream)) { + const data = this.streams.get(stream); + if (data.dispatcher) data.dispatcher.destroy('end'); this.streams.delete(stream); return; }