apu: Opus packets decoded by a thread of the connection, not in the title's call #535
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!535
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-535"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@cerealfordinner on GitHub · 2026-12-04 23:29 UTC · original
cerealfordinner:upstream-pr-opus-thread→main· +205 −52 · 1 files · 1 commits · closed without mergingDecodes Opus packets on a thread of the connection instead of in the title's call, so decoding doesn't run on the title's thread.
cargo check -p victory-hle --lib --target x86_64-pc-windows-gnu: clean.Note: overlaps the Opus work in open PRs #508 and #497 — flagging in case they'd rather land first; happy to rebase or close if it duplicates.
Signed-off-by: cerealfordinner [email protected]
@kromka45 on GitHub · 2026-12-05 00:08 UTC · original
good pr i feel like the sound is finally there...there huge upgrade in ms
@Kal0s-design on GitHub · 2026-12-05 00:18 UTC · original
Checked
a1f7369on native Windows with MSVC (didn't run the game).victory-hle lib tests pass 162/162 (1 ignored) on the PR, five runs with --test-threads=2, same as main. Clippy with and without
--features diagnosticsgives the same warnings as main, nothing new in apu.rs.I also ran a throwaway test against both. It used 480 real Opus packets on two streams, queued in bursts up to QUEUE_FULL. Results came back in order, both counters went up by one each time, the PCM matched main's synchronous decode byte for byte and every output was already filled when its result appeared. A bad packet still came back as BAD_PACKET with its neighbours fine. With SIGNAL only on the last of 15 commands, all 15 results were there once the event fired. Disconnecting with 60 commands queued, before or partway through decoding, never wrote anything after XApuDisconnect returned.
From the code, the result is pushed only after the PCM is written, under the mutex the title's dequeue takes (apu.rs:373-376). SetEvent comes after that, still only for SIGNAL (377-381). It doesn't need #455's
is_frontsignal, because with one thread and one FIFO a signalled result can never sit behind an unfinished one. Disconnect joins the thread before freeing anything and drops queued commands (297-300, 362). Deactivate and reset cancel nothing, earlier queued packets still decode and write, so a title would only get a late write if it freed an output buffer before dequeuing its result. One decoder set and one queue per connection keeps order and Opus state. The thread waits on a condvar when idle and there is only one mutex.Things to consider
This and #455 do the same job and conflict in apu.rs, so only one should land. This one is smaller, strict FIFO, joins on disconnect instead of a 5 s wait and leak, and adds no extra signals. #455 has the switch, a thread pool and higher priority. The reused
pcmbuffer (471) covers #508, which also conflicts. #497 is in dsp and merges cleanly with this.AI-assisted: yes
github-bot referenced this pull request2026-12-06 00:27:01 +00:00
Pull request closed