Finish WAV capture at the RIFF size limit #4991

Open
github-bot wants to merge 1 commit from github-bot/gh-4990 into main AGit
Owner

@⁠RanoGames on GitHub · 2026-12-01 16:46 UTC · original
RanoGames:fix/wav-riff-size-limit → main · +36 −9 · 1 files · 1 commits · open

What it changes

The diagnostics recorder writes 48 kHz stereo PCM with four bytes per frame. After about 6 h 13 min the PCM payload still fits a u32, but adding the 36 bytes counted by the RIFF chunk size overflows. Longer recordings can continue past the length their WAV header describes.

Finish at the last whole PCM frame representable by RIFF, including when a timestamp gap consumes the remaining space. Release the full WASAPI packet and write the final header before returning. Stream silence for gaps in bounded chunks.

How it was tested

  • Windows x64, synthetic header sizes on either side of the RIFF boundary. On base 5fabb46e the extracted header function panicked on integer overflow. On 7a922141 the RIFF and data lengths matched the last whole frame.
  • cargo test --locked -p victory-hle --features diagnostics --lib modules::audio::capture::tests passed (1 test).
  • cargo clippy --locked -p victory-hle --lib --features diagnostics --no-deps -- -D warnings passed. No six-hour hardware recording or game run was performed.

Checked for overlap

  • Searched open and closed issues and PRs for RIFF, WAV overflow and VICTORY_AUDIO_CAPTURE, and reviewed changes to the recorder. #4725 addresses recorder scheduling and #4825 addresses unreliable WASAPI timestamps. Both retain the original RIFF length calculation.
**@⁠RanoGames** on GitHub · 2026-12-01 16:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4990) `RanoGames:fix/wav-riff-size-limit` → `main` · +36 −9 · 1 files · 1 commits · open ## What it changes The diagnostics recorder writes 48 kHz stereo PCM with four bytes per frame. After about 6 h 13 min the PCM payload still fits a `u32`, but adding the 36 bytes counted by the RIFF chunk size overflows. Longer recordings can continue past the length their WAV header describes. Finish at the last whole PCM frame representable by RIFF, including when a timestamp gap consumes the remaining space. Release the full WASAPI packet and write the final header before returning. Stream silence for gaps in bounded chunks. ## How it was tested - Windows x64, synthetic header sizes on either side of the RIFF boundary. On base `5fabb46e` the extracted header function panicked on integer overflow. On `7a922141` the `RIFF` and `data` lengths matched the last whole frame. - `cargo test --locked -p victory-hle --features diagnostics --lib modules::audio::capture::tests` passed (1 test). - `cargo clippy --locked -p victory-hle --lib --features diagnostics --no-deps -- -D warnings` passed. No six-hour hardware recording or game run was performed. ## Checked for overlap - [x] Searched open and closed issues and PRs for RIFF, WAV overflow and `VICTORY_AUDIO_CAPTURE`, and reviewed changes to the recorder. #4725 addresses recorder scheduling and #4825 addresses unreliable WASAPI timestamps. Both retain the original RIFF length calculation.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 16:51:40 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-12-01 17:33 UTC · original

Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree.

Base 5fabb46eaf6ed8771321787f8871051abde69b9b, head 7a92214160437d0b17cecd7e5af2d2f5de3c44ad. git diff --numstat → crates/victory-hle/src/modules/audio/capture.rs 36/9.

The test is new on the base (git grep -F wav_sizes_stop_at_the_last_whole_frame_that_fits_riff 5fabb46e -- . → no match, exit 1).

One build note, because it costs a run: capture is declared #[cfg(all(windows, feature = "diagnostics"))] (modules/audio.rs:28), so without --features diagnostics the module is not compiled and cargo test -p victory-hle --lib -- --list shows no such test at all — a silent absence, not a failure.

git diff --check "5fabb46e..7a922141" → no output, exit 0.

$env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-4990'
cargo test --locked -p victory-hle --lib --features diagnostics -- modules::audio::capture::tests::wav_sizes_stop_at_the_last_whole_frame_that_fits_riff --exact --test-threads=1 --quiet

Result: running 1 test, test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 482 filtered out.

What it pins: header(frames) for 1, max_frames-1, max_frames, max_frames+1 and max_frames+10 with max_frames = (u32::MAX - 36) / FRAME_BYTES, asserting the data chunk is min(frames, max_frames) * FRAME_BYTES and that the RIFF size is 36 + data. Pure header arithmetic, no file written, no audio device opened; GPU/driver N/A. No game data.

**@⁠cloph-dsp** on GitHub · 2026-12-01 17:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4990#issuecomment-7319493307) Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree. Base `5fabb46eaf6ed8771321787f8871051abde69b9b`, head `7a92214160437d0b17cecd7e5af2d2f5de3c44ad`. `git diff --numstat` → crates/victory-hle/src/modules/audio/capture.rs 36/9. The test is new on the base (`git grep -F wav_sizes_stop_at_the_last_whole_frame_that_fits_riff 5fabb46e -- .` → no match, exit 1). One build note, because it costs a run: `capture` is declared `#[cfg(all(windows, feature = "diagnostics"))]` (modules/audio.rs:28), so without `--features diagnostics` the module is not compiled and `cargo test -p victory-hle --lib -- --list` shows no such test at all — a silent absence, not a failure. `git diff --check "5fabb46e..7a922141"` → no output, exit 0. ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-4990' cargo test --locked -p victory-hle --lib --features diagnostics -- modules::audio::capture::tests::wav_sizes_stop_at_the_last_whole_frame_that_fits_riff --exact --test-threads=1 --quiet ``` Result: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 482 filtered out`. What it pins: `header(frames)` for 1, max_frames-1, max_frames, max_frames+1 and max_frames+10 with `max_frames = (u32::MAX - 36) / FRAME_BYTES`, asserting the data chunk is `min(frames, max_frames) * FRAME_BYTES` and that the RIFF size is `36 + data`. Pure header arithmetic, no file written, no audio device opened; GPU/driver N/A. No game data.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4991/head:github-bot/gh-4990'
git switch 'github-bot/gh-4990'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4990'
git switch 'github-bot/gh-4990'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4990'
git switch 'github-bot/gh-4990'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4990'
git switch 'main'
git merge --squash 'github-bot/gh-4990'
git switch 'main'
git merge --ff-only 'github-bot/gh-4990'
git switch 'main'
git merge 'github-bot/gh-4990'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4991
No description provided.