fix(audioout): serialize SDL audio initialization for Dark Forces #4789

Merged
PrintOrb merged 2 commits from upstream-pr/4789 into main 2026-10-14 02:35:57 +00:00
PrintOrb commented 2026-10-12 21:56:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrintOrb on 2026-10-12T21:56:30Z.


What

STAR WARS: Dark Forces Remaster (PPSA19728, 02.000.000) can crash in SDL_AudioQuit_REAL at address zero when legacy AudioOut and AudioOut2 initialize SDL audio concurrently. Debugger traces show overlapping initialization from sceAudioOutOpen and sceAudioOut2ContextCreate.

Serialize SDL audio initialization through a shared helper. Preserve SDL's return value and the existing caller error handling.

Tested

Native Windows, Release build, based on main 529f7bfd4. Full libs build passes. The new audio_out_initialization test exercises the production helper with a controlled SDL backend, checks serialization and unchanged failure/success returns, and passes. Removing serialization produces overlapping backend calls and fails the regression. Existing audio_out_ex, audio_out2_latency and audio_out2_port_buffers pass (4/4 total). Conventions, test registration and whitespace checks pass. Newer main ee4962190 was checked before publication: neither affected library changed, and the branch merges cleanly; the build/test results above are for the stated tested base.

Earlier title testing required the independent NGS2 voice-index fix to reach this audio path. With both fixes, manual testing completed the first mission. Tab/PDA performance problems remain. Gameplay was not repeated on the refreshed main build.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no new silent stubs
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none for building/testing; the NGS2 voice-index fix #4788 is needed to reproduce this title's later startup path
  • Unblocks: PPSA19728 #4310
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4835454582 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4789). Originally posted by [PrintOrb](https://github.com/PrintOrb) on 2026-10-12T21:56:30Z. --- ### What STAR WARS: Dark Forces Remaster (PPSA19728, 02.000.000) can crash in `SDL_AudioQuit_REAL` at address zero when legacy AudioOut and AudioOut2 initialize SDL audio concurrently. Debugger traces show overlapping initialization from `sceAudioOutOpen` and `sceAudioOut2ContextCreate`. Serialize SDL audio initialization through a shared helper. Preserve SDL's return value and the existing caller error handling. ### Tested Native Windows, Release build, based on main `529f7bfd4`. Full `libs` build passes. The new `audio_out_initialization` test exercises the production helper with a controlled SDL backend, checks serialization and unchanged failure/success returns, and passes. Removing serialization produces overlapping backend calls and fails the regression. Existing `audio_out_ex`, `audio_out2_latency` and `audio_out2_port_buffers` pass (4/4 total). Conventions, test registration and whitespace checks pass. Newer main `ee4962190` was checked before publication: neither affected library changed, and the branch merges cleanly; the build/test results above are for the stated tested base. Earlier title testing required the independent NGS2 voice-index fix to reach this audio path. With both fixes, manual testing completed the first mission. Tab/PDA performance problems remain. Gameplay was not repeated on the refreshed main build. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no new silent stubs - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none for building/testing; the NGS2 voice-index fix #4788 is needed to reproduce this title's later startup path - [x] Unblocks: PPSA19728 #4310 - [x] AI-assisted: yes (Codex)
github-actions[bot] commented 2026-10-13 04:56:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T04:56:42Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#3533 core/libs/prx/libSceAudioOut/CMakeLists.txt L19
#5448 core/libs/prx/libSceAudioOut/src/AudioOut2Context.cpp L16
#5558 core/libs/prx/libSceAudioOut/CMakeLists.txt L19
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6138553643 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4789#issuecomment-6138553643). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T04:56:42Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #3533 | `core/libs/prx/libSceAudioOut/CMakeLists.txt` [L19](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/core/libs/prx/libSceAudioOut/CMakeLists.txt#L19) | | | | #5448 | `core/libs/prx/libSceAudioOut/src/AudioOut2Context.cpp` [L16](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/core/libs/prx/libSceAudioOut/src/AudioOut2Context.cpp#L16) | | | | #5558 | `core/libs/prx/libSceAudioOut/CMakeLists.txt` [L19](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/core/libs/prx/libSceAudioOut/CMakeLists.txt#L19) | | |
xXPBSXx commented 2026-10-13 11:52:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T11:52:01Z.


Windows test: head 5031432db merged onto current main 5d50886ee, together with 9 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest for the tests this change adds or touches: audio_out_initialization passed; python tools/check_conventions.py --base upstream/main passed for the combined tree. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144916563 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4789#issuecomment-6144916563). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T11:52:01Z. --- Windows test: head `5031432db` merged onto current `main` `5d50886ee`, together with 9 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest for the tests this change adds or touches: audio_out_initialization passed; `python tools/check_conventions.py --base upstream/main` passed for the combined tree. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
johnohhh1 commented 2026-10-14 02:02:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnohhh1 on 2026-10-14T02:02:20Z.


Independent Linux validation of 5031432db0d39c8c95504218673166cf6a69ef1a, applied alone to main 959d39fb2b050fa76beed0b49b4c2f13a119ab5a (without #4788 or other pending PRs).

Ubuntu 26.04.1 x86-64, GCC 15.2.0, Release, bundled dependencies, testing and SPIR-V Tools enabled. SDL_AUDIODRIVER=dummy was set only in the test process.

  • Full baseline and patched builds pass. All 12 selected AudioOut/patched-library suites pass on the candidate without skips, including audio_out_initialization; serial CTest with a 30-second maximum. The slowest selected test takes 4.40 seconds.
  • The author's exact initialization regression passes against the production AudioOutSdl.cpp helper. Against an unsynchronized control that calls SDL_InitSubSystem(SDL_INIT_AUDIO) directly, it fails with peak=2, while preserving the backend's -1,0 return sequence.
  • An additional stress probe starts 12 threads together for 1,536 calls, mixing backend success and failure. The unsynchronized control reaches 12 simultaneous backend calls and fails the serialization check; the production helper reaches only one and passes, with every call made and each thread's return value preserved.
  • Conventions and whitespace checks pass; the combined change matches the original stable patch ID and retains the original author.

The concurrency checks compile the actual production helper with a controlled SDL backend. They establish serialization and return-value preservation, not reproduction of the real SDL_AudioQuit_REAL crash or gameplay progress. The existing AudioOut library suites use SDL's dummy driver. No title or native PS5 was run, and Windows was not retested.

AI-assisted validation/report: Codex. Original implementation and authorship preserved.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159229812 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4789#issuecomment-6159229812). Originally posted by [johnohhh1](https://github.com/johnohhh1) on 2026-10-14T02:02:20Z. --- Independent Linux validation of `5031432db0d39c8c95504218673166cf6a69ef1a`, applied alone to main `959d39fb2b050fa76beed0b49b4c2f13a119ab5a` (without #4788 or other pending PRs). Ubuntu 26.04.1 x86-64, GCC 15.2.0, Release, bundled dependencies, testing and SPIR-V Tools enabled. `SDL_AUDIODRIVER=dummy` was set only in the test process. - Full baseline and patched builds pass. All 12 selected AudioOut/patched-library suites pass on the candidate without skips, including `audio_out_initialization`; serial CTest with a 30-second maximum. The slowest selected test takes 4.40 seconds. - The author's exact initialization regression passes against the production `AudioOutSdl.cpp` helper. Against an unsynchronized control that calls `SDL_InitSubSystem(SDL_INIT_AUDIO)` directly, it fails with `peak=2`, while preserving the backend's `-1,0` return sequence. - An additional stress probe starts 12 threads together for 1,536 calls, mixing backend success and failure. The unsynchronized control reaches 12 simultaneous backend calls and fails the serialization check; the production helper reaches only one and passes, with every call made and each thread's return value preserved. - Conventions and whitespace checks pass; the combined change matches the original stable patch ID and retains the original author. The concurrency checks compile the actual production helper with a controlled SDL backend. They establish serialization and return-value preservation, not reproduction of the real `SDL_AudioQuit_REAL` crash or gameplay progress. The existing AudioOut library suites use SDL's dummy driver. No title or native PS5 was run, and Windows was not retested. AI-assisted validation/report: Codex. Original implementation and authorship preserved.
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!4789
No description provided.