mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 00:05:58 +03:00
[PR #507] [MERGED] sceNetAccept sleep and SDLAudio::AudioOutOutput latency and cpu improvements #1604
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#1604
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/shadps4-emu/shadPS4/pull/507
Author: @kh0nsu
Created: 8/21/2024
Status: ✅ Merged
Merged: 9/11/2024
Merged by: @georgemoralis
Base:
main← Head:main📝 Commits (3)
8a42c20Add 5-second sleep on sceNetAccept as this can be called in an infinite loop and would normally block (this isn't ideal for non-blocking sockets but it's all stubs at the moment anyway)fc6a259SDLAudio::AudioOutOutput: protect against invalid handle, support NULL input (wait only), replace fixed 65536 with an amount based on settable latency target (20ms for now)42413d1Fix whitespace📊 Changes
2 files changed (+27 additions, -11 deletions)
View changed files
📝
src/audio_core/sdl_audio.cpp(+23 -10)📝
src/core/libraries/network/net.cpp(+4 -1)📄 Description
The sceNetAccept sleep reduces CPU usage, possibly memory usage depending on game behaviour, and log spam if the game calls it in a loop. BB at least is known to do this. This is still far from ideal but I expect this is beneficial for most games.
The SDLAudio::AudioOutOutput changes will target a particular latency rather than a fixed number of bytes which should make behaviour consistent across games. Handle is validated further. A NULL buffer is supported (I saw this in some OpenOrbis samples). The sleep is changed from 0ms to 1ms. In testing an audio-only homebrew sample, CPU usage is lowered. It's hard to measure exactly (on Windows at least) but a sleep-0 theoretically constantly yields and re-schedules the thread possibly using up a whole core. Sleep-1 is not guaranteed to be 1ms but it should be lower than the (arbitrary) 20ms latency target on all platforms.
20ms is meant to provide ~1-frame latency in 60fps games but may be too low in some cases so this may need tuning. This should be obvious as audio will become crunchy in games where it is currently smooth.
Feedback welcome. This is my first PR.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.