mirror of
https://github.com/danbulant/discord.js
synced 2026-06-18 22:21:17 +00:00
parent
6bc2750f3d
commit
6b5f4fa773
4 changed files with 40 additions and 34 deletions
|
|
@ -122,17 +122,17 @@ var AudioEncoder = (function () {
|
|||
};
|
||||
|
||||
AudioEncoder.prototype.hookEncodingProcess = function hookEncodingProcess(resolve, reject, enc, stream) {
|
||||
var _this4 = this;
|
||||
|
||||
var processKilled = false;
|
||||
|
||||
function killProcess() {
|
||||
function killProcess(cause) {
|
||||
if (processKilled) return;
|
||||
|
||||
enc.stdin.pause();
|
||||
enc.kill("SIGINT");
|
||||
enc.kill("SIGKILL");
|
||||
|
||||
processKilled = true;
|
||||
|
||||
reject(cause);
|
||||
}
|
||||
|
||||
var ffmpegErrors = "";
|
||||
|
|
@ -143,10 +143,12 @@ var AudioEncoder = (function () {
|
|||
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
|
||||
});
|
||||
|
||||
enc.stdout.on("end", function () {
|
||||
killProcess();
|
||||
enc.stdout.once("end", function () {
|
||||
killProcess("end");
|
||||
});
|
||||
|
||||
reject("end");
|
||||
enc.stdout.once("error", function () {
|
||||
enc.stdout.emit("end");
|
||||
});
|
||||
|
||||
enc.once("exit", function (code, signal) {
|
||||
|
|
@ -170,21 +172,19 @@ var AudioEncoder = (function () {
|
|||
});
|
||||
|
||||
this.volume.once("end", function () {
|
||||
killProcess();
|
||||
killProcess("end");
|
||||
});
|
||||
|
||||
reject("end");
|
||||
this.volume.once("error", function () {
|
||||
killProcess("end");
|
||||
});
|
||||
|
||||
this.volume.on("end", function () {
|
||||
killProcess();
|
||||
|
||||
reject("end");
|
||||
killProcess("end");
|
||||
});
|
||||
|
||||
this.volume.on("close", function () {
|
||||
killProcess();
|
||||
|
||||
reject("close");
|
||||
killProcess("close");
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ var VoiceConnection = (function (_EventEmitter) {
|
|||
}
|
||||
if (this.streamProc) {
|
||||
this.streamProc.stdin.pause();
|
||||
this.streamProc.kill("SIGINT");
|
||||
this.streamProc.kill("SIGKILL");
|
||||
this.streamProc = null;
|
||||
}
|
||||
};
|
||||
|
|
@ -156,6 +156,7 @@ var VoiceConnection = (function (_EventEmitter) {
|
|||
}
|
||||
if (!self.playingIntent || !self.playing) {
|
||||
self.setSpeaking(false);
|
||||
self.stopPlaying();
|
||||
retStream.emit("end");
|
||||
return;
|
||||
}
|
||||
|
|
@ -166,6 +167,7 @@ var VoiceConnection = (function (_EventEmitter) {
|
|||
if (!buffer) {
|
||||
if (onWarning) {
|
||||
self.setSpeaking(false);
|
||||
self.stopPlaying();
|
||||
retStream.emit("end");
|
||||
return;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -114,28 +114,32 @@ export default class AudioEncoder {
|
|||
hookEncodingProcess(resolve, reject, enc, stream) {
|
||||
var processKilled = false;
|
||||
|
||||
function killProcess() {
|
||||
function killProcess(cause) {
|
||||
if (processKilled)
|
||||
return;
|
||||
|
||||
enc.stdin.pause();
|
||||
enc.kill("SIGINT");
|
||||
enc.kill("SIGKILL");
|
||||
|
||||
processKilled = true;
|
||||
|
||||
reject(cause);
|
||||
}
|
||||
|
||||
var ffmpegErrors = "";
|
||||
|
||||
enc.stdout.pipe(this.volume);
|
||||
|
||||
enc.stderr.on("data", (data) => {
|
||||
enc.stderr.on("data", function (data) {
|
||||
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
|
||||
});
|
||||
|
||||
enc.stdout.on("end", () => {
|
||||
killProcess();
|
||||
enc.stdout.once("end", () => {
|
||||
killProcess("end");
|
||||
});
|
||||
|
||||
reject("end");
|
||||
enc.stdout.once("error", () => {
|
||||
enc.stdout.emit("end");
|
||||
});
|
||||
|
||||
enc.once("exit", (code, signal) => {
|
||||
|
|
@ -144,10 +148,10 @@ export default class AudioEncoder {
|
|||
}
|
||||
});
|
||||
|
||||
this.volume.once("readable", () => {
|
||||
this.volume.once("readable", function () {
|
||||
var data = {
|
||||
proc: enc,
|
||||
stream: this.volume,
|
||||
stream: _this4.volume,
|
||||
channels: 2
|
||||
};
|
||||
|
||||
|
|
@ -159,21 +163,19 @@ export default class AudioEncoder {
|
|||
});
|
||||
|
||||
this.volume.once("end", () => {
|
||||
killProcess();
|
||||
|
||||
reject("end");
|
||||
killProcess("end");
|
||||
});
|
||||
|
||||
this.volume.on("end", () => {
|
||||
killProcess();
|
||||
this.volume.once("error", () => {
|
||||
killProcess("end");
|
||||
})
|
||||
|
||||
reject("end");
|
||||
this.volume.on("end", () => {
|
||||
killProcess("end");
|
||||
});
|
||||
|
||||
this.volume.on("close", () => {
|
||||
killProcess();
|
||||
|
||||
reject("close");
|
||||
killProcess("close");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ export default class VoiceConnection extends EventEmitter {
|
|||
}
|
||||
if (this.streamProc) {
|
||||
this.streamProc.stdin.pause();
|
||||
this.streamProc.kill("SIGINT");
|
||||
this.streamProc.kill("SIGKILL");
|
||||
this.streamProc = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -118,6 +118,7 @@ export default class VoiceConnection extends EventEmitter {
|
|||
}
|
||||
if (!self.playingIntent || !self.playing) {
|
||||
self.setSpeaking(false);
|
||||
self.stopPlaying();
|
||||
retStream.emit("end");
|
||||
return;
|
||||
}
|
||||
|
|
@ -128,6 +129,7 @@ export default class VoiceConnection extends EventEmitter {
|
|||
if (!buffer) {
|
||||
if (onWarning) {
|
||||
self.setSpeaking(false);
|
||||
self.stopPlaying();
|
||||
retStream.emit("end");
|
||||
return;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue