mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
Add an extra range check to the volume transformer, should hopefully fix #193
This commit is contained in:
@@ -47,6 +47,13 @@ var Volume = (function (_Transform) {
|
|||||||
var out = new Buffer(buffer.length);
|
var out = new Buffer(buffer.length);
|
||||||
|
|
||||||
for (var i = 0; i < buffer.length; i += 2) {
|
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
|
// Read Int16, multiple with multiplier and round down
|
||||||
//console.log(this.volume, this.multiplier, buffer.readInt16LE(i));
|
//console.log(this.volume, this.multiplier, buffer.readInt16LE(i));
|
||||||
var uint = Math.floor(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);
|
let out = new Buffer(buffer.length);
|
||||||
|
|
||||||
for (let i = 0; i < buffer.length; i += 2) {
|
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
|
// Read Int16, multiple with multiplier and round down
|
||||||
//console.log(this.volume, this.multiplier, buffer.readInt16LE(i));
|
//console.log(this.volume, this.multiplier, buffer.readInt16LE(i));
|
||||||
let uint = Math.floor(this.multiplier * buffer.readInt16LE(i));
|
let uint = Math.floor(this.multiplier * buffer.readInt16LE(i));
|
||||||
|
|||||||
Reference in New Issue
Block a user