More voice fixes

* More voice fixes

* Start socket reader paused and wait for socket creation

* Fix issues handling 4014 closures

Fixes code not handling disconnects from discord's end properly.  The
4014 code is shared between being disconnected and moved, so it has to
account for the uncertainty.  Also properly stops the voice_client audio
player when disconnecting.

* Fix sending (dropped) silence packets when not connected
This commit is contained in:
Imayhaveborkedit
2024-04-18 03:36:18 -04:00
committed by GitHub
parent dc6d33c303
commit b8c29b0790
3 changed files with 60 additions and 19 deletions

View File

@ -337,7 +337,7 @@ class VoiceClient(VoiceProtocol):
Disconnects this voice client from voice.
"""
self.stop()
await self._connection.disconnect(force=force)
await self._connection.disconnect(force=force, wait=True)
self.cleanup()
async def move_to(self, channel: Optional[abc.Snowflake], *, timeout: Optional[float] = 30.0) -> None:
@ -567,6 +567,6 @@ class VoiceClient(VoiceProtocol):
try:
self._connection.send_packet(packet)
except OSError:
_log.info('A packet has been dropped (seq: %s, timestamp: %s)', self.sequence, self.timestamp)
_log.debug('A packet has been dropped (seq: %s, timestamp: %s)', self.sequence, self.timestamp)
self.checked_add('timestamp', opus.Encoder.SAMPLES_PER_FRAME, 4294967295)