fix(libSceAudioOut): allow state queries during output waits #2130

Merged
authurtabo-byte merged 1 commit from upstream-pr/2130 into main 2026-10-09 21:43:11 +00:00
authurtabo-byte commented 2026-10-09 09:41:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by authurtabo-byte on 2026-10-09T09:41:34Z.


What

Audio output waits hold the global port-state mutex while draining SDL audio or pacing a port without a device. A continuous FMOD output thread can therefore starve Unity's main thread in sceAudioOutGetPortState, leaving startup stuck on a black screen.

Release the state mutex during sleeps. A separate output mutex keeps output batches and closes serialized, preserving port lifetime and output order while state queries and volume updates can proceed. Queue thresholds, drain timeouts and virtual-port pacing stay the same.

Related #1486 changes sleep precision in the same helpers; it does not release the port-state mutex. This change addresses lock scope independently and needs reconciliation if both land.

Tested

Rebased onto main f8c2f072. Fresh independent Windows Release build: last-output-time/concurrency, pad-speaker mix levels, AudioOut2 timing and latency tests all pass (4/4; 6.06 seconds); conventions pass.

Windows 11, WinLibs GCC, Release. Added a concurrency regression covering single and batched output, pacing and draining, state/timestamp queries, and close during pending output. The regression fails on unchanged audio code; with this change it passes. audio_out_last_output_time, audio_out_mix_level_pad_spk, audio_out2_timing and audio_out2_latency pass (4/4).

In MiniGolf, repeated debugger samples previously showed the main thread blocked in sceAudioOutGetPortState while FMOD slept in queueAudio holding the shared mutex. With this change the main thread advances. Separate module-loading and rendering issues are being tested independently; this is not a claim that this change alone makes the title playable.

Conventions and whitespace checks pass. Linux and other titles were not run.

Checklist

  • Based on current main; no duplicate open PR implements this fix (related #1486 described above)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • No third-party code added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4798722243 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2130). Originally posted by [authurtabo-byte](https://github.com/authurtabo-byte) on 2026-10-09T09:41:34Z. --- ### What Audio output waits hold the global port-state mutex while draining SDL audio or pacing a port without a device. A continuous FMOD output thread can therefore starve Unity's main thread in `sceAudioOutGetPortState`, leaving startup stuck on a black screen. Release the state mutex during sleeps. A separate output mutex keeps output batches and closes serialized, preserving port lifetime and output order while state queries and volume updates can proceed. Queue thresholds, drain timeouts and virtual-port pacing stay the same. Related #1486 changes sleep precision in the same helpers; it does not release the port-state mutex. This change addresses lock scope independently and needs reconciliation if both land. ### Tested Rebased onto main `f8c2f072`. Fresh independent Windows Release build: last-output-time/concurrency, pad-speaker mix levels, AudioOut2 timing and latency tests all pass (4/4; 6.06 seconds); conventions pass. Windows 11, WinLibs GCC, Release. Added a concurrency regression covering single and batched output, pacing and draining, state/timestamp queries, and close during pending output. The regression fails on unchanged audio code; with this change it passes. `audio_out_last_output_time`, `audio_out_mix_level_pad_spk`, `audio_out2_timing` and `audio_out2_latency` pass (4/4). In MiniGolf, repeated debugger samples previously showed the main thread blocked in `sceAudioOutGetPortState` while FMOD slept in `queueAudio` holding the shared mutex. With this change the main thread advances. Separate module-loading and rendering issues are being tested independently; this is not a claim that this change alone makes the title playable. Conventions and whitespace checks pass. Linux and other titles were not run. ### Checklist - [x] Based on current `main`; no duplicate open PR implements this fix (related #1486 described above) - [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 silent stubs added - [x] No notes, investigation files or images added to the repository - [x] No third-party code added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
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!2130
No description provided.