Repository navigation
fix(libSceNgs2): reset the geometry parameters to the console's values - #17673
Merged
oneandonlydean merged 3 commits intoNov 12, 2026
Merged
Conversation
…stenerParam and ResetSourceParam On a PS5 (firmware 11.60, payload process) the listener reset writes front (0, 0, -1) and a sound speed of 340.29 and the source reset writes a zero direction, cone 1.0/30.0/0.2/60.0, rolloff model 5 with max distance 100.0, lfe level 0, radius 1.0, 7 speakers and matrix format 8. Both leave the reserved words untouched. The transform tests keep their own front axis and sound speed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
sceNgs2GeomResetListenerParam and sceNgs2GeomResetSourceParam wrote defaults that differ from a PS5 in two listener and ten source fields, and zeroed the reserved words the console leaves untouched. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
Probe sources (built with ps5-payload-sdk v0.45; sceNgs2GeomResetListenerParam probe.c (run at 04:24 UTC)/* Probe E: sceNgs2GeomResetListenerParam, sceNgs2GeomResetSourceParam and sceNgs2GeomCalcListener, payload process,
firmware 11.60 (debt libSceNgs2.native.md:89 and :90: the defaults the reset calls write, the structure sizes and
the transform that CalcListener builds were taken from emulators and are not measured on a PS5). The three calls
only fill caller-owned buffers: no system, rack or voice is created and nothing is rendered. The output buffers
are 512 bytes filled with a marker; the number of changed bytes and the changed region are printed as hex words
(floats), so no handle, user or device data can appear. CalcListener gets the reset listener parameter as its
input with flags 0 and 1. No NULL pointer is passed. There is no initialization call for these functions. Nothing
is written, nothing is sent. */
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h> /* only for kernel_get_fw_version() */
#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: the runner can only close the connection, it cannot end the process on the console, so the probe ends
itself after PROBE_MAX_S seconds at the latest (set by the build script). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif
static void probe_alarm(int sig) {
static const char msg[] = "TIMEOUT\tprobe self limit\n";
(void)sig;
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
}
/* Watchdog thread: alarm()/SIGALRM does not help when the main thread hangs in a blocking system call or IPC. The
thread sleeps PROBE_MAX_S seconds, writes TIMEOUT with write() and ends the process with _exit(124). alarm() stays
as a second safeguard. */
static void* probe_watchdog(void* arg) {
static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
unsigned left = PROBE_MAX_S;
(void)arg;
while (left) left = sleep(left);
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
return 0;
}
static void probe_watchdog_start(void) {
pthread_t t;
if (pthread_create(&t, 0, probe_watchdog, 0) == 0) pthread_detach(t);
}
static int cases = 0;
static void probe_header(void) {
char utc[32];
time_t now = time(0);
probe_watchdog_start();
struct tm tmv;
gmtime_r(&now, &tmv);
strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
getpid(), utc);
fflush(stdout);
}
static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
fflush(stdout);
cases++;
}
static void probe_end(void) {
printf("END\t%d\n", cases);
fflush(stdout);
}
typedef int (*fn_reset)(void*);
typedef int (*fn_calc)(const void*, void*, unsigned);
#define BUF 512
static void dump(const char* id, const char* call, long r, int e, const unsigned char* buf) {
char extra[1200];
int changed = 0, last = -1;
for (int b = 0; b < BUF; ++b)
if (buf[b] != 0x5a) { changed++; last = b; }
int words = last < 0 ? 0 : (last / 4) + 1;
int n = snprintf(extra, sizeof extra, "0x%08x changed_bytes=%d last_changed_offset=%d words=", (unsigned)r, changed, last);
for (int w = 0; w < words && n < (int)sizeof extra - 12; ++w) {
unsigned v;
memcpy(&v, buf + w * 4, 4);
n += snprintf(extra + n, sizeof extra - n, "%08x%s", v, w + 1 < words ? " " : "");
}
probe_case(id, call, r, e, extra);
}
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
probe_header();
errno = 0;
void* lib = dlopen("libSceNgs2.sprx", RTLD_LAZY);
probe_case("0", "load libSceNgs2.sprx", lib ? 0 : -1, errno, lib ? "loaded" : dlerror());
if (!lib) { probe_end(); return 0; }
fn_reset resetListener = (fn_reset)dlsym(lib, "sceNgs2GeomResetListenerParam");
fn_reset resetSource = (fn_reset)dlsym(lib, "sceNgs2GeomResetSourceParam");
fn_calc calc = (fn_calc)dlsym(lib, "sceNgs2GeomCalcListener");
char extra[64];
snprintf(extra, sizeof extra, "reset_listener=%d reset_source=%d calc=%d", resetListener != 0, resetSource != 0, calc != 0);
probe_case("0b", "dlsym of the Geom functions", (resetListener && resetSource && calc) ? 0 : -1, 0, extra);
if (!resetListener || !resetSource || !calc) { probe_end(); return 0; }
static unsigned char listener[BUF];
static unsigned char source[BUF];
static unsigned char work[BUF];
memset(listener, 0x5a, sizeof listener);
errno = 0;
long r = resetListener(listener);
dump("1", "sceNgs2GeomResetListenerParam(¶m)", r, errno, listener);
memset(source, 0x5a, sizeof source);
errno = 0;
r = resetSource(source);
dump("2", "sceNgs2GeomResetSourceParam(¶m)", r, errno, source);
/* CalcListener input: the reset listener parameter without the marker bytes behind it. */
static unsigned char input[BUF];
memset(input, 0, sizeof input);
memcpy(input, listener, 64);
memset(work, 0x5a, sizeof work);
errno = 0;
r = calc(input, work, 0);
dump("3", "sceNgs2GeomCalcListener(reset param, &work, flags 0)", r, errno, work);
memset(work, 0x5a, sizeof work);
errno = 0;
r = calc(input, work, 1);
dump("4", "sceNgs2GeomCalcListener(reset param, &work, flags 1)", r, errno, work);
probe_end();
return 0;
}raw output (run at 04:24 UTC)sceNgs2GeomResetListenerParam probe.c (run at 04:54 UTC)/* Probe E: sceNgs2GeomResetListenerParam, sceNgs2GeomResetSourceParam and sceNgs2GeomCalcListener, payload process,
firmware 11.60 (debt libSceNgs2.native.md:89 and :90: the defaults the reset calls write, the structure sizes and
the transform that CalcListener builds were taken from emulators and are not measured on a PS5). The three calls
only fill caller-owned buffers: no system, rack or voice is created and nothing is rendered. The output buffers
are 512 bytes filled with a marker; the number of changed bytes and the changed region are printed as hex words
(floats), so no handle, user or device data can appear. CalcListener gets the reset listener parameter as its
input with flags 0 and 1. No NULL pointer is passed. There is no initialization call for these functions. Nothing
is written, nothing is sent. */
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h> /* only for kernel_get_fw_version() */
#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: the runner can only close the connection, it cannot end the process on the console, so the probe ends
itself after PROBE_MAX_S seconds at the latest (set by the build script). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif
static void probe_alarm(int sig) {
static const char msg[] = "TIMEOUT\tprobe self limit\n";
(void)sig;
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
}
/* Watchdog thread: alarm()/SIGALRM does not help when the main thread hangs in a blocking system call or IPC. The
thread sleeps PROBE_MAX_S seconds, writes TIMEOUT with write() and ends the process with _exit(124). alarm() stays
as a second safeguard. */
static void* probe_watchdog(void* arg) {
static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
unsigned left = PROBE_MAX_S;
(void)arg;
while (left) left = sleep(left);
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
return 0;
}
static void probe_watchdog_start(void) {
pthread_t t;
if (pthread_create(&t, 0, probe_watchdog, 0) == 0) pthread_detach(t);
}
static int cases = 0;
static void probe_header(void) {
char utc[32];
time_t now = time(0);
probe_watchdog_start();
struct tm tmv;
gmtime_r(&now, &tmv);
strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
getpid(), utc);
fflush(stdout);
}
static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
fflush(stdout);
cases++;
}
static void probe_end(void) {
printf("END\t%d\n", cases);
fflush(stdout);
}
typedef int (*fn_reset)(void*);
typedef int (*fn_calc)(const void*, void*, unsigned);
#define BUF 512
static void dump(const char* id, const char* call, long r, int e, const unsigned char* buf) {
char extra[1200];
int changed = 0, last = -1;
for (int b = 0; b < BUF; ++b)
if (buf[b] != 0x5a) { changed++; last = b; }
int words = last < 0 ? 0 : (last / 4) + 1;
int n = snprintf(extra, sizeof extra, "0x%08x changed_bytes=%d last_changed_offset=%d words=", (unsigned)r, changed, last);
for (int w = 0; w < words && n < (int)sizeof extra - 12; ++w) {
unsigned v;
memcpy(&v, buf + w * 4, 4);
n += snprintf(extra + n, sizeof extra - n, "%08x%s", v, w + 1 < words ? " " : "");
}
probe_case(id, call, r, e, extra);
}
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
probe_header();
errno = 0;
void* lib = dlopen("libSceNgs2.sprx", RTLD_LAZY);
probe_case("0", "load libSceNgs2.sprx", lib ? 0 : -1, errno, lib ? "loaded" : dlerror());
if (!lib) { probe_end(); return 0; }
fn_reset resetListener = (fn_reset)dlsym(lib, "sceNgs2GeomResetListenerParam");
fn_reset resetSource = (fn_reset)dlsym(lib, "sceNgs2GeomResetSourceParam");
fn_calc calc = (fn_calc)dlsym(lib, "sceNgs2GeomCalcListener");
char extra[64];
snprintf(extra, sizeof extra, "reset_listener=%d reset_source=%d calc=%d", resetListener != 0, resetSource != 0, calc != 0);
probe_case("0b", "dlsym of the Geom functions", (resetListener && resetSource && calc) ? 0 : -1, 0, extra);
if (!resetListener || !resetSource || !calc) { probe_end(); return 0; }
static unsigned char listener[BUF];
static unsigned char source[BUF];
static unsigned char work[BUF];
memset(listener, 0x5a, sizeof listener);
errno = 0;
long r = resetListener(listener);
dump("1", "sceNgs2GeomResetListenerParam(¶m)", r, errno, listener);
memset(source, 0x5a, sizeof source);
errno = 0;
r = resetSource(source);
dump("2", "sceNgs2GeomResetSourceParam(¶m)", r, errno, source);
/* CalcListener input: only the 52 bytes the reset call wrote (case 1); everything behind them is zero. The first run copied 64 bytes and so passed 12 marker bytes (0x5a) as part of the input. */
static unsigned char input[BUF];
memset(input, 0, sizeof input);
memcpy(input, listener, 52);
memset(work, 0x5a, sizeof work);
errno = 0;
r = calc(input, work, 0);
dump("3", "sceNgs2GeomCalcListener(reset param, &work, flags 0)", r, errno, work);
memset(work, 0x5a, sizeof work);
errno = 0;
r = calc(input, work, 1);
dump("4", "sceNgs2GeomCalcListener(reset param, &work, flags 1)", r, errno, work);
probe_end();
return 0;
}raw output (run at 04:54 UTC)AI-assisted (Claude Code). 🤖 Generated with Claude Code |
Contributor
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sceNgs2GeomResetListenerParamandsceNgs2GeomResetSourceParamwrote defaults that differ from a PS5 in two listener fields and ten source fields, and zeroed the reserved words that the console leaves untouched. They now write what a PS5 wrote: listener front (0, 0, -1) and sound speed 340.29; source direction (0, 0, 0), cone 1.0/30.0/0.2/60.0, rolloff model 5 with a maximum distance of 100.0, LFE level 0, radius 1.0, 7 speakers and matrix format 8. Position, velocity and up axis of the listener, the doppler factor, the full-band, maximum and minimum levels and the rolloff factor and reference distance already matched. The transform tests keep their own front axis and sound speed. A title process was not measured; PPSA15552 (Dead Cells) is the title the debt entry names as callingsceNgs2GeomResetSourceParam.sceNgs2GeomApplyderives its channel count frommatrix_format, so a source reset by a title now yields an 8-channel matrix instead of a 2-channel one; this was not run with the title.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-09 at 04:24 UTC and 04:54 UTC (two runs, identical); the console's own clock read about 1 h 41 min more (see the first comment). A title process may differ.mainbeforeorient_frontsound_speeddirectionconerolloffmodel, max distancelfe_level,radiusnum_speakers,matrix_formatreservedwords (listener bytes 52 to 59, source bytes 100 to 107)The tests
ngs2_geomnow expect these values. On Ubuntu 24.04 under WSL2 with GCC 13.3.0 and an AddressSanitizer build, onmain0ef5a14e6athe test commit alone aborts, and with the fix commit on the samemainit passes; all 48ngs2*tests pass with this change when leak detection is off; with it on, 27 of the 48 fail on LeakSanitizer reports (ngs2_geompasses), which I did not compare withmain.tools/check_conventions.py --base upstream/mainpasses.Overlap: the 8 other open pull requests that change
Geom.cpp,Ngs2Geom.cppordocs/dev/debt/libSceNgs2.native.mdwere checked on 2026-11-09 between 08:25 UTC and 08:32 UTC againstmain75c65bf005(the base of this change is the older0ef5a14e6a; it still merges without a conflict). Three already conflict withmainwithout this change (#5548, #12107 and #14212), and none conflicts only with this change. The other five merge cleanly with and without it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted (Claude Code).
🤖 Generated with Claude Code