audio: rely on SDL queue pacing #36
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!36
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/36/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Digote on GitHub · 2026-07-18 03:47 UTC · original
fix/audio-output-pacing→main· +16 −22 · 1 files · 2 commits · closed without mergingSummary
AudioOutOutputsProblem
The wall-clock delay was inherited from the original Kyty implementation, where
audio output was not implemented and the buffer duration was only simulated.
KytyPS5 now sends real audio through
SDL_QueueAudio. The existing code alreadyapplies backpressure based on the amount of audio queued in SDL. Keeping the
legacy delay in
AudioOutOutputsintroduced a second pacing mechanism beforequeueing each buffer.
With 256-frame buffers at 48 kHz, each buffer represents approximately 5.33 ms
of audio. Sleeping for that duration before queueing the next buffer prevented
SDL from consistently maintaining its intended buffering cushion, making
underruns and audible stuttering more likely under scheduler or emulation
jitter.
Implementation
The per-port
last_output_timestate and the corresponding wall-clock sleepwere removed.
The existing backpressure in
QueueSdlAudiois preserved. In blocking mode, thefunction still waits while SDL has more than two buffers queued before adding
the next buffer. Therefore, removing the wall-clock delay does not allow the
normal audio queue to grow without bounds.
Non-blocking output behavior is unchanged and continues to skip the SDL queue
wait.
A null buffer is handled separately as a blocking drain request. It waits for
the actual SDL queue to finish, with the existing 200 ms watchdog behavior to
avoid an indefinite wait if the audio device stops consuming data.
Validation
clang-clcompleted successfullykyty_emulator.exe --helpsmoke test passedPPSA02929) with 256-frame FloatStereo audio at 48 kHzAI assistance disclosure
AI assistance was used to inspect the inherited timing implementation, analyze
the SDL queue behavior, review edge cases, and prepare the initial change.
The contributor manually tested the affected game, confirmed the audio
improvement, and reviewed the final one-file diff before submission.
@red-prig on GitHub · 2026-07-22 03:00 UTC · original
From shadps4's experience, I can say that this is incorrect. Time delays should always be simulated manually because games expect them, and SDL doesn't guarantee the same time delays in each implementation, so you'll get bugs from some people and normal behavior from others.
@Digote on GitHub · 2026-07-22 13:39 UTC · original
Thank you very much for the detailed explanation. I'll close this PR and work on a new one that better contributes to the emulator.
Pull request closed