runtime/shims: implement xapu.dll and chad.dll audio processor shims #277

Closed
github-bot wants to merge 1 commit from github-bot/gh-277 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:57 UTC · original
ubiquitarianism:old-pr/10008 → main · +375 −2 · 5 files · 1 commits · closed without merging

Carried over from old PR 10008 by piyonchu in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10008, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
This branch conflicts with the current main and needs a rebase.
piyonchu: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Clean-room shims for the remaining Xbox Series audio hardware DLLs: xapu.dll (5 imports) and chad.dll (5 imports), backed by static ABI inspection of all 13 call sites.

What changed

  • Added runtime/shims/xapu_chad.cpp with constant-initialized SRWLOCK session registries (0 _Init_thread_header TLS guards):
    • xapu.dll: XApuConnect, XApuDisconnect, XApuEnqueueCommand, XApuGetResultCount, XApuDequeueResult. Tracks valid queue handles and echoes FIFO 56-byte result packets (opcode, context_index, and output_bytes for decode commands) so callers advance context states and recycle slots cleanly, failing closed (HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS)) when empty and ERROR_INVALID_HANDLE on stale handles.
    • chad.dll: XDspConnectWithMaximumStreamLimit, XDspActivate, XDspDeactivate, XDspDisconnect, XDspSubmitCommand. Validates handle lifetime, max_streams > 0, and non-null command buffers; returns S_OK (0) so stream setup and command submission succeed cleanly.
  • Added xapu.dll and chad.dll ReturnClass::HResult entries to runtime/shims/registry.cpp.
  • Added unit tests runtime/test/xapu_chad_test.cpp and wired xapu_chad_test / xapu_chad.cpp in runtime/CMakeLists.txt and scripts/build_runtime.ps1.

Verification

  • Built xapu_chad_test (cmake --build runtime/build --target xapu_chad_test): 0 warnings.
  • ctest --test-dir runtime/build -R "^xapu_chad$" --output-on-failure: 1/1 passed.
  • dumpbin /symbols on xapu_chad.cpp.obj: 0 _Init_thread_header references.
  • python -m unittest tests/test_ctest_registration.py: 4/4 OK.
  • python scripts/check_no_game_data.py & git diff --check: clean.

Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116975037

**@⁠Andretuta** on GitHub · 2026-11-24 02:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/277) `ubiquitarianism:old-pr/10008` → `main` · +375 −2 · 5 files · 1 commits · closed without merging > Carried over from **old PR 10008** by `piyonchu` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10008`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > This branch conflicts with the current `main` and needs a rebase. > `piyonchu`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Clean-room shims for the remaining Xbox Series audio hardware DLLs: `xapu.dll` (5 imports) and `chad.dll` (5 imports), backed by static ABI inspection of all 13 call sites. ### What changed - Added [`runtime/shims/xapu_chad.cpp`](runtime/shims/xapu_chad.cpp) with constant-initialized `SRWLOCK` session registries (`0` `_Init_thread_header` TLS guards): - `xapu.dll`: `XApuConnect`, `XApuDisconnect`, `XApuEnqueueCommand`, `XApuGetResultCount`, `XApuDequeueResult`. Tracks valid queue handles and echoes FIFO 56-byte result packets (`opcode`, `context_index`, and `output_bytes` for decode commands) so callers advance context states and recycle slots cleanly, failing closed (`HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS)`) when empty and `ERROR_INVALID_HANDLE` on stale handles. - `chad.dll`: `XDspConnectWithMaximumStreamLimit`, `XDspActivate`, `XDspDeactivate`, `XDspDisconnect`, `XDspSubmitCommand`. Validates handle lifetime, `max_streams > 0`, and non-null command buffers; returns `S_OK` (`0`) so stream setup and command submission succeed cleanly. - Added `xapu.dll` and `chad.dll` `ReturnClass::HResult` entries to [`runtime/shims/registry.cpp`](runtime/shims/registry.cpp). - Added unit tests [`runtime/test/xapu_chad_test.cpp`](runtime/test/xapu_chad_test.cpp) and wired `xapu_chad_test` / `xapu_chad.cpp` in [`runtime/CMakeLists.txt`](runtime/CMakeLists.txt) and [`scripts/build_runtime.ps1`](scripts/build_runtime.ps1). ### Verification - Built `xapu_chad_test` (`cmake --build runtime/build --target xapu_chad_test`): 0 warnings. - `ctest --test-dir runtime/build -R "^xapu_chad$" --output-on-failure`: `1/1` passed. - `dumpbin /symbols` on `xapu_chad.cpp.obj`: `0` `_Init_thread_header` references. - `python -m unittest tests/test_ctest_registration.py`: `4/4` OK. - `python scripts/check_no_game_data.py` & `git diff --check`: clean. Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116975037
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:51:41 +00:00
github-bot closed this pull request 2026-11-27 05:06:17 +00:00
Author
Owner

@⁠Andretuta on GitHub · 2026-11-27 05:01 UTC · original

Closing carried-over draft: the xapu half merged in #1144 (via #2350) and the chad half is carried over in #2363.

**@⁠Andretuta** on GitHub · 2026-11-27 05:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/277#issuecomment-7210291317) Closing carried-over draft: the xapu half merged in #1144 (via #2350) and the chad half is carried over in #2363.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.