Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion discord/voice/receive/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def decrypt_rtp(self, packet: RTPPacket) -> bytes:
raw_payload,
)
# Successfully decrypted - cache the mapping for next time
self.client._connection.user_ssrc_map[int_uid] = packet.ssrc
self.client._connection.ssrc_user_map[packet.ssrc] = int_uid
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VoiceConnectionState.ssrc_user_map is a computed @property (return {v: k for k, v in self.user_ssrc_map.items()} in discord/voice/state.py), so mutating it here (ssrc_user_map[packet.ssrc] = int_uid) updates a temporary dict and does not persist. This means the cache will still miss on the next packet and the brute-force get_user_ids() scan will continue every time. To make caching effective, write to the canonical backing map (state.user_ssrc_map[int_uid] = packet.ssrc), or introduce a persistent SSRC→user_id map in the connection state and update that instead of the derived property.

Suggested change
self.client._connection.ssrc_user_map[packet.ssrc] = int_uid
self.client._connection.user_ssrc_map[int_uid] = packet.ssrc

Copilot uses AI. Check for mistakes.
uid = int_uid
raw_payload = decrypted_audio
_log.debug(
Expand All @@ -299,6 +299,10 @@ def decrypt_rtp(self, packet: RTPPacket) -> bytes:
break
except ValueError:
continue
else:
# All candidates failed to decrypt; return silence to avoid
# passing encrypted audio data downstream.
return OPUS_SILENCE
elif uid:
try:
raw_payload = dave.decrypt(
Expand Down
Loading