Skip to content

Upstream sync 9B: small HLE libraries (Net, SaveData, AudioOut, Ngs2, nid and others) - #489

Merged
RINNECODER merged 30 commits into
mainfrom
sync9/libs
Oct 14, 2026
Merged

RINNECODER merged 30 commits into
mainfrom
sync9/libs

Conversation

@RINNECODER

Copy link
Copy Markdown
Owner

Summary

Sync slice B (small HLE libraries) from boykopovar/AnyPS5, range 18c438b..upstream/main. Each commit is a git cherry-pick -x; commit messages that named games or title IDs were reworded, and title IDs were removed from ported test and debt text (last commit). Upstream debt hunks were folded into docs/dev/TechnicalDebt.md where this fork has no per-library debt file.

Ported (29 upstream commits)

  • fix(nid): validate ELF table layouts before patching (upstream abe8fb8)
  • test(nid): avoid competing hash test registration (upstream 617e7ac)
  • fix(avplayer): resume the presentation clock when the source restarts after a pause (upstream a671dc4)
  • fix(libSceNet): accept MSG_DONTWAIT in the send and receive calls (upstream 44d46ee)
  • fix(audioout): serialize shared SDL audio initialization (upstream c35572e)
  • test(audioout): detect overlapping backend initialization (upstream 5031432)
  • feat(net): implement memory-pool netstat diagnostic (upstream 565fafa)
  • fix(libSceVideoOut): return RESOURCE_BUSY when a bus is opened twice (upstream c15e9f2)
  • fix(savedata): leave the mount result untouched when sceSaveDataMount3 fails (upstream 4ccf888)
  • fix(libSceNet): report SO_ERROR from sceNetGetsockopt (upstream 0daf1d5)
  • fix(savedata): report a save's size as the mount that created it gave (upstream 4b7a357)
  • fix(savedata): return no saves for a search with another title's ID (upstream d34b788)
  • feat(libScePosixForWebKit): implement getservbyname (upstream 15bbc19)
  • fix(libScePosixForWebKit): keep the getservbyname result trivially destructible (upstream 8b9529b)
  • test(libSceConvertKeycode): cover sceConvertKeycodeGetImeKeyboardType (upstream 0afa191)
  • feat(ces): implement sceCesUcsProfileInitSJis1997Cp932 (upstream e5f0938)
  • refactor(savedata): clear the mount result once the mount point is made (upstream 6a46563)
  • fix(libSceKeyboard): report one key slot when no key is held (upstream 8ea8ea3)
  • fix(libSceNpAuth): report an async request as running on its first poll (upstream cb8b0ca)
  • feat(libSceConvertKeycode): implement sceConvertKeycodeGetCharacter for the US layout (upstream 5ca6487)
  • feat(libSceNet): implement sceNetResolverStartNtoa6 (upstream df32a44)
  • fix(libSceNet): dissolve a datagram association on connect to AF_UNSPEC (upstream 65d56b3)
  • fix(libSceNet): fail the AF_UNSPEC connect with EAFNOSUPPORT as FreeBSD does (upstream fce9538)
  • fix(libSceOpusDec): decode narrowband SILK packets (upstream fb41f10)
  • fix(http2): allow completion waits without an event queue (upstream 28bcd6b)
  • feat(libSceNgs2.native): implement custom sampler rack id 0x4001 (libSceNgs2: Dead Cells (PPSA15552) crashes at startup — 'NGS2: rack id 0x4001 is not implemented' boykopovar/AnyPS5#4334) (upstream 855823e)
  • feat(libSceNgs2.native): add custom voice filter support and related tests for 0x13 issue case (upstream ef52b16)
  • test(libSceNgs2): fix custom filter regression expectations (upstream 852c808)
  • fix(ngs2): resolve voice patches to rack handles (upstream 8b0da18)

Skipped

  • f818d5e fix(libs): spell inline assembly symbols for Mach-O hosts - conflicts in libc/libkernel/Fiber files owned by other slices
  • c1bcd0b fix(videoout): dump linear display buffers - touches the Vulkan frame-dump path, which this fork's VulkanDevice does not have in that form
  • 2f45380 fix(libSceSystemService): contain converted executable paths - this fork's sceSystemServiceLoadExec relaunches the host executable and has no converted-executable path to harden
  • 299a736 feat(libSceCesCs): build libSceCesCs-module from the libSceCesCs source - CMake layout differs (module builds from Export.cpp here)
  • 22f6b17 docs: keep the technical debt index and end the NGS2 entry with a newline - upstream per-library debt layout fix; not applicable to this fork's single TechnicalDebt.md
  • 9828710 feat(videoout): implement sceVideoOutGetOutputStatusWithVrr - Output.cpp output-config code differs from this fork's; needs a separate Metal-side port
  • e94f12b, 56d1eda (videoout DirectInput on Windows) - Windows-only
  • libc, libkernel, agc, shader, relinker, recompiler, tools and input commits in the range belong to other slices

Evidence

  • Rosetta x86_64 configure (-DANYPS5_ROSETTA_LIBS=ON): built nid_patcher, the rosetta_patch_* targets for AudioOut, AvPlayer(+native), CesCs, ConvertKeycode, Http2, Keyboard, Net, Ngs2(+native), NpAuth, OpusDec, PosixForWebKit, SaveData(+native), VideoOut, plus rosetta_libs and rosetta_engine; all built with no errors.
  • ctest audio_out2_*: 5/5 passed. NID python tests test_elf_layout, test_gnu_hash, test_symbol_versions, test_macho_nids: all pass.
  • The core/libs guest tests (SaveData, Net, Ngs2, Keyboard, Http2 and others) are not part of the Rosetta configuration and were not run; they were compiled only through the library targets above where applicable.
  • Game smoke (tools/smoke.sh, 130 s limit, no --map): first movie <= 27 s, main menu <= 51 s, leader select <= 63 s, map generation start <= 81 s, no fault, no uncaught exception. Run because AudioOut and SaveData behavior changed. Not compared against a main run in this session.
  • No performance claims.

🤖 Generated with Claude Code

MiniRML and others added 30 commits October 14, 2026 01:39
… after a pause

Clock::Reset left the paused flag set by Clock::Pause, so a Start issued
from the paused state (stop and restart of the source) kept the clock
frozen at the start position. Only the frame at that position was
delivered; later frames were held back by the default A/V sync.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
(cherry picked from commit a671dc4)
sceNetSend, sceNetSendto, sceNetRecv, sceNetRecvfrom, sceNetRecvmsg and
sceNetSendmsg failed with EOPNOTSUPP for any flag other than MSG_PEEK on
a receive, so a game polling a socket with MSG_DONTWAIT got an error on
every call instead of its data or EWOULDBLOCK.

FreeBSD 11.4 defines the flag in sys/sys/socket.h:

	#define	MSG_DONTWAIT	0x80		/* this message should be nonblocking */

and soreceive_generic() (sys/kern/uipc_socket.c) treats it like a
non-blocking socket for that one call:

		if ((so->so_state & SS_NBIO) ||
		    (flags & (MSG_DONTWAIT|MSG_NBIO))) {
			SOCKBUF_UNLOCK(&so->so_rcv);
			error = EWOULDBLOCK;
			goto release;

shadPS4's sceNet uses the same value (ORBIS_NET_MSG_DONTWAIT 0x80).

On Linux and macOS the flag now maps to the host's MSG_DONTWAIT, alone
or with MSG_PEEK on a receive. Winsock has no per-call non-blocking
flag, so Windows keeps failing with EOPNOTSUPP for it; TechnicalDebt
records that. Other flags still fail with EOPNOTSUPP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 44d46ee)
…3 fails

A title checks for its save with a CREATE2 mount it never
unmounts, then saves with a second mount of the same directory. That
mount returns BUSY, and the title keeps using the first mount point for
sceSaveDataPrepare, its save file and sceSaveDataUmount2.
sceSaveDataMount3 cleared the result before its checks, so the save was
written to "/save" in the game folder instead of the save directory, and
the first mount was never released. The result is now written only when
the mount succeeds, as shadPS4 does.

(cherry picked from commit 4ccf888)
Every native save reported SAVE_DATA_BLOCKS_MAX blocks, all of them free,
in the sceSaveDataDirNameSearch infos and in sceSaveDataGetMountInfo,
whatever the title created it with and whatever its files held. A save's
size is now the blocks of the sceSaveDataMount3 call that created it,
kept beside the save; a save without a kept size takes that of its next
mount that names one, and otherwise keeps SAVE_DATA_BLOCKS_MAX. Free
blocks are what the save's files leave of it, each file rounded up to
32 KiB blocks, and the blocks and free-blocks sort keys use both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4b7a357)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d34b788)
Implement getservbyname (H1bArJPagV0) in libScePosixForWebKit. A title imports it from this library only (registry index 408,
call site 0x1042124); once fnmatch (boykopovar#3545) is in, its predicted load
stop is:

    FAIL: unresolved ELF import H1bArJPagV0 from libScePosixForWebKit.prx

The ps5-payload-dev SDK stubs (f5d40f02, sce_stubs/) declare
getservbyname in libScePosixForWebKit.c and not in libkernel.c or
libSceLibcInternal.c. The call site is the service-name branch of a
getaddrinfo inside the title: a non-numeric service is looked up with
protocol "tcp", "udp" or "sctp" and the port is read big-endian at
offset 16 of the result, which fixes the servent layout used here
(name, aliases, 32-bit port, protocol at 0, 8, 16, 24).

The guest has no /etc/services and the console's file is unknown, so the
function searches 37 lines of FreeBSD 11.4 etc/services (8c639945):
ftp-data, ftp, ssh, telnet, smtp, domain, tftp, http, pop3, ntp, imap,
https, rtsp, submission, imaps and pop3s with their aliases and
protocols, in file order. None of their names or aliases appears on an
earlier line of the full file, so these lookups answer as the full file
would. The search follows files_servent in lib/libc/net/getservent.c
(8c639945): exact, case-sensitive match on the name or an alias, a null
protocol takes the first match, the port in network byte order, the
result in per-thread storage like getserv's NSS TLS state. Any other
name returns null without touching errno, as for a name the file lacks.
The repository's getaddrinfo still resolves service names through the
host, so there was no table to share; this is recorded in
TechnicalDebt.md.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 15bbc19)
…structible

The per-thread servent storage held std::string and std::vector
members, so getservbyname_nid_postfix registered a thread_local
destructor through __cxa_thread_atexit. On Windows that destructor runs
after emulated TLS freed the object, and prx_thread_local_destructors
(boykopovar#4029) rejects libScePosixForWebKit.prx for it.

The result now lives in a thread_local struct of fixed-size char arrays
and an alias pointer array, sized for the longest name (submission),
alias (www-http), protocol (sctp) and alias count in the embedded table;
static_asserts check the sizes against the table and that the struct is
trivially destructible. The guest servent layout and the per-thread
result FreeBSD's getservent.c keeps in its NSS TLS state are unchanged.
Nothing is allocated, so the ENOMEM path is gone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 8b9529b)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0afa191)
boykopovar#5173 changes the create condition right after the last error check, and boykopovar#3950 removes the comment after the create block, so clearing the result in either place made the pull requests conflict. The result is still cleared only after every error return and before anything is written to it.

(cherry picked from commit 6a46563)
A keyboard record on the console never counts fewer than one key: with
nothing held, and with no keyboard connected, the count is 1 and that
slot holds code 0. SharpProspero's keyboard reader, PS5_Quake3e's notes
on records read from a console and the PS5 input research notes all say
so. AnyPS5 reported a count of 0. The count is now at least 1; the key
slots themselves are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 8ea8ea3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit cb8b0ca)
…or the US layout

The signature is inferred from a title call: a 16-bit keycode, a second
argument the title passes as 0, the type from
sceConvertKeycodeGetImeKeyboardType and a UTF-16 output. The keycode is a
USB HID keyboard usage and the unshifted US character is returned; a
keycode without a character returns 0. A second argument or keyboard type
other than 0 throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5ca6487)
Resolve a host name to its first IPv6 address through the host resolver
(getaddrinfo with AF_INET6) and write the 16-byte address. The lookup
shares the IPv4 path's resolver bookkeeping (abort preservation, error
state); a name without an IPv6 address fails with RESOLVER_ENODNS like a
failed lookup. Nonzero flags throw.

A title imports it and failed to
load without it (unresolved zl35YNs9jnI from libSceNet.prx).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit df32a44)
sceNetConnect() on a connected datagram socket rejected an address
whose family is AF_UNSPEC (a null address) with EINVAL before touching
the socket, so the socket stayed connected: sceNetGetpeername() still
reported the old peer and datagrams from any other sender were dropped
by the host.

FreeBSD 11.4 disconnects a connected datagram socket first and only then
looks at the address. sys/kern/uipc_socket.c, soconnectat():

	 * If protocol is connection-based, can only connect once.
	 * Otherwise, if connected, try to disconnect first.  This allows
	 * user to disconnect by connecting to, e.g., a null address.
	 */
	if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING) &&
	    ((so->so_proto->pr_flags & PR_CONNREQUIRED) ||
	    (error = sodisconnect(so)))) {

udp_disconnect() (sys/netinet/udp_usrreq.c) clears the peer and keeps
the local port. connect(2): "Datagram sockets may dissolve the
association by connecting to an invalid address, such as a null
address." libkernel's connect gets the same change in boykopovar#4498.

A connected datagram socket given an address whose family byte is 0 is
now disconnected on the host first (AF_UNSPEC on Linux, a zeroed
address of the socket's family on Windows), and the call then fails
with EINVAL as before. Linux also drops an ephemeral local port on that
disconnect, so the port is bound again on the wildcard address, which
is what FreeBSD leaves. A host failure during the disconnect is
returned as the call's error. Stream sockets keep the previous path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 65d56b3)
…SD does

Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit fce9538)
FFmpeg resamples narrowband SILK (TOC configurations 0-3) from 8 kHz and
holds back 24 samples of the first narrowband packet after the decoder
starts or after a packet of another bandwidth: a 20 ms packet decodes to
936 samples and the next wider packet to 984. sceOpusDecDecode required
exactly the packet's duration and threw, so ProsperoRadio aborted on a
narrowband Opus station.

The decoder now keeps FFmpeg's output in a queue and returns exactly the
packet's duration, as libopus does: the first narrowband packet starts
with 24 samples of silence and the held-back samples follow in the next
calls. The new test decodes three libopus 6 kb/s narrowband packets and
a wideband packet after them; it aborts on main.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit fb41f10)
…tests for 0x13 issue case

(cherry picked from commit ef52b16)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RINNECODER RINNECODER added the upstream-sync Upstream boykopovar/AnyPS5 intake label Oct 14, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T07:59:14.697957Z 138f4f2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: edc33fd8-4599-45d8-b76d-19d6a5a341c4
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 138f4f2f9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +103 to +105
if ((param.id & ~0x1fu) == SCE_NGS2_CUSTOM_VOICE_PARAM_FILTER) {
if (rackId != SCE_NGS2_RACK_ID_CUSTOM_SAMPLER && rackId != SCE_NGS2_RACK_ID_CUSTOM_SUBMIXER) {
throw std::invalid_argument("NGS2: voice param " + Ngs2Hex(param.id) + " belongs to another rack");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Apply filters to custom-submixer voices

When a custom-submixer rack contains module 0x13, this branch accepts its filter parameter and populates voice.filters, but RenderVoice routes custom submixers through MixInputs; only RenderSampler calls ApplyFilter. Consequently the call succeeds while the mixed audio remains completely unfiltered. Either apply the filter chain after mixing custom-submixer inputs or reject this rack type.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real. Custom-submixer voices now run their filter chain after mixing; fixed in #497

Comment on lines +335 to +336
case SCE_NGS2_RACK_ID_SAMPLER:
case SCE_NGS2_RACK_ID_CUSTOM_SAMPLER: ApplySamplerParam(voice, param); return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Return sampler state for custom-sampler voices

Custom-sampler voices now accept the sampler setup, waveform, and pitch controls, but sceNgs2VoiceGetState still handles only SCE_NGS2_RACK_ID_SAMPLER and falls into its throwing default for rack 0x4001. A title that polls normal sampler fields such as decoded bytes or waveform position after using the newly supported rack will therefore terminate instead of receiving Ngs2SamplerVoiceState; the custom sampler should share the sampler state case.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not real. sceNgs2VoiceGetState already has a SCE_NGS2_RACK_ID_CUSTOM_SAMPLER case returning Ngs2CustomSamplerVoiceState, a distinct 48-byte struct with its own size check and an existing test. Returning the sampler struct would break that size contract. No change (#497).

Comment on lines +245 to +246
if (voice.rack->rackId == SCE_NGS2_RACK_ID_SAMPLER || voice.rack->rackId == SCE_NGS2_RACK_ID_CUSTOM_SAMPLER) {
RenderSampler(voice, grain, systemRate);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report drained custom-sampler streams as empty

Although rack 0x4001 is rendered as a sampler here, the post-render state calculation still adds SCE_NGS2_VOICE_STATE_FLAG_EMPTY only for the standard sampler rack. Thus a custom sampler using CONTINUE never reports that its queued blocks are exhausted through sceNgs2VoiceGetStateFlags, so producers waiting for EMPTY before appending or reusing the voice can stall.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real. The EMPTY flag is now also reported for drained custom-sampler streams; fixed in #497

@RINNECODER
RINNECODER merged commit b7c97bf into main Oct 14, 2026
6 checks passed
@RINNECODER
RINNECODER deleted the sync9/libs branch October 14, 2026 08:13
RINNECODER added a commit that referenced this pull request Oct 14, 2026
…s) (#497)

* Address Codex review findings left on merged #489, #493, #494

NGS2: custom-submixer voices now run their filter chain after mixing; a
drained custom-sampler stream reports the EMPTY state flag like a
sampler. AJM M4AAC: the first non-delay frame is sized from the ADTS
channel configuration and one AAC-LC frame before FFmpeg consumes it.
tools: unwrap_self reads the SELF record table from 0x20 bounded by the
header entry count, keeps only data records and assigns each by its
encoded program index (duplicates refused); check_compile keys compile
commands against the repository root so sibling build trees work.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

* AJM M4AAC: size the first raw frame by the configured channel count

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream-sync Upstream boykopovar/AnyPS5 intake

Projects

None yet

Development

Successfully merging this pull request may close these issues.