mirror of
https://github.com/danbulant/discord.js
synced 2026-05-26 05:22:15 +00:00
Add an extra range check to the volume transformer, should hopefully fix #193
This commit is contained in:
parent
0e54d77025
commit
d48458b80f
2 changed files with 14 additions and 0 deletions
|
|
@ -47,6 +47,13 @@ var Volume = (function (_Transform) {
|
|||
var out = new Buffer(buffer.length);
|
||||
|
||||
for (var i = 0; i < buffer.length; i += 2) {
|
||||
// Check whether the index is actually in range - sometimes it's possible
|
||||
// that it skips ahead too far before the end condition of the for can
|
||||
// kick in.
|
||||
if (i >= buffer.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Read Int16, multiple with multiplier and round down
|
||||
//console.log(this.volume, this.multiplier, buffer.readInt16LE(i));
|
||||
var uint = Math.floor(this.multiplier * buffer.readInt16LE(i));
|
||||
|
|
|
|||
|
|
@ -44,6 +44,13 @@ class Volume extends Transform {
|
|||
let out = new Buffer(buffer.length);
|
||||
|
||||
for (let i = 0; i < buffer.length; i += 2) {
|
||||
// Check whether the index is actually in range - sometimes it's possible
|
||||
// that it skips ahead too far before the end condition of the for can
|
||||
// kick in.
|
||||
if (i >= buffer.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Read Int16, multiple with multiplier and round down
|
||||
//console.log(this.volume, this.multiplier, buffer.readInt16LE(i));
|
||||
let uint = Math.floor(this.multiplier * buffer.readInt16LE(i));
|
||||
|
|
|
|||
Loading…
Reference in a new issue