feat: libdave support#3222
Merged
Merged
Conversation
Misha-133
reviewed
Jan 5, 2026
Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>
…et/Discord.Net into voice/big-dave-support
Misha-133
approved these changes
Jan 5, 2026
Member
Author
|
It might be a good idea to expose either the |
MrCakeSlayer
approved these changes
Jan 6, 2026
Contributor
|
Will test this out this weekend Update: weekend arrived, so far successful testing. Flood of debug output from logs, about 50 per second of "Buffer under run". Buffer under run |
Misha-133
reviewed
Jan 30, 2026
Contributor
|
Hi, please take a look at the the PR I created to be merged into this branch: #3241 |
…t layer on early streams (#3241) * Fix SelectProtocol sending local port instead of external port The UDP discovery response from Discord contains the external IP and port as seen by the voice server. SendSelectProtocol was passing UdpPort (the local socket port) instead of the external port from the discovery packet. Behind NAT, these differ, causing the voice server to send audio to the wrong port. Extract the external port from bytes 72-73 of the discovery response and pass it to SendSelectProtocol alongside the external IP. * Rebuild input streams after initial DAVE key exchange When a user joins a voice channel, SocketGuild.RepopulateAudioStreamsAsync fires StreamCreated before AudioClient.OnConnectingAsync initializes the DaveSessionManager. This means input streams are created without the DaveDecryptStream layer in the pipeline. Once the MLS key exchange completes and the initial transition fires, the encrypted audio reaches OpusDecodeStream directly — causing InvalidPacket errors since the data is still DAVE-encrypted. Add RebuildInputStreamsForDaveAsync to AudioClient which tears down existing streams and recreates them with the DaveDecryptStream layer. Call it from DaveSessionManager.PrepareProtocolTransitionAsync when the initial transition (transitionId == InitTransitionId) completes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds
libdavesupport into the audio client, as well as some small audio client refractors.Remarks
A new project,
Discord.Net.Davewas created in thetools/folder that provides the low level bindings (libdaveclass) and some higher level wrappers around them (Dave,DaveSession, etc).Since this is a low level binding, manual memory management is required, the current allocs/FFI boundaries should be investigated for any leaking memory.
Notice on breaking changes
This PR is implemented in a way to prevent breaking change,
libdavee2ee support is gated behind a new configuration optionEnableVoiceDaveEncryptionwithin the socket config. The default value for the new configuration option isfalse, so users will have to opt-in tolibdavesupport. This is up for discussion as Discord plans to requirelibdavee2ee by march.I don't know how we want to distribute
libdavealong with dnet when it becomes required, do we bundle builds in with the WS project? I'm happy for feedback on this.If you have an app with audio functionality, It'd be great if you can test this PR and report any bugs you find with it.