Skip to content

Commit 7c39e1a

Browse files
committed
fix(voice): remove this.current dep in sendAudioFrame
1 parent 87473ba commit 7c39e1a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/voice/VoiceConnection.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class VoiceConnection extends EventEmitter {
276276
this.reconnecting = false;
277277
this.ready = true;
278278
// Send audio to properly establish the socket (e.g. for voice receive)
279-
this.sendAudioFrame(SILENCE_FRAME);
279+
this.sendAudioFrame(SILENCE_FRAME, this.frameSize);
280280
/**
281281
* Fired when the voice connection turns ready
282282
* @event VoiceConnection#ready
@@ -638,9 +638,10 @@ class VoiceConnection extends EventEmitter {
638638
/**
639639
* Send a packet containing an Opus audio frame
640640
* @arg {Buffer} frame The Opus audio frame
641+
* @arg {Number} [frameSize] The size (in samples) of the Opus audio frame
641642
*/
642-
sendAudioFrame(frame) {
643-
this.timestamp += this.current.options.frameSize;
643+
sendAudioFrame(frame, frameSize = this.frameSize) {
644+
this.timestamp += frameSize;
644645
if(this.timestamp >= 4294967295) {
645646
this.timestamp -= 4294967295;
646647
}
@@ -711,7 +712,7 @@ class VoiceConnection extends EventEmitter {
711712

712713
if(this.secret) {
713714
for(let i = 0; i < 5; i++) {
714-
this.sendAudioFrame(SILENCE_FRAME);
715+
this.sendAudioFrame(SILENCE_FRAME, this.frameSize);
715716
}
716717
}
717718
this.playing = false;
@@ -805,7 +806,7 @@ class VoiceConnection extends EventEmitter {
805806
return this.stopPlaying();
806807
}
807808

808-
this.sendAudioFrame(this.current.buffer);
809+
this.sendAudioFrame(this.current.buffer, this.current.options.frameSize);
809810
this.current.playTime += this.current.options.frameDuration;
810811
this.current.timeout = setTimeout(this._send, this.current.startTime + this.current.pausedTime + this.current.playTime - Date.now());
811812
}

0 commit comments

Comments
 (0)