Skip to content

Commit bdba6a4

Browse files
committed
feat: Gracefully handle OpusError s
1 parent c48341e commit bdba6a4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

discord/opus.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,15 @@ def _decode_packet(self, packet: Packet) -> tuple[Packet, bytes]:
708708

709709
if packet:
710710
other_code = False
711-
pcm = self._decoder.decode(packet.decrypted_data, fec=False)
711+
try:
712+
pcm = self._decoder.decode(packet.decrypted_data, fec=False)
713+
except OpusError:
714+
_log.warning(
715+
"Opus decode failed for packet seq=%s, using PLC",
716+
packet.sequence,
717+
exc_info=True,
718+
)
719+
pcm = self._decoder.decode(None, fec=False)
712720

713721
if other_code:
714722
next_packet = self._buffer.peek_next()

0 commit comments

Comments
 (0)