Skip to content

Commit

Permalink
fix(voice): remove this.current dep in sendAudioFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
abalabahaha committed Nov 16, 2021
1 parent 87473ba commit 7c39e1a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/voice/VoiceConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class VoiceConnection extends EventEmitter {
this.reconnecting = false;
this.ready = true;
// Send audio to properly establish the socket (e.g. for voice receive)
this.sendAudioFrame(SILENCE_FRAME);
this.sendAudioFrame(SILENCE_FRAME, this.frameSize);
/**
* Fired when the voice connection turns ready
* @event VoiceConnection#ready
Expand Down Expand Up @@ -638,9 +638,10 @@ class VoiceConnection extends EventEmitter {
/**
* Send a packet containing an Opus audio frame
* @arg {Buffer} frame The Opus audio frame
* @arg {Number} [frameSize] The size (in samples) of the Opus audio frame
*/
sendAudioFrame(frame) {
this.timestamp += this.current.options.frameSize;
sendAudioFrame(frame, frameSize = this.frameSize) {
this.timestamp += frameSize;
if(this.timestamp >= 4294967295) {
this.timestamp -= 4294967295;
}
Expand Down Expand Up @@ -711,7 +712,7 @@ class VoiceConnection extends EventEmitter {

if(this.secret) {
for(let i = 0; i < 5; i++) {
this.sendAudioFrame(SILENCE_FRAME);
this.sendAudioFrame(SILENCE_FRAME, this.frameSize);
}
}
this.playing = false;
Expand Down Expand Up @@ -805,7 +806,7 @@ class VoiceConnection extends EventEmitter {
return this.stopPlaying();
}

this.sendAudioFrame(this.current.buffer);
this.sendAudioFrame(this.current.buffer, this.current.options.frameSize);
this.current.playTime += this.current.options.frameDuration;
this.current.timeout = setTimeout(this._send, this.current.startTime + this.current.pausedTime + this.current.playTime - Date.now());
}
Expand Down

0 comments on commit 7c39e1a

Please sign in to comment.