The title's own command line, and XMA2 source voices in XAudio2 #830

Open
0xkn0wh3r3 wants to merge 2 commits from upstream-pr/830 into main
0xkn0wh3r3 commented 2026-11-28 07:28:24 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 0xkn0wh3r3 on 2026-11-28T07:28:24Z.


Two gaps found by a stand-in title that checks the console runtime against what a retail Series X|S returns (vapordrive-probe: 100 checks, no game needed). Against main it matched 98 of 100 on both console models:

  • GetCommandLineW gave victory.exe's own line (victory run <exe> --execute ...). The C runtime's argv was already the title's, but a title that parses the command line itself, or takes WinMain's lpCmdLine, read our arguments instead of its own.
  • XMA2 source voices were refused (XAUDIO2_E_INVALID_CALL): xaudio2_9.dll passes through to the host's XAudio2, which has no XMA2.

What changes

  • kernel: GetCommandLineW/A, _get_wide/_get_narrow_winmain_command_line and __p__wcmdln/__p__acmdln give a line made from the same list as argv, quoted so the MSVC runtime parses it back to that list. The processenvironment api-set is now served by the kernel module (only these two functions; the rest still pass through).
  • New xaudio2 module: XAudio2Create (name and ordinal 1) and XAudio2CreateWithVersionInfo return the host's engine with a copy of its vtable in which CreateSourceVoice is ours. A one-stream (mono or stereo) XMA2 voice becomes a 16-bit PCM voice of the same channels and rate, and its SubmitSourceBuffer decodes each buffer with victory_formats::xma (the same frame walk as the decoder's reference tests), keeps play and loop regions inside the decoded length, and submits the PCM. Decoded buffers are freed once GetState says the host is done with them, or at DestroyVoice. Everything else, including the host's own virtual calls, reaches the host's functions.
  • Not yet: XMA2 with more than one stream (surround). Those voices are left to the host, as before.

Tested

  • cargo test -p victory-hle: all pass, with new tests for the command line (parsed back with the MSVC rules: quotes, backslashes before quotes, empty arguments, a program path with spaces) and the XMA2 format checks.
  • The ignored device test passes here: the host's engine makes an XMA2 voice, destroys it, and is released cleanly.
  • Clippy raises nothing in the changed code; cargo xtask policy passes.
  • The release build runs the probe as Series X and Series S: 100 of 100 on both, and the log shows the XMA2 voice made as PCM.
  • Not yet tried: decoding and playing a real title's XMA2 audio through XAudio2 (no XMA2 streams on this machine).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5537880656 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/830). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-28T07:28:24Z. --- Two gaps found by a stand-in title that checks the console runtime against what a retail Series X|S returns ([vapordrive-probe](https://github.com/0xkn0wh3r3/vapordrive): 100 checks, no game needed). Against `main` it matched 98 of 100 on both console models: - **`GetCommandLineW`** gave `victory.exe`'s own line (`victory run <exe> --execute ...`). The C runtime's argv was already the title's, but a title that parses the command line itself, or takes `WinMain`'s `lpCmdLine`, read our arguments instead of its own. - **XMA2 source voices** were refused (`XAUDIO2_E_INVALID_CALL`): `xaudio2_9.dll` passes through to the host's XAudio2, which has no XMA2. **What changes** - `kernel`: `GetCommandLineW/A`, `_get_wide/_get_narrow_winmain_command_line` and `__p__wcmdln/__p__acmdln` give a line made from the same list as argv, quoted so the MSVC runtime parses it back to that list. The processenvironment api-set is now served by the kernel module (only these two functions; the rest still pass through). - New `xaudio2` module: `XAudio2Create` (name and ordinal 1) and `XAudio2CreateWithVersionInfo` return the host's engine with a copy of its vtable in which `CreateSourceVoice` is ours. A one-stream (mono or stereo) XMA2 voice becomes a 16-bit PCM voice of the same channels and rate, and its `SubmitSourceBuffer` decodes each buffer with `victory_formats::xma` (the same frame walk as the decoder's reference tests), keeps play and loop regions inside the decoded length, and submits the PCM. Decoded buffers are freed once `GetState` says the host is done with them, or at `DestroyVoice`. Everything else, including the host's own virtual calls, reaches the host's functions. - Not yet: XMA2 with more than one stream (surround). Those voices are left to the host, as before. **Tested** - `cargo test -p victory-hle`: all pass, with new tests for the command line (parsed back with the MSVC rules: quotes, backslashes before quotes, empty arguments, a program path with spaces) and the XMA2 format checks. - The ignored device test passes here: the host's engine makes an XMA2 voice, destroys it, and is released cleanly. - Clippy raises nothing in the changed code; `cargo xtask policy` passes. - The release build runs the probe as Series X and Series S: 100 of 100 on both, and the log shows the XMA2 voice made as PCM. - Not yet tried: decoding and playing a real title's XMA2 audio through XAudio2 (no XMA2 streams on this machine).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/830:upstream-pr/830'
git switch 'upstream-pr/830'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/830'
git switch 'upstream-pr/830'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/830'
git switch 'upstream-pr/830'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/830'
git switch 'main'
git merge --squash 'upstream-pr/830'
git switch 'main'
git merge --ff-only 'upstream-pr/830'
git switch 'main'
git merge 'upstream-pr/830'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

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