fix(voice): keep the first packets of a speaker until Discord names them

Discord names a speaker's SSRC in the Speaking op only the first time
they speak, and the op arrives after their first UDP packets. songbird
0.6.1 dropped the DAVE packets it could not decrypt yet, so the first
~100 ms of the first thing each person said after a join were lost
(live 2026-11-18: "자비스 서울 날씨 어때" arrived as "아비 서울날씨
어때", and the first call after the 01:20 start as "아비스").

songbird is vendored in app/vendor/songbird with one patch: packets of
an unnamed SSRC are held (1 s, 50 packets each, 32 SSRCs) and processed
in arrival order once it is named, and the Speaking event is sent before
the SSRC is named so handlers know the speaker first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-18 16:15:07 +09:00
parent 88ee5ec2cb
commit 81d1e26f61
123 changed files with 20119 additions and 5 deletions

View File

@@ -135,7 +135,14 @@ and the late "left" update cancelled the new join (seen on real Discord).
- **Hearing**: songbird only decrypts (transport and DAVE). Its own Opus decoding is not used: in
songbird 0.6.1 it decodes the payload without trimming what DAVE decryption left at its end, which
garbled, repeated or dropped about a third of the frames (measured with a test tone that changes
pitch every 20 ms). The core takes each decrypted RTP packet with songbird's exact payload bounds:
pitch every 20 ms). Discord names a speaker's SSRC (its Speaking op, over the websocket) only the
first time they speak, after their first packets arrive over UDP; songbird dropped the DAVE packets
it could not yet decrypt, which cut the first ~100 ms off the first thing each person said after a
join (live 2026-11-18: "자비스" heard as "아비"). The app therefore uses songbird 0.6.1 with a patch
(`app/vendor/songbird`, `JARVIS-PATCH.md`): packets of an SSRC not named yet are held, at most one
second and 50 packets for each of at most 32 SSRCs, and processed in arrival order once it is named;
the Speaking event goes out first, so the core knows the speaker before their held packets come.
The core takes each decrypted RTP packet with songbird's exact payload bounds:
- Packets go through a per-speaker reorder window in sequence-number order. A missing packet is
waited for until two later packets have arrived (about 40 ms), then rebuilt from the next packet's
Opus in-band FEC (the last missing frame) or concealed (any earlier ones). Late and duplicate