From bfde1dd8f2d7785dd2974c5310fac45634637855 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Mon, 13 Aug 2018 17:35:21 +0100 Subject: [PATCH] fix: StreamDispatcher doesn't emit finish if ended while paused (#2648) --- src/client/voice/dispatcher/StreamDispatcher.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/voice/dispatcher/StreamDispatcher.js b/src/client/voice/dispatcher/StreamDispatcher.js index 4b6a5f860..748e4f3f8 100644 --- a/src/client/voice/dispatcher/StreamDispatcher.js +++ b/src/client/voice/dispatcher/StreamDispatcher.js @@ -121,8 +121,11 @@ class StreamDispatcher extends Writable { * Pauses playback */ pause() { + if (this.paused) return; + if (this.streams.opus) this.streams.opus.unpipe(this); + this._writeCallback(); this._setSpeaking(false); - if (!this.paused) this.pausedSince = Date.now(); + this.pausedSince = Date.now(); } /** @@ -142,6 +145,7 @@ class StreamDispatcher extends Writable { */ resume() { if (!this.pausedSince) return; + if (this.streams.opus) this.streams.opus.pipe(this); this._pausedTime += Date.now() - this.pausedSince; this.pausedSince = null; if (typeof this._writeCallback === 'function') this._writeCallback();