Commit Graph

3 Commits

Author SHA1 Message Date
9d054cd855 Async callback and handle safety in xgameruntime, gameinput_no_sdl and xapu_queue
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>
2026-11-27 19:40:07 -06:00
a5dd540bcc xapu: decode Opus packets through runtime/opus_decoder (RT-XAPU-OPUS-DECODE)
Builds on #1144 (RT-XAPU-CONNECT-LAYOUTS): the queue and layouts stay there;
fill() decodes each process packet through a Rust C-ABI crate over BSD-3
opus-pure when cargo builds it, and keeps the table-of-contents silence path
otherwise. Adds xapu_opus_test (a generated 440 Hz stereo packet decoded to
960 frames) and the CMake wiring; xapu_chad_test keeps covering the layouts
and the silent path. No game data.
2026-11-25 14:11:53 -05:00
6ee7ef89b9 Merge branch 'main' of https://github.com/ubiquitarianism/leonida into xapu-connect-layouts
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
2026-11-25 12:09:55 +01:00