improve: fix desynced buffers issue, improved the performance and dave op codes support. #4
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.
Changes
Added an _ownedSSRCs Set into the connection class, which tracks and deletes the SSRc entries from the global ssrcs object to prevent memory leaks.
replaced Buffer.alloc with Buffer.allocUnsafe for hot paths where the data is immediately overwritten
made 'sendAudioChunk' re-use the packetBuffer for rtp headers, preventing more allocations.
Added support for some dave op codes (21, 22, 24, 25, 27, 28, 30, 31)
Fixed an issue where if you add 2 songs into a queue and skipped, the jitter buffer (Preferred) would go up to 520ms, making the audio stutter for 20 seconds, this commit fixes this issue
Why
As listed in the changes, this PR improves the general code performance, fixes a buffer desync issue, and prevents a memory leak.
Checkmarks
Additional information
Op codes from: https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice
Formatted with biome.
(again, i request an review from pedroo, i fr need to learn more stuff about this area :))