improve broadcasting performance

This commit is contained in:
Amish Shah
2016-12-30 15:25:28 +00:00
parent fb1d0a3e74
commit 3109accf87
2 changed files with 8 additions and 5 deletions

View File

@@ -169,11 +169,13 @@ class VoiceBroadcast extends EventEmitter {
buffer = this.applyVolume(buffer);
for (const x of this.dispatchers.entries()) {
const [volume, container] = x;
const opusPacket = this.opusEncoder.encode(this.applyVolume(buffer, volume));
for (const dispatcher of container.values()) {
setImmediate(() => dispatcher.process(buffer, true, opusPacket));
}
setImmediate(() => {
const [volume, container] = x;
const opusPacket = this.opusEncoder.encode(this.applyVolume(buffer, volume));
for (const dispatcher of container.values()) {
setImmediate(() => dispatcher.process(buffer, true, opusPacket));
}
});
}
}

View File

@@ -120,6 +120,7 @@ class StreamDispatcher extends EventEmitter {
}
setSpeaking(value) {
if (this.speaking === value) return;
this.speaking = value;
/**
* Emitted when the dispatcher starts/stops speaking