Repository navigation
acphal: ACP message queue and background XMA ring decoding with the Rust XMA2 decoder (RT-ACPHAL-XMA2) - #404
Merged
Merged
Conversation
…orker
- Add portable C++20 XMA2 packet parser and WMA Pro frame decoder
(runtime/src/xma2_decoder.{h,cpp}, following FFmpeg wmaprodec.c /
wmaprodata.h LGPL-2.1-or-later under Leonida's GPL-3.0-or-later)
with cross-platform xma2_decoder_test.
- Implement IAcpHal command/message queue protocol (REGISTER_MESSAGES,
UNREGISTER_MESSAGES, LOAD_FLOWGRAPH, COMMAND_COMPLETED, DISCONNECTED,
queue-full dropped counters, and APU notification word writes) in
runtime/shims/acphal.cpp.
- Wire a lazily-started, cleanly-joined background XMA2 decoder thread
pumping enabled SHAPE_XMA_CONTEXT output rings in APU memory.
stop_worker set a shared stopping_ flag, moved the thread out and joined it after releasing worker_mutex_. A wake in that window reset stopping_ and started a second worker, so the old one kept running and the join could hang. Each worker is now a std::jthread with its own stop_token (waits use condition_variable_any with the token), so a stop only reaches its own thread. acphal_test races 20000 context alloc/release rounds against ENABLE_XMA on a second thread (the unfixed code hung there intermittently). AI-assisted. Tested: acphal_test 115 checks, 0 failures, repeated runs (clang 23 / mingw x64). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ailable Replace the hand-written C++ XMA2/WMA Pro decoder with the Rust decoder already on main. runtime/CMakeLists.txt builds it at configure time when cargo is on PATH and links it into gta6rt and acphal_test (LEONIDA_HAVE_XMA2_DECODER); without cargo, if that build fails, or with the cl.exe fallback, XMA voices output silence for each packet's frame count. The ring engine decodes whole 2048-byte packets: the read offset and the loop points are used per packet, so a loop plays its end packet in full and restarts with a fresh decoder at the packet holding the loop start. The C ABI gains leonida_xma2_decoder_create_hardware (no first-frame drop, no 64-sample start skip), since the context carries its own skip. Tested: acphal_test 129 checks (silence) and 125 checks (Rust decoder, gnullvm build), 0 failures, 3 runs each, clang 23 / mingw x64; cargo fmt and cargo test (gnullvm); pytest build/docs suites 204 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
demoz53
added a commit
to demoz53/leonida
that referenced
this pull request
Nov 24, 2026
…dd portable XMA2/WMA-Pro decoder, ACP message queue and background XMA ring decoding (RT-ACPHAL-XMA2) [Andretuta] # Conflicts: # runtime/shims/acphal.cpp # scripts/build_runtime.ps1
Collaborator
|
Post-merge check of main d0da7da on Windows 11 / RTX 4070 SUPER (VS 2022, Ninja, RelWithDebInfo, cargo 1.98.0): the XMA2 decoder builds and links, the full build succeeds, and full ctest is 304/306 with the same two pre-existing failures as before (d3d12_execute_indirect_validation, d3d12_depth_resolve). The new Two supply-chain notes now that CMake builds this by default and CI requires it (
AI-assisted (Claude Code, Claude Opus 5.5). |
4 tasks done
demoz53
added a commit
to demoz53/leonida
that referenced
this pull request
Nov 24, 2026
Brings 58 PRs integration did not have (among them ProjectLeonida#359 ProjectLeonida#360 ProjectLeonida#402 ProjectLeonida#497 ProjectLeonida#557 ProjectLeonida#558 ProjectLeonida#560 ProjectLeonida#561 ProjectLeonida#572 ProjectLeonida#573 ProjectLeonida#574 ProjectLeonida#577) and the newer heads of ProjectLeonida#401 and ProjectLeonida#404. 15 files conflicted; resolved by hand: - frame_pacer.h, d3d12_xs_device.h/.cpp: ProjectLeonida#402's pacer (per-event ticks, issue_token_locked) now issues from ProjectLeonida#414's shared FrameTokenSource, so a token from the device-side WaitFrameEventX is one the pacer accepts (towade's ProjectLeonida#14 finding: without it every PresentX is refused). The dead frame_next_token and issued_ counters are dropped. Queue slot 32 stays ProjectLeonida#414's PresentX; ProjectLeonida#402's presentation-handler routes serve slot 30 or LEONIDA_XS_PRESENT_X_SLOT. ProjectLeonida#402's GetFrameStatisticsX route moves into ProjectLeonida#385's route_xbox_device_slot. - acphal.cpp/acphal_test.cpp: upstream's reworked SHAPE allocation and release; the release writes nothing through its first argument, as ProjectLeonida#405 requires; both sides' tests kept. Upstream's ProjectLeonida#401/ProjectLeonida#404 heads remove lifecycle.cpp and the C++ xma2_decoder.cpp (replaced by runtime/xma_decoder), so build_runtime.ps1's cl.exe list drops them and keeps ProjectLeonida#549's and ProjectLeonida#400's files. - vulkan_backend.h, statistics_sum.comp, its SPIR-V header, d3d12_mesh_test, replay_query_edges_test, d3d12_vulkan_device.cpp, docs: ProjectLeonida#577's clipping counter on top of ProjectLeonida#540, which both sides carry; the Timestamps sentence keeps integration's corrected wording (c33ce87). - xs_proxy_mock_test.cpp: both sides' cases; pr_conflict_label.py keeps the guarded reconfigure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as:
RT-ACPHAL-XMA2(#14 (comment))Depends on: #357
What and why
acphal.dllstub with an ACP command and message queue and a worker that fills SHAPE XMA PCM rings. The worker follows packet skips and refill order, updates shared fields atomically, and bounds each pass to the ring. Repeated enables preserve queued PCM for the same format and reset it when the format changes.runtime/xma_decoderat configure time through Cargo. The shim outputs silence based on each packet's frame count when Cargo is missing, the build fails, or the directcl.exefallback is used. Windows runtime CI explicitly requires the decoder.std::jthreadstop token. A worker memory failure reports an error for the affected voice. SHAPE allocation publishes a complete table or returnsE_OUTOFMEMORY. Release detaches the worker, then frees the process-wide arrays without writing through the opaque HAL handle.Tested
gta6rtandacphal_testin Debug and Release with Rust. A separate CMake configuration builtacphal_testwith the silence fallback in both build types. CTest passed in all four configurations, with 170 checks per normal run with Rust, 166 with silence, and 14 for the separate non-cached-only case in each configuration.4e9407a40.x86_64-pc-windows-msvcandx86_64-pc-windows-gnullvm, including a first-frame test for the hardware constructor. Locked release builds succeeded on both targets.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — audio decoder & runtime shim only)🤖 Generated with Claude Code