Include ssrc parameter when sending a SPEAKING payload

As it is a required parameter.

Don't unnecessarily send a second SPEAKING payload after
connecting to voice

We do need to send a SPEAKING payload in order to set our SSRC value
after connecting to voice, yet that can be with a `state` of 0
(SpeakingState.none).

There is no reason to send 2 packets; one marking ourselves as
speaking, and then not speaking.
This commit is contained in:
Andrew Morgan 2023-03-14 07:18:23 +00:00 committed by GitHub
parent 08d668f21b
commit 8ba830eeb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -915,6 +915,7 @@ class DiscordVoiceWebSocket:
'd': {
'speaking': int(state),
'delay': 0,
'ssrc': self._connection.ssrc,
},
}
@ -990,7 +991,11 @@ class DiscordVoiceWebSocket:
async def load_secret_key(self, data: Dict[str, Any]) -> None:
_log.debug('received secret key for voice connection')
self.secret_key = self._connection.secret_key = data['secret_key']
await self.speak()
# Send a speak command with the "not speaking" state.
# This also tells Discord our SSRC value, which Discord requires
# before sending any voice data (and is the real reason why we
# call this here).
await self.speak(SpeakingState.none)
async def poll_event(self) -> None: