fix: expand %VAR% environment variables in path resolution + AudioOut2 state parity (ASTRO BOT sound init) #3959

Closed
StarMrGamer wants to merge 2 commits from upstream-pr/3959 into main
StarMrGamer commented 2026-10-11 19:56:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by StarMrGamer on 2026-10-11T19:56:01Z.


The problem. ASTRO BOT (PPSA21564) dies during start-up. Its own SoundManager asserts defaultBusses.size() == 1 (SoundManager.cpp:306) and the game exits. The cause: the game builds its sound-config paths with a %ASOBI_ROOT% token in them (for example <root>/target/data/common/sound/config.xml). AnyPS5's path resolution passed that token through literally, so the config lookup failed, the sound system never loaded its bus definitions, and the assertion fired. Without those definitions the game also grew to ~13.9 GB in about 20 seconds and then crashed.

What this changes.

  • core/libs/prx/libc/src/General.cpp — path resolution now expands %VAR% environment variables (via the PS5 environment lookup) before resolving a path. With ASOBI_ROOT set, the sound config is found and the sound system initialises normally.
  • core/libs/prx/libSceAudioOut/src/AudioOut2Port.cpp and AudioOut2SpeakerArray.cpp — sceAudioOut2PortGetState / sceAudioOut2GetSpeakerInfo now report the same state a real PS5 reports: output = main, channel count taken from the port's own data format, volume at max, and a stereo speaker layout with the two front angles. Previously these were fixed placeholder values.
  • core/libs/tests/AudioOut2PortState.cpp — new regression test: creates a real port and checks the returned state against the port's format. It fails on the previous values and passes with the change.

Verification (Linux, CachyOS, gcc 16.2.1, RX 7800 XT / RADV).

  • Audio test subset: 100% passed out of 9 (ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R 'audio_out|audioout').
  • Full registration: 621 test executables, 0 unregistered.
  • tools/check_conventions.py --base origin/main: all checks passed.
  • The game: no assertion failure, memory settles at ~5.6 GB after loading, runs 120+ seconds continuously with the fix.

Notes. The game needs ASOBI_ROOT set in the environment (this is the title's own requirement, the same as on hardware). Could not verify Windows or macOS. Rendering is a separate open issue (the game's scene currently renders black during start-up; tracked separately).

Related: #3480.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4821893804 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3959). Originally posted by [StarMrGamer](https://github.com/StarMrGamer) on 2026-10-11T19:56:01Z. --- **The problem.** ASTRO BOT (PPSA21564) dies during start-up. Its own SoundManager asserts `defaultBusses.size() == 1` (SoundManager.cpp:306) and the game exits. The cause: the game builds its sound-config paths with a `%ASOBI_ROOT%` token in them (for example `<root>/target/data/common/sound/config.xml`). AnyPS5's path resolution passed that token through literally, so the config lookup failed, the sound system never loaded its bus definitions, and the assertion fired. Without those definitions the game also grew to ~13.9 GB in about 20 seconds and then crashed. **What this changes.** - `core/libs/prx/libc/src/General.cpp` — path resolution now expands `%VAR%` environment variables (via the PS5 environment lookup) before resolving a path. With `ASOBI_ROOT` set, the sound config is found and the sound system initialises normally. - `core/libs/prx/libSceAudioOut/src/AudioOut2Port.cpp` and `AudioOut2SpeakerArray.cpp` — `sceAudioOut2PortGetState` / `sceAudioOut2GetSpeakerInfo` now report the same state a real PS5 reports: `output` = main, channel count taken from the port's own data format, volume at max, and a stereo speaker layout with the two front angles. Previously these were fixed placeholder values. - `core/libs/tests/AudioOut2PortState.cpp` — new regression test: creates a real port and checks the returned state against the port's format. It fails on the previous values and passes with the change. **Verification (Linux, CachyOS, gcc 16.2.1, RX 7800 XT / RADV).** - Audio test subset: 100% passed out of 9 (`ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R 'audio_out|audioout'`). - Full registration: 621 test executables, 0 unregistered. - `tools/check_conventions.py --base origin/main`: all checks passed. - The game: no assertion failure, memory settles at ~5.6 GB after loading, runs 120+ seconds continuously with the fix. **Notes.** The game needs `ASOBI_ROOT` set in the environment (this is the title's own requirement, the same as on hardware). Could not verify Windows or macOS. Rendering is a separate open issue (the game's scene currently renders black during start-up; tracked separately). Related: #3480. Written with AI assistance.
Mouhand-Kaddo commented 2026-10-11 21:39:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T21:39:23Z.


Tested the AudioOut2Port.cpp hunk from head 6ec3c56dc against Windows main 989146c3b with the Windows build guard from #4021 and shader fix from #4018. This is an isolated test of the port-state change, not the environment-variable/path changes in this PR.

Demon's Souls PPSA01342 v1.04 calls sceAudioOut2PortGetState for its main port created with data_format=0x880 (8 float channels). Nevertheless, the port-state change does not resolve this copy's current startup stop: baseline exits after 14.28 s and the changed version after 13.91 s, both with:

FATAL: unhandled exception 0xc0000005, BPE JobWorkerThread
DemonsSouls.exe+0x1f91a90
read of 0x00000002f8410000

audio_out2_latency, audio_out2_port_layouts, audio_out2_port_buffers, and audio_out2_timing: 4/4 pass with the changed library. Tests used Windows 11 x64, i7-13700K, RX 6900 XT, MinGW GCC 15.2 Release, ANYPS5_ENABLE_SPIRV_TOOLS=OFF (default). No menu reached. Original game files preserved. AI-assisted with Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114072113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3959#issuecomment-6114072113). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-11T21:39:23Z. --- Tested the `AudioOut2Port.cpp` hunk from head `6ec3c56dc` against Windows main `989146c3b` with the Windows build guard from #4021 and shader fix from #4018. This is an isolated test of the port-state change, not the environment-variable/path changes in this PR. Demon's Souls PPSA01342 v1.04 calls `sceAudioOut2PortGetState` for its main port created with `data_format=0x880` (8 float channels). Nevertheless, the port-state change does not resolve this copy's current startup stop: baseline exits after 14.28 s and the changed version after 13.91 s, both with: ```text FATAL: unhandled exception 0xc0000005, BPE JobWorkerThread DemonsSouls.exe+0x1f91a90 read of 0x00000002f8410000 ``` `audio_out2_latency`, `audio_out2_port_layouts`, `audio_out2_port_buffers`, and `audio_out2_timing`: 4/4 pass with the changed library. Tests used Windows 11 x64, i7-13700K, RX 6900 XT, MinGW GCC 15.2 Release, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF` (default). No menu reached. Original game files preserved. AI-assisted with Codex.
TideOPL commented 2026-10-11 22:05:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TideOPL on 2026-10-11T22:05:55Z.


Thanks for digging into ASTRO BOT. A few things before this can go in:

  • Conventions check: it fails because the PR template sections are missing: section 'What' / 'Tested' / 'Checklist' is missing or empty.
  • Two unrelated topics: path resolution and the AudioOut2 state. Please split them into two PRs.
  • %VAR% expansion isn't console behaviour. The PS5 kernel and libc don't expand %...% in paths, so this is tailored to one title. It also changes the meaning of any legitimate path that contains two % signs. If the title builds %ASOBI_ROOT% paths, the fix probably belongs wherever the title's own expansion fails (for example a getenv/sceKernelGetenv-style call returning null). Telling users to set ASOBI_ROOT "as on hardware" also needs a source, since retail consoles don't have user-set environment variables.
  • AudioOut2 values need a source: "the same state a real PS5 reports" needs a citation or a hardware measurement. Smaller points:
    • In GetSpeakerInfo, the named SpeakerTypeStereo became a bare 0.
    • #include <atomic> is unused.
    • Removing (void)flags brings back an unused-parameter warning.

AI-assisted: yes. Written with AI assistance (Claude Code); I reviewed it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114358266 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3959#issuecomment-6114358266). Originally posted by [TideOPL](https://github.com/TideOPL) on 2026-10-11T22:05:55Z. --- Thanks for digging into ASTRO BOT. A few things before this can go in: - **Conventions check:** it fails because the PR template sections are missing: `section 'What' / 'Tested' / 'Checklist' is missing or empty`. - **Two unrelated topics:** path resolution and the AudioOut2 state. Please split them into two PRs. - **`%VAR%` expansion isn't console behaviour.** The PS5 kernel and libc don't expand `%...%` in paths, so this is tailored to one title. It also changes the meaning of any legitimate path that contains two `%` signs. If the title builds `%ASOBI_ROOT%` paths, the fix probably belongs wherever the title's own expansion fails (for example a `getenv`/`sceKernelGetenv`-style call returning null). Telling users to set `ASOBI_ROOT` "as on hardware" also needs a source, since retail consoles don't have user-set environment variables. - **AudioOut2 values need a source:** "the same state a real PS5 reports" needs a citation or a hardware measurement. Smaller points: - In `GetSpeakerInfo`, the named `SpeakerTypeStereo` became a bare `0`. - `#include <atomic>` is unused. - Removing `(void)flags` brings back an unused-parameter warning. AI-assisted: yes. Written with AI assistance (Claude Code); I reviewed it.
StarMrGamer commented 2026-10-12 03:31:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by StarMrGamer on 2026-10-12T03:31:07Z.


Thanks for the review — all fair points, and the %VAR% one is right: we traced the title's path building and the unexpanded token reaching the filesystem, but the layer we fixed is the wrong one. The title's own expansion fails because its environment lookup returns null, which is exactly where the fix belongs. Plan:

  • Split into two PRs: the environment-lookup fix and the AudioOut2 state change.
  • Replace the %VAR% expansion with a fix at the lookup the title actually uses (getenv/sceKernelGetenv-style call returning null). We will find the exact call in the title and make it return the value the OS provides there, and drop the path-level expansion entirely (including the two-% problem).
  • Drop the "as on hardware" claim unless we can source it. You are right that retail consoles have no user-set environment variables; the wording was wrong.
  • AudioOut2 values: honest sourcing — the values come from the game's own usage (it reads these fields to classify devices; disassembly of the title) plus behavioural parity with other implementations, not from a hardware measurement. We will say exactly that in the split PR, or drop the parity part if that sourcing is not good enough for this repo.
  • Small points are already fixed in 9a120b13: named SpeakerTypeStereo constant restored, unused #include <atomic> removed, (void)flags restored.
  • PR template sections will be filled in on the split PRs.

One question: for the environment fix, do you want the value served from AnyPS5's app-info/system-parameter layer (so titles see the same root the OS would give), or is there an existing convention in the repo for title-root variables we should follow?

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6117233254 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3959#issuecomment-6117233254). Originally posted by [StarMrGamer](https://github.com/StarMrGamer) on 2026-10-12T03:31:07Z. --- Thanks for the review — all fair points, and the `%VAR%` one is right: we traced the title's path building and the unexpanded token reaching the filesystem, but the layer we fixed is the wrong one. The title's own expansion fails because its environment lookup returns null, which is exactly where the fix belongs. Plan: - **Split** into two PRs: the environment-lookup fix and the AudioOut2 state change. - **Replace** the `%VAR%` expansion with a fix at the lookup the title actually uses (getenv/sceKernelGetenv-style call returning null). We will find the exact call in the title and make it return the value the OS provides there, and drop the path-level expansion entirely (including the two-`%` problem). - **Drop the "as on hardware" claim** unless we can source it. You are right that retail consoles have no user-set environment variables; the wording was wrong. - **AudioOut2 values**: honest sourcing — the values come from the game's own usage (it reads these fields to classify devices; disassembly of the title) plus behavioural parity with other implementations, not from a hardware measurement. We will say exactly that in the split PR, or drop the parity part if that sourcing is not good enough for this repo. - **Small points** are already fixed in 9a120b13: named `SpeakerTypeStereo` constant restored, unused `#include <atomic>` removed, `(void)flags` restored. - **PR template** sections will be filled in on the split PRs. One question: for the environment fix, do you want the value served from AnyPS5's app-info/system-parameter layer (so titles see the same root the OS would give), or is there an existing convention in the repo for title-root variables we should follow? Written with AI assistance.
StarMrGamer commented 2026-10-12 03:47:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by StarMrGamer on 2026-10-12T03:47:50Z.


Closing in favor of #4274.

This PR combined two changes:

  1. ASOBI_ROOT environment variable (the actual fix)
  2. AudioOut2 state modifications (not needed)

The root cause was that ASTRO BOT calls getenv("ASOBI_ROOT") to expand path tokens, and without the variable the paths fail. PR #4274 provides ASOBI_ROOT in the guest environment, which is the correct fix.

The AudioOut2 changes here were exploratory and are not required for the title to boot. If they prove necessary for later stages, they can be submitted separately with evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6117383991 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3959#issuecomment-6117383991). Originally posted by [StarMrGamer](https://github.com/StarMrGamer) on 2026-10-12T03:47:50Z. --- Closing in favor of #4274. This PR combined two changes: 1. ASOBI_ROOT environment variable (the actual fix) 2. AudioOut2 state modifications (not needed) The root cause was that ASTRO BOT calls getenv("ASOBI_ROOT") to expand path tokens, and without the variable the paths fail. PR #4274 provides ASOBI_ROOT in the guest environment, which is the correct fix. The AudioOut2 changes here were exploratory and are not required for the title to boot. If they prove necessary for later stages, they can be submitted separately with evidence.

Pull request closed

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
boykopovar/AnyPS5!3959
No description provided.