mirror of
https://github.com/discordjs/discord.js.git
synced 2026-06-16 11:28:18 +00:00
Added Opus stream support, added volume interface (#1102)
* Added opus stream support, added volume interface * Remove setImmediate * Fix weird syntax error * Most useless commit ever You're welcome, @PgBiel * Fix potential memory leak with OpusScript Emscripten has the tendency to not free resources even when the Opus engine instance has been garbage collected. Thanks to @abalabahaha for pointing this out. * Typo * VoiceReceiver.destroy: destroy opus encoder
This commit is contained in:
@@ -10,6 +10,10 @@ class BaseOpus {
|
||||
decode(buffer) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BaseOpus;
|
||||
|
||||
@@ -20,5 +20,9 @@ exports.fetch = () => {
|
||||
const fetched = fetch(encoder);
|
||||
if (fetched) return fetched;
|
||||
}
|
||||
throw new Error('Couldn\'t find an Opus engine.');
|
||||
return null;
|
||||
};
|
||||
|
||||
exports.guaranteeOpusEngine = () => {
|
||||
if (!this.opusEncoder) throw new Error('Couldn\'t find an Opus engine.');
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ const OpusEngine = require('./BaseOpusEngine');
|
||||
|
||||
let OpusScript;
|
||||
|
||||
class NodeOpusEngine extends OpusEngine {
|
||||
class OpusScriptEngine extends OpusEngine {
|
||||
constructor(player) {
|
||||
super(player);
|
||||
try {
|
||||
@@ -22,6 +22,11 @@ class NodeOpusEngine extends OpusEngine {
|
||||
super.decode(buffer);
|
||||
return this.encoder.decode(buffer);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
super.destroy();
|
||||
this.encoder.delete();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NodeOpusEngine;
|
||||
module.exports = OpusScriptEngine;
|
||||
|
||||
Reference in New Issue
Block a user