Audio capture: wait for the engine's event, buffer the writes, raise the recorder's priority #4725
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4725
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4724"
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?
@kkrlock on GitHub · 2026-12-01 03:39 UTC · original
kkrlock:fix/audio-capture-drops→main· +110 −13 · 1 files · 1 commits · openWhat it changes
VICTORY_AUDIO_CAPTURErecorded silence where the title played audio. In a 12-minute capture 22 to 24% of the file was exact zeros, in stretches of whole 10 ms periods (peaks at exactly 480, 960 and 1440 frames), one every 80 to 110 ms, the longest 725 ms. Anyone reading such a capture for dropouts finds thousands of them, and none belong to the title.The cause is in
record(). It slept 10 ms between drains while the process loopback's own buffer holds a few periods, it wrote every packet straight to disk with an unbufferedFile::write_all, and it ran at normal thread priority. Under the title's load a drain comes late, the loopback buffer wraps, and the packets for that period are gone. What is left is a jump in the timestamps, which the code already fills with silence, so the file reads as if the title played nothing.Four changes:
AUDCLNT_STREAMFLAGS_EVENTCALLBACKandSetEventHandle) instead of sleeping a whole period between drains. The wait has a 200 ms timeout, so the title is still polled and the header still patched while nothing arrives.BufWriter.THREAD_PRIORITY_HIGHEST.missedis a packet that never arrived,silentis a packet that arrived marked silent. Only the first is a recorder bug, so a capture cannot be judged without the split.VICTORY_AUDIO_TONE=1makes the recorder play a constant 1 kHz sine from its own process, which is inside the process tree the loopback records. That is the reference used below, and it can be used any time to check a capture before trusting it.Nothing the title does changes, and nothing is built outside the diagnostics feature.
How it was tested
GPU and profile: RTX 5060 8 GB, Ryzen 5 5600X, 32 GB, Windows 11. Series S, 540p internal to a 1080p output, DLSS performance, frame generation 5X, ray tracing off. The title runs at 10-12 fps under that load.
Method: the recorder plays the 1 kHz sine and records it with the same process loopback. The sine cannot have a gap of its own, so any gap in the recording is the recorder's. Measured as the exact-zero fraction of the file, and as the 1 kHz band envelope (FFT around 1 kHz, 128-sample blocks). Same save, same protocol, the title parked in the same car, for every run.
Before, three runs: 22.38%, 23.60%, 23.25% exact zeros.
After, four runs: 0.19%, 0.08%, 0.09%, 0.18% exact zeros.
The recorder's own counters agree with the files, and put the remainder on this side:
silentcounts packets that arrived marked silent, which would mean the tone underran. It was 0 in every run.No listening comparison: this changes no audio the title plays, only what the recorder writes.
For shader changes, the wave sizes tested: not a shader change.
cargo test: not run.cargo check --profile diag -p victory --features diagnosticspasses on this branch, rebased ontomain. The capture module has no unit tests onmainand this change adds none.One machine, non-blinded, three runs before and four after. The 23% figure needs the title busy enough that a drain is late; where it is never late, the bug does not show.
Checked for overlap
crates/victory-hle/src/modules/audio/capture.rshas one commit onmain, the one that added it, and no pull request changes it. #2799 mentionsVICTORY_AUDIO_CAPTUREin its list of settings that write game data outside the repo; it does not change this file.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.