audio: schedule SPU IRQ samples by guest clock; prime the SPU scheduler before the first sample deadline - #239
Conversation
|
I think there may be one idle-skip gap here, but I want to check whether you agree. The new SPU sample event is included in the internal device slicer, but not in the idle-skip observable-event path. Does that seem like a real gap to you? If so, would it make sense to include the SPU sample deadline in the idle-skip event distance when |
The SPU sample event was part of the internal device slicer but not of the idle-skip observable-event distance, so a poll loop waiting on SPU IRQ9 could be skipped across several 768-cycle sample boundaries before it could acknowledge and re-arm. Include the sample deadline in devices_cycles_to_next_idle_event() when IRQ_SPU is unmasked (mask-gated like the other sources), expose the distance through psx_idle_cycles_to_next_observable_event() for tests, and extend psx_cycle_event_boundaries_test: masked IRQ9 does not bound the skip; unmasked IRQ9 stops it at the first sample boundary, never across later ones.
|
Yes, that is a real gap — the sample event was in the internal device slicer but not in the observable-event distance, so an idle-skip could cross several sample boundaries before the guest could acknowledge and re-arm IRQ9. Pushed e9f834d: |
Summary
SPU IRQ sample events are scheduled on the guest cycle clock (768 CPU cycles per 44.1 kHz sample) rather than host frames, and the scheduler is primed before the first deadline so the first service cannot establish a shifted epoch. Fixes audio pitch/skew on titles whose SPU IRQ drives streaming (measured 27 kHz -> 59 kHz effective on Gran Turismo).
Commits
Scope
6 files changed, 148 insertions(+)
Validation
Cherry-picked from the Alexbeav/psxrecomp
mainline, where the same changes pass the recompiler/runtime/runtime-ui ctest gates with only the pre-existing failures (aot_overlay_discovery,release_zip,gte_register_access_testlink). This branch was also built onmstan/masteras of 01c647e with the same result.Amendment
The branch now also carries
db2c638a(SPU sample-event test stubs + PAL-aware load-accel guard) — without itpsx_cycle_event_boundaries_testdoes not link on the pristine base. Rebuilt ata36b504d: only the acceptedgte_register_access_testlink fails;psx_cycle_event_boundaries_testpasses;test_mod_load_acceleration.pyandtest_spu_sample_scheduler_default.pypass.