kevincommits' Finding 19 in #1608, item 5:
- xgameruntime.cpp (XNetworking): an initial notification's callback
that unregistered itself with wait=true waited for its own return and
never came back. The registration now records the thread running its
callback, and an unregister from that thread returns at once (the
registration ends when the callback returns). net_register also used a
throwing new across the ABI; it is new (std::nothrow) now.
- gameinput_no_sdl.cpp: a GameInputBlockingEnumeration report ran
outside deliver_mu, so UnregisterCallback on another thread returned
while the callback was still running and the caller could free its
context mid-call. It now runs under deliver_mu and marked as
delivering, as deliver() runs callbacks.
- xapu_queue.cpp: handles were never checked, so a second XApuDisconnect
freed the connection again and closed its event twice. Connections are
kept in a live set under a shared mutex; every call checks its handle
and holds the lock shared for the call, and a disconnect takes it
exclusive. An activate or deactivate changed the stream before the
result was queued, so running out of memory left it half applied; the
result's slot is now taken first.
New checks: xgameruntime_test (a callback that unregisters itself with
wait=true returns), gameinput_no_sdl_test (UnregisterCallback waits for a
running blocking callback; a blocking callback can unregister itself),
xapu_chad_test (a second disconnect, a disconnected and a foreign handle
are refused). On main the first two fail and xapu_chad_test crashes with
heap corruption.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main added its own runtime/shims/xapu.cpp: the boot stack's earlier xapu.dll stub, which gta6rt does not link and
xapu_test checks. This branch's xapu.dll command queue moves to runtime/shims/xapu_queue.cpp so both stay: gta6rt,
xapu_chad_test, the cl.exe fallback list in scripts/build_runtime.ps1 and the references in xapu_chad.cpp,
xapu_chad_test.cpp and docs/audio_hal_exe_calls.md name the new file; main's xapu.cpp and xapu_test are unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GnGkjYHUWx92TkwvwCnAMe
xapu.dll moves out of xapu_chad.cpp into xapu.cpp; chad.dll is unchanged.
The signatures, structure layouts, command kinds, option bits and error
codes come from Marvisak/VIctory (GPL-3.0-or-later,
crates/victory-hle/src/modules/apu.rs at ffe310e), which runs the retail
executable through these calls. Only facts are used, no code
(docs/related_projects.md). They settle what the old header left open:
XApuConnect's first argument is an input (processing kind, streams,
commands per stream, memory bytes, frames per output, options), and the
dword the title reads at +0x34 of a result is its output byte count.
- XApuConnect validates the input, allocates the memory the title asks
for (zeroed) and, with option 0x8, an auto-reset result event; any
processing kind but Opus decoding is E_NOTIMPL.
- Each accepted command gives one result in command order, with the
console's error codes; an unknown kind, a stream out of range or a full
stream is refused with no result.
- A process result carries the frame count of the Opus packet's TOC byte
(RFC 6716, section 3.1), clipped from first_frame, to frame_count and to
the output, and zeros in the output. Nothing is decoded.
- xapu_chad_test covers result order, the full queue, the error codes,
frame counts, silence and the event.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The executable's ten APU and audio DSP imports (one call site each, four for XApuEnqueueCommand) now bind to runtime/shims/xapu_chad.cpp instead of the unimplemented thunk. Both connects return a handle; the APU connect also returns a zeroed shared buffer. Commands are accepted and dropped, the result count is 0 and dequeuing fails. xapu_chad_test calls all ten in the call-site shapes.