8000 8000 fix(voice): keep audio alive across channel moves by jovolopez · Pull Request #603 · disgoorg/disgo · GitHub
[go: up one dir, main page]

Skip to content

fix(voice): keep audio alive across channel moves - #603

Open
jovolopez wants to merge 2 commits into
disgoorg:masterfrom
jovolopez:fix/voice-channel-move
Open

jovolopez wants to merge 2 commits into
disgoorg:masterfrom
jovolopez:fix/voice-channel-move

Conversation

@jovolopez
Copy link
Copy Markdown
Contributor

When a bot is moved from one channel to another, it often disconnects, and sometimes it simply remains silent (waiting for the DAVE session to be ready). These problems are solved with these two changes:

Rebuild voice transports when moving between channels and ignore stale callbacks
A channel move was reusing the old Gateway/UDP/DAVE generation and stale SSRC entries carried over from the old channel, so a late Ready/SessionDescription or speaking event could revive the old epoch and drop the new handshake. On moved VoiceStateUpdate the generation is now replaced via resetTransportsLocked() under stateMu and callbacks from previous gateways are dropped. SpeakingFlags are saved in SetSpeaking and restored after SessionDescription.

Wait for the fresh VoiceStateUpdate + VoiceServerUpdate pair instead of closing immediately on 4014/4022
A move can surface as a gateway close. The same thing I make in the PR #583, only without the massive fallback. I'm uploading it here because it's necessary for the complete fix to work; otherwise, the gateway ends up closing in many cases.

Replace stale gateway, UDP, and DAVE transports after a move, ignore
callbacks from old generations, and restore speaking after the new
handshake.
Discord sends these close codes both for a real disconnect and for a channel move. Closing the conn here loses the VoiceStateUpdate/VoiceServerUpdate pair that follows a move, so leave the conn alive and let those events decide.
@jovolopez
jovolopez force-pushed the fix/voice-channel-move branch from 2f50e6a to e85d45f Compare November 11, 2026 02:24
@jovolopez
Copy link
Copy Markdown
Contributor Author

Let me know if you need me to clarify anything in order to proceed with the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant

0