mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
maybe fix again
This commit is contained in:
@@ -39,6 +39,11 @@ class VoiceConnection extends EventEmitter {
|
|||||||
|
|
||||||
this.player = new AudioPlayer(this);
|
this.player = new AudioPlayer(this);
|
||||||
|
|
||||||
|
this.player.on('error', e => {
|
||||||
|
this.emit('warn', e);
|
||||||
|
this.player.cleanup();
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object that wraps contains the `ws` and `udp` sockets of this voice connection
|
* Object that wraps contains the `ws` and `udp` sockets of this voice connection
|
||||||
* @type {object}
|
* @type {object}
|
||||||
|
|||||||
@@ -23,12 +23,18 @@ class AudioPlayer extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
playUnknownStream(stream) {
|
playUnknownStream(stream) {
|
||||||
|
stream.on('end', () => {
|
||||||
|
|
||||||
|
console.log(Date.now(), 'real input stream ended');
|
||||||
|
})
|
||||||
const conversionProcess = this.audioToPCM.createConvertStream(0);
|
const conversionProcess = this.audioToPCM.createConvertStream(0);
|
||||||
stream.pipe(conversionProcess.process.stdin, { end: false });
|
stream.pipe(conversionProcess.process.stdin, { end: false });
|
||||||
return this.playPCMStream(conversionProcess.process.stdout, conversionProcess);
|
return this.playPCMStream(conversionProcess.process.stdout, conversionProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup(checkStream) {
|
cleanup(checkStream) {
|
||||||
|
// cleanup is a lot less aggressive than v9 because it doesn't try to kill every single stream it is aware of
|
||||||
|
console.log(Date.now(), 'clean up triggered');
|
||||||
const filter = checkStream && this.currentDispatcher && this.currentDispatcher.stream === checkStream;
|
const filter = checkStream && this.currentDispatcher && this.currentDispatcher.stream === checkStream;
|
||||||
if (this.currentConverter && (checkStream ? filter : true)) {
|
if (this.currentConverter && (checkStream ? filter : true)) {
|
||||||
if (this.currentConverter.process.stdin.destroy) {
|
if (this.currentConverter.process.stdin.destroy) {
|
||||||
@@ -42,6 +48,10 @@ class AudioPlayer extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
playPCMStream(stream, converter) {
|
playPCMStream(stream, converter) {
|
||||||
|
stream.on('end', () => {
|
||||||
|
|
||||||
|
console.log(Date.now(), 'pcm input stream ended');
|
||||||
|
})
|
||||||
this.cleanup();
|
this.cleanup();
|
||||||
this.currentConverter = converter;
|
this.currentConverter = converter;
|
||||||
if (this.currentDispatcher) {
|
if (this.currentDispatcher) {
|
||||||
|
|||||||
Reference in New Issue
Block a user