Repository navigation
Conversation
A PS5 on firmware 11.60 (payload process) reports 2 channels, flag 0 and active state 0 from sceAudioOutGetPortState for a main port opened as 48 kHz, 1024 frames, 16-bit stereo, before and after one output. Pin those fields. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Probe source (built with ps5-payload-sdk v0.45; /* Probe E: sceAudioOutGetLastOutputTime and sceAudioOutGetPortState, payload process, firmware 11.60 (debt
libSceAudioOut.md: what the last output time is, and the answer before any output). One port is opened with
sceAudioOutOpen(0xff, 0, 0, 1024, 48000, 0x1), one block of silence (1024 samples, 16-bit stereo, all zero) is output
and the port is closed. The output time is printed raw and as the difference to sceKernelGetProcessTime() taken
just before and just after the output call. The port state record is a 64-byte marker buffer: only the return
code, the number of changed bytes and its first 16 bytes are printed. No user ID of a person is used (0xff is the
system user). 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_init)(void);
typedef int (*fn_open)(int, int, int, unsigned, unsigned, unsigned);
typedef int (*fn_close)(int);
typedef int (*fn_output)(int, const void*);
typedef int (*fn_lastout)(int, uint64_t*);
typedef int (*fn_portstate)(int, void*);
typedef uint64_t (*fn_proctime)(void);
static fn_lastout aoLast;
static fn_portstate aoState;
static fn_proctime procTime;
static uint64_t now_us(void) { return procTime ? procTime() : 0; }
static void last_case(const char* id, const char* call, int handle, uint64_t t0, uint64_t t1) {
uint64_t v = 0xdeadbeefdeadbeefULL;
char extra[160];
errno = 0;
long r = aoLast(handle, &v);
int e = errno;
if (v == 0xdeadbeefdeadbeefULL)
snprintf(extra, sizeof extra, "0x%08x value=untouched", (unsigned)r);
else
snprintf(extra, sizeof extra, "0x%08x value=%llu delta_to_before=%lld delta_to_after=%lld", (unsigned)r,
(unsigned long long)v, (long long)(v - t0), (long long)(v - t1));
probe_case(id, call, r, e, extra);
}
static void state_case(const char* id, const char* call, int handle) {
unsigned char buf[64];
char extra[160];
memset(buf, 0x5a, sizeof buf);
errno = 0;
long r = aoState(handle, buf);
int e = errno;
int changed = 0;
for (size_t b = 0; b < sizeof buf; ++b)
if (buf[b] != 0x5a) changed++;
snprintf(extra, sizeof extra, "0x%08x changed=%d first16=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
(unsigned)r, changed, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10],
buf[11], buf[12], buf[13], buf[14], buf[15]);
probe_case(id, call, r, e, extra);
}
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
char extra[64];
probe_header();
errno = 0;
void* lib = dlopen("libSceAudioOut.sprx", RTLD_LAZY);
probe_case("0", "load libSceAudioOut.sprx", lib ? 0 : -1, errno, lib ? "loaded" : dlerror());
if (!lib) { probe_end(); return 0; }
fn_init aoInit = (fn_init)dlsym(lib, "sceAudioOutInit");
fn_open aoOpen = (fn_open)dlsym(lib, "sceAudioOutOpen");
fn_close aoClose = (fn_close)dlsym(lib, "sceAudioOutClose");
fn_output aoOutput = (fn_output)dlsym(lib, "sceAudioOutOutput");
aoLast = (fn_lastout)dlsym(lib, "sceAudioOutGetLastOutputTime");
aoState = (fn_portstate)dlsym(lib, "sceAudioOutGetPortState");
procTime = (fn_proctime)dlsym(RTLD_DEFAULT, "sceKernelGetProcessTime");
if (!aoInit || !aoOpen || !aoClose || !aoOutput || !aoLast || !aoState) {
probe_case("0b", "dlsym of the audio out functions", -1, 0, "missing");
probe_end();
return 0;
}
probe_case("0c", "dlsym(sceKernelGetProcessTime)", procTime ? 0 : -1, 0, procTime ? "found" : "missing");
errno = 0;
long r = aoInit();
snprintf(extra, sizeof extra, "0x%08x", (unsigned)r);
probe_case("1", "sceAudioOutInit()", r, errno, extra);
if (r != 0) { probe_end(); return 0; } /* no further call without a successful init */
errno = 0;
long h = aoOpen(0xff, 0, 0, 1024, 48000, 0x1);
snprintf(extra, sizeof extra, "0x%08x", (unsigned)h);
probe_case("2", "sceAudioOutOpen(0xff, 0, 0, 1024, 48000, 0x1)", h, errno, extra);
if (h <= 0) { probe_end(); return 0; }
state_case("3", "sceAudioOutGetPortState(own port, &state)", (int)h);
last_case("4", "sceAudioOutGetLastOutputTime(own port) before any output", (int)h, 0, 0);
static short block[2048]; /* 1024 samples, stereo, all zero */
memset(block, 0, sizeof block);
uint64_t t0 = now_us();
errno = 0;
r = aoOutput((int)h, block);
uint64_t t1 = now_us();
snprintf(extra, sizeof extra, "0x%08x took_us=%llu", (unsigned)r, (unsigned long long)(t1 - t0));
probe_case("5", "sceAudioOutOutput(own port, one silent block)", r, errno, extra);
last_case("6", "sceAudioOutGetLastOutputTime(own port) after one output", (int)h, t0, t1);
state_case("7", "sceAudioOutGetPortState(own port) after output", (int)h);
errno = 0;
long c = aoClose((int)h);
snprintf(extra, sizeof extra, "0x%08x", (unsigned)c);
probe_case("8", "sceAudioOutClose(own port)", c, errno, extra);
last_case("9", "sceAudioOutGetLastOutputTime(closed handle)", (int)h, t0, t1);
state_case("10", "sceAudioOutGetPortState(closed handle)", (int)h);
last_case("11", "sceAudioOutGetLastOutputTime(handle -1)", -1, t0, t1);
state_case("12", "sceAudioOutGetPortState(handle -1)", -1);
probe_end();
return 0;
}Raw output: |
|
Independent Windows focused test of PR head |
|
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. |
|
The red
AI-assisted. |
|
Windows check of head Setup: Windows 11 x64, WinLibs GCC 15.2.0 (r7), Ninja, Release,
AI-assisted: yes. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this test addition; the observed behavior is consistent with the implementation.
What I ran
Reviewed head 86ee758c55f406e0412c01f02e37512b7f31473d. No commands or tests were run in this review.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed files | passed | Both changed files read |
| Implementation context | passed | State query and port open paths read |
| Tests | not run | No checks executed |
Findings
Blocking
None.
Non-blocking
None.
Not verified
Did not run the new test or build it. The manifest lists two reviewed files, and both full texts were read. files.json was unavailable through the reader, so excluded files are not verified. The PR description's console and CI reports were not independently confirmed.
To get this to a good state
Nothing is required.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
What
Adds the test
audio_out_port_state(newAudioOutPortState.cpp): a main port opened withsceAudioOutOpen(user, 0, 0, 1024, 48000, 1)(16-bit stereo) must reportchannel == 2,flag == 0andactiveState == 0fromsceAudioOutGetPortState, before and after one output of 1024 silent frames.mainalready behaves this way, so the test passes onmainunchanged and only fixes the console value in place.The fields
output,volumeandrerouteCounterare not pinned: the console reported output 0, volume -1 and rerouteCounter 5 there, and AnyPS5 reports 1, 127 and 0.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-07 at 04:56 UTC (the console clock was about 1 h 41 min ahead), one run.sceAudioOutGetPortStatereturned 0 and a 16-byte record with channel 2 and flag and active state 0, the same before and after the output. A title process may differ. The probe source and its raw output are in the first comment.On Ubuntu 24.04 under WSL2 with an AddressSanitizer and UBSan build (
BUILD_TESTING=ON),ctest -R audio_out_port_statepasses onmainb0e5efb708. ChangingAudioOut.cppso that a stereo port reports 3 channels makes it fail.tools/check_conventions.py --base upstream/mainpasses.Overlap: the 20 other open pull requests that change the library's
CMakeLists.txtorAudioOutBufferSize.cpp(the files that touch this change'sCMakeLists.txtlines) were checked on 2026-11-08 between 21:35 UTC and 21:43 UTC againstmain0bae53facd(the base of this change is the olderb0e5efb708; it still merges without a conflict, andsceAudioOutGetPortStateis unchanged between the two). Four already conflict withmainwithout this change (#12863, #5021, #12315 and #14212), and none conflicts only with this change. The other sixteen merge cleanly with and without it, among them #17546, #16737, #16736, #16641, #16614 and #16597.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