fix(Voice*): filter out silent audio from video users #5035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please describe the changes this PR makes and why it should be merged:
Problem:
This resolves #5019. When a user has video enabled, they send silent audio frames continually even if they are not speaking. Discord.js didn't check whether a received audio packet was silence or not for performance reasons. This shortcut is no longer applicable since it causes the incorrect behaviour described in the issue above.
Fix:
Instead of decoding all the received packets, we only decode the packets from users with video enabled (which is where the issue occurs). If a packet is received from such a user and it turns out to be silent audio, the packet is ignored which is a graceful fix for this issue. This means performance will only degrade (and even then, I doubt it will be by a lot) in cases where a bot is in the same voice channel as users with video enabled, and the bot is actively receiving audio.
Status
Semantic versioning classification: