Merge pull request #15740 from akkadbakkad89/feat/audioout2-ex-signatures
feat(libSceAudioOut): verify eleven audio-out2 exports against the 4.03 module
This commit is contained in:
13 files changed
+272
-76
No files matched your search
@@ -50,7 +50,7 @@ int APS5_VABI sceAudioOut2DisableChat(void);
|
||||
int APS5_VABI sceAudioOut2UserCreate(uint32_t userId, AudioOut2UserHandle* handle);
|
||||
int APS5_VABI sceAudioOut2UserDestroy(AudioOut2UserHandle handle);
|
||||
int APS5_VABI sceAudioOut2UserGetSupportedAttributes(AudioOut2UserHandle handle, uint32_t* contextAttributes, uint32_t* portAttributes);
|
||||
int APS5_VABI sceAudioOut2UserCreateEx(void);
|
||||
int APS5_VABI sceAudioOut2UserCreateEx(uint32_t userId, const void* attributes, AudioOut2UserHandle* handle);
|
||||
int APS5_VABI sceAudioOut2ArbitrationInitialize(void);
|
||||
int APS5_VABI sceAudioOut2MbusInit(void);
|
||||
int APS5_VABI sceAudioOut2MbusSetPortConnections(void);
|
||||
@@ -68,11 +68,11 @@ int APS5_VABI sceAudioOut2ReportRegisterHandler(void);
|
||||
int APS5_VABI sceAudioOut2ReportUnregisterHandler(void);
|
||||
int APS5_VABI sceAudioOut2GetTvCorrectionInfo(void);
|
||||
int APS5_VABI sceAudioOut2GetIpcHandle(void);
|
||||
int APS5_VABI sceAudioOut2GetSystemStateEx(void);
|
||||
int APS5_VABI sceAudioOut2GetSystemStateEx(void* state);
|
||||
int APS5_VABI sceAudioOut2SetDebugHeadphoneMode(void);
|
||||
int APS5_VABI sceAudioOut2DebugStateCtrl(void);
|
||||
int APS5_VABI sceAudioOut2ContextBedWrite(void);
|
||||
int APS5_VABI sceAudioOut2PortCreateEx(void);
|
||||
int APS5_VABI sceAudioOut2ContextBedWrite(AudioOut2ContextHandle ctx, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint32_t layout, uint8_t flag);
|
||||
int APS5_VABI sceAudioOut2PortCreateEx(AudioOut2ContextHandle ctx, const AudioOut2PortParam* params, AudioOut2PortHandle* port);
|
||||
int APS5_VABI sceAudioOut2Terminate(void);
|
||||
int APS5_VABI sceAudioOut2PortRegister(void);
|
||||
int APS5_VABI sceAudioOut2PortUnregister(void);
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceAudioOut2GetSystemDebugState();
|
||||
int APS5_VABI sceAudioOut2LoContextCreateEx();
|
||||
int APS5_VABI sceAudioOut2LoContextGetAttributes();
|
||||
int APS5_VABI sceAudioOut2LoContextQueryMemoryEx();
|
||||
int APS5_VABI sceAudioOut2LoPortCreateEx();
|
||||
int APS5_VABI sceAudioOut2LoPortGetAttributes();
|
||||
int APS5_VABI sceAudioOut2LoPortSetAttributesEx();
|
||||
int APS5_VABI sceAudioOut2LoContextCreateEx(const AudioOut2ContextParam* params, const void* exParams, void* buffer, size_t bufferSize, AudioOut2ContextHandle* ctx);
|
||||
int APS5_VABI sceAudioOut2LoContextGetAttributes(AudioOut2ContextHandle ctx, AudioOut2Attribute* attributes, uint32_t num);
|
||||
int APS5_VABI sceAudioOut2LoContextQueryMemoryEx(const AudioOut2ContextParam* params, const void* exParams, size_t* memorySize);
|
||||
int APS5_VABI sceAudioOut2LoPortCreateEx(AudioOut2ContextHandle ctx, const AudioOut2PortParam* params, AudioOut2PortHandle* port);
|
||||
int APS5_VABI sceAudioOut2LoPortGetAttributes(AudioOut2PortHandle port, AudioOut2Attribute* attributes, uint32_t num);
|
||||
int APS5_VABI sceAudioOut2LoPortSetAttributesEx(AudioOut2PortHandle port, const AudioOut2Attribute* attributes, uint32_t num);
|
||||
int APS5_VABI sceAudioOut2PortSetAttributesEx();
|
||||
int APS5_VABI sceAudioOut2SetHrtfIdForCronos();
|
||||
int APS5_VABI sceAudioOut2SetSpeakerInfo();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
using Clock = std::chrono::steady_clock;
|
||||
|
||||
static constexpr std::size_t CONTEXT_MEMORY = 0x10000;
|
||||
static constexpr std::uint32_t DEFAULT_MAX_PORTS = 16;
|
||||
static constexpr std::uint32_t DEFAULT_MAX_PORTS = 8;
|
||||
// Pushes, polls and advances traced individually before the trace falls back to the per-second summary.
|
||||
static constexpr std::uint64_t CALL_TRACE_FULL = 16;
|
||||
// Grains the device waits for before it starts playing (and again whenever it ran dry), so the
|
||||
@@ -72,6 +72,18 @@ AudioOut2Context* AudioOut2FindContext(AudioOut2ContextHandle ctx) {
|
||||
return found == g_contexts.end() ? nullptr : *found;
|
||||
}
|
||||
|
||||
void AudioOut2DestroyAllContexts() {
|
||||
for (;;) {
|
||||
AudioOut2ContextHandle handle = 0;
|
||||
{
|
||||
std::lock_guard lock(g_contextsLock);
|
||||
if (g_contexts.empty()) return;
|
||||
handle = reinterpret_cast<AudioOut2ContextHandle>(*g_contexts.begin());
|
||||
}
|
||||
sceAudioOut2ContextDestroy(handle);
|
||||
}
|
||||
}
|
||||
|
||||
static Clock::duration GrainDuration(const AudioOut2Context& context) {
|
||||
return std::chrono::duration_cast<Clock::duration>(std::chrono::duration<double>(static_cast<double>(context.grain) / AUDIO_OUT2_SAMPLE_RATE));
|
||||
}
|
||||
@@ -489,4 +501,12 @@ int APS5_VABI sceAudioOut2ContextSetAttributes(AudioOut2ContextHandle ctx, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2ContextBedWrite(AudioOut2ContextHandle ctx, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint32_t layout, uint8_t flag) {
|
||||
constexpr int ErrorInvalidParam = static_cast<int>(0x80268001);
|
||||
(void)arg2; (void)arg3; (void)arg4; (void)arg5; (void)layout; (void)flag;
|
||||
if (!AudioOut2FindContext(ctx)) return ErrorInvalidParam;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,6 +136,7 @@ struct AudioOut2Context {
|
||||
};
|
||||
|
||||
AudioOut2Context* AudioOut2FindContext(AudioOut2ContextHandle ctx);
|
||||
void AudioOut2DestroyAllContexts();
|
||||
|
||||
// Mixes every port of the context that carries PCM data into out (stereo float, frames frames), summing
|
||||
// onto the zeroed buffer. Returns the number of ports mixed.
|
||||
|
||||
@@ -1,10 +1,44 @@
|
||||
#include "prx/libSceAudioOut/include/AudioOut2.hpp"
|
||||
#include "prx/libSceAudioOut/include/InventoryExports.hpp"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
#include "AudioOut2Internal.hpp"
|
||||
|
||||
static int AudioOut2QueryMemoryLo(const AudioOut2ContextParam* params, const std::uint32_t* exParams, std::size_t* memory_size) {
|
||||
constexpr int ErrorInvalidParam = static_cast<int>(0x80268001);
|
||||
constexpr int ErrorInvalidGrains = static_cast<int>(0x8026800d);
|
||||
if (!params) return ErrorInvalidParam;
|
||||
if (params->max_object_ports > 0x80) return ErrorInvalidParam;
|
||||
if (params->max_ports > 0x20) return ErrorInvalidParam;
|
||||
if (params->guarantee_object_ports > params->max_object_ports) return ErrorInvalidParam;
|
||||
if (params->num_grains < 0x100 || params->num_grains > 0x800 || (params->num_grains & 0xff) != 0) return ErrorInvalidGrains;
|
||||
const std::uint32_t extra_ports = exParams ? exParams[0] : 0;
|
||||
if (exParams && extra_ports > 0x15) return ErrorInvalidParam;
|
||||
if (params->queue_depth > (exParams ? 0x40u : 0x10u)) return ErrorInvalidParam;
|
||||
if (memory_size) {
|
||||
const auto slot_words = [](std::uint32_t n) { return 0xc + ((n + 0x1f) >> 5) * 4; };
|
||||
*memory_size = static_cast<std::size_t>(params->max_ports + extra_ports + params->max_object_ports) * 0xb60
|
||||
+ static_cast<std::size_t>(slot_words(params->max_ports) + slot_words(params->max_object_ports))
|
||||
+ (exParams ? static_cast<std::size_t>(slot_words(extra_ports)) : 0)
|
||||
+ ((static_cast<std::size_t>(params->max_object_ports) * 24 + 0x7f) & ~static_cast<std::size_t>(0x7f));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int AudioOut2CreateContextLo(const AudioOut2ContextParam* params, const std::uint32_t* exParams, void* buffer, std::size_t buffer_size, AudioOut2ContextHandle* ctx) {
|
||||
constexpr int ErrorInvalidParam = static_cast<int>(0x80268001);
|
||||
if (!params || !buffer || !ctx) return ErrorInvalidParam;
|
||||
*ctx = static_cast<AudioOut2ContextHandle>(-1);
|
||||
std::size_t required = 0;
|
||||
const int result = AudioOut2QueryMemoryLo(params, exParams, &required);
|
||||
if (result < 0) return result;
|
||||
if (exParams && exParams[1] > params->max_object_ports) return ErrorInvalidParam;
|
||||
if (buffer_size < required) return ErrorInvalidParam;
|
||||
return sceAudioOut2ContextCreate(params, buffer, buffer_size, ctx);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceAudioOut2LoInit(void) {
|
||||
@@ -17,11 +51,19 @@ int APS5_VABI sceAudioOut2LoTerminate(void) {
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextQueryMemory(const AudioOut2ContextParam* params, size_t* memory_size) {
|
||||
return sceAudioOut2ContextQueryMemory(params, memory_size);
|
||||
return AudioOut2QueryMemoryLo(params, nullptr, memory_size);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextQueryMemoryEx(const AudioOut2ContextParam* params, const void* exParams, size_t* memory_size) {
|
||||
return AudioOut2QueryMemoryLo(params, static_cast<const std::uint32_t*>(exParams), memory_size);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextCreate(const AudioOut2ContextParam* params, void* buffer, size_t buffer_size, AudioOut2ContextHandle* ctx) {
|
||||
return sceAudioOut2ContextCreate(params, buffer, buffer_size, ctx);
|
||||
return AudioOut2CreateContextLo(params, nullptr, buffer, buffer_size, ctx);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextCreateEx(const AudioOut2ContextParam* params, const void* exParams, void* buffer, size_t buffer_size, AudioOut2ContextHandle* ctx) {
|
||||
return AudioOut2CreateContextLo(params, static_cast<const std::uint32_t*>(exParams), buffer, buffer_size, ctx);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextDestroy(AudioOut2ContextHandle ctx) {
|
||||
@@ -32,6 +74,18 @@ int APS5_VABI sceAudioOut2LoContextSetAttributes(AudioOut2ContextHandle ctx, con
|
||||
return sceAudioOut2ContextSetAttributes(ctx, attributes, num);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextGetAttributes(AudioOut2ContextHandle ctx, AudioOut2Attribute* attributes, uint32_t num) {
|
||||
constexpr int ErrorInvalidParam = static_cast<int>(0x80268001);
|
||||
if (!AudioOut2FindContext(ctx)) return ErrorInvalidParam;
|
||||
if (!attributes && num != 0) return ErrorInvalidParam;
|
||||
for (uint32_t index = 0; index < num; index++) {
|
||||
const auto id = attributes[index].attribute_id;
|
||||
if (id != 0x1e && id != 0x1f) return ErrorInvalidParam;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextAdvance(AudioOut2ContextHandle ctx) {
|
||||
return sceAudioOut2ContextAdvance(ctx);
|
||||
}
|
||||
@@ -48,6 +102,10 @@ int APS5_VABI sceAudioOut2LoPortCreate(AudioOut2ContextHandle ctx, const AudioOu
|
||||
return sceAudioOut2PortCreate(ctx, params, port);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoPortCreateEx(AudioOut2ContextHandle ctx, const AudioOut2PortParam* params, AudioOut2PortHandle* port) {
|
||||
return sceAudioOut2PortCreate(ctx, params, port);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoPortDestroy(AudioOut2PortHandle port) {
|
||||
return sceAudioOut2PortDestroy(port);
|
||||
}
|
||||
@@ -56,6 +114,10 @@ int APS5_VABI sceAudioOut2LoPortSetAttributes(AudioOut2PortHandle port, const Au
|
||||
return sceAudioOut2PortSetAttributes(port, attributes, num);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoPortSetAttributesEx(AudioOut2PortHandle port, const AudioOut2Attribute* attributes, uint32_t num) {
|
||||
return sceAudioOut2PortSetAttributes(port, attributes, num);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoPortGetState(AudioOut2PortHandle port, AudioOut2PortState* state) {
|
||||
return sceAudioOut2PortGetState(port, state);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "prx/libSceAudioOut/include/AudioOut2.hpp"
|
||||
#include "prx/libSceAudioOut/include/InventoryExports.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
@@ -254,6 +255,10 @@ int APS5_VABI sceAudioOut2PortCreate(AudioOut2ContextHandle ctx, const AudioOut2
|
||||
LibcAwaitExit_nid_postfix();
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2PortCreateEx(AudioOut2ContextHandle ctx, const AudioOut2PortParam* params, AudioOut2PortHandle* port) {
|
||||
return sceAudioOut2PortCreate(ctx, params, port);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2PortDestroy(AudioOut2PortHandle port) try {
|
||||
const AudioOutCall call;
|
||||
std::lock_guard lock(g_portsLock);
|
||||
@@ -316,4 +321,26 @@ int APS5_VABI sceAudioOut2PortSetAttributes(AudioOut2PortHandle port, const Audi
|
||||
LibcAwaitExit_nid_postfix();
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoPortGetAttributes(AudioOut2PortHandle port, AudioOut2Attribute* attributes, uint32_t num) try {
|
||||
constexpr int ErrorInvalidParam = static_cast<int>(0x80268001);
|
||||
const AudioOutCall call;
|
||||
std::lock_guard lock(g_portsLock);
|
||||
auto* entry = FromHandle(port);
|
||||
if (!entry) return SCE_AUDIO_OUT2_ERROR_INVALID_HANDLE;
|
||||
if (!attributes && num != 0) return ErrorInvalidParam;
|
||||
for (uint32_t index = 0; index < num; index++) {
|
||||
const auto& attribute = attributes[index];
|
||||
if (attribute.attribute_id == ATTRIBUTE_VOLUME && attribute.value != nullptr) {
|
||||
std::memcpy(const_cast<void*>(attribute.value), entry->volume, entry->channels * sizeof(float));
|
||||
} else if (attribute.attribute_id == 9 || attribute.attribute_id == 0xa || attribute.attribute_id == 0x21) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
} else {
|
||||
return ErrorInvalidParam;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} catch (const ProcessShutdown&) {
|
||||
LibcAwaitExit_nid_postfix();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,18 @@ int APS5_VABI sceAudioOut2GetSystemState(AudioOut2SystemState* state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2GetSystemStateEx(void* state) {
|
||||
(void)state;
|
||||
if (!AudioOut2IsInitialized_nid_no_patch()) return SCE_AUDIO_OUT2_ERROR_NOT_INITIALIZED;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2Terminate(void) {
|
||||
AudioOut2DestroyAllContexts();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2SetSystemDebugState(const AudioOut2SystemDebugStateParam* param) {
|
||||
constexpr int ErrorInvalidPointer = static_cast<int>(0x8026800C);
|
||||
constexpr std::uint32_t DebugStateIdLoudness = 1;
|
||||
|
||||
@@ -26,6 +26,11 @@ int APS5_VABI sceAudioOut2UserCreate(uint32_t user_id, AudioOut2UserHandle* hand
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2UserCreateEx(uint32_t user_id, const void* attributes, AudioOut2UserHandle* handle) {
|
||||
(void)attributes;
|
||||
return sceAudioOut2UserCreate(user_id, handle);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2UserDestroy(AudioOut2UserHandle handle) {
|
||||
std::lock_guard lock(g_usersLock);
|
||||
g_users.erase(handle);
|
||||
|
||||
@@ -9,30 +9,6 @@ int APS5_VABI sceAudioOut2GetSystemDebugState() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextCreateEx() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextGetAttributes() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoContextQueryMemoryEx() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoPortCreateEx() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoPortGetAttributes() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2LoPortSetAttributesEx() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2PortSetAttributesEx() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceAudioOut2UserCreateEx(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOutOpenEx(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
@@ -334,11 +329,6 @@ int APS5_VABI sceAudioOut2GetIpcHandle(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2GetSystemStateEx(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2SetDebugHeadphoneMode(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
@@ -349,21 +339,6 @@ int APS5_VABI sceAudioOut2DebugStateCtrl(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2ContextBedWrite(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2PortCreateEx(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2Terminate(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAudioOut2PortRegister(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
@@ -384,7 +359,6 @@ int APS5_VABI sceAudioOut2GetHrtfIdForCronos(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int APS5_VABI sceAudioDeviceControlGet_nid_no_patch() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <filesystem>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
static void Require(bool value, const char* message) {
|
||||
if (value) return;
|
||||
@@ -31,6 +32,7 @@ constexpr AudioOut2PortHandle portSentinel = 0x6B6B;
|
||||
AudioOut2ContextHandle CreateContext() {
|
||||
AudioOut2ContextParam params{};
|
||||
Require(sceAudioOut2ContextResetParam(¶ms) == 0, "the context parameters did not reset");
|
||||
Require(params.max_ports == 8 && params.queue_depth == 1 && params.num_grains == 256 && params.max_object_ports == 0 && params.guarantee_object_ports == 0, "a context parameter default did not match the console");
|
||||
AudioOut2ContextHandle context = 0;
|
||||
Require(sceAudioOut2ContextCreate(¶ms, nullptr, 0, &context) == 0 && context != 0, "a context was not created");
|
||||
return context;
|
||||
@@ -80,6 +82,107 @@ void UncreatedContextIsInvalid() {
|
||||
Require(sceAudioOut2ContextDestroy(live) == 0, "a live context was not destroyed");
|
||||
}
|
||||
|
||||
void FirmwareExSignatures() {
|
||||
constexpr int errorInvalidParam = static_cast<int>(0x80268001);
|
||||
constexpr int errorInvalidArgument = static_cast<int>(0x80260502);
|
||||
constexpr int errorInvalidGrains = static_cast<int>(0x8026800d);
|
||||
constexpr int errorNotInitialized = static_cast<int>(0x80268006);
|
||||
|
||||
Require(sceAudioOut2GetSystemStateEx(nullptr) == errorNotInitialized, "a system state read ran before initialization");
|
||||
Require(sceAudioOut2Terminate() == 0, "terminate with no contexts did not return 0");
|
||||
Require(sceAudioOut2GetSystemStateEx(nullptr) == errorNotInitialized, "terminate cleared the initialized flag");
|
||||
Require(sceAudioOut2LoInit() == 0, "the low-latency library did not initialize");
|
||||
Require(sceAudioOut2ContextBedWrite(0, 0, 0, 0, 0, 0, 0) == errorInvalidParam, "a bed write on a dead context was not refused");
|
||||
|
||||
AudioOut2UserHandle user = 0;
|
||||
Require(sceAudioOut2UserCreateEx(0x10000000, 0, &user) == 0 && user != 0, "a user was not created through the ex call");
|
||||
std::uint32_t contextAttributes = 1;
|
||||
std::uint32_t portAttributes = 1;
|
||||
Require(sceAudioOut2UserGetSupportedAttributes(user, &contextAttributes, &portAttributes) == 0, "a user made by the ex call was not known");
|
||||
Require(sceAudioOut2UserDestroy(user) == 0, "a user made by the ex call was not destroyed");
|
||||
|
||||
AudioOut2ContextParam params{};
|
||||
Require(sceAudioOut2ContextResetParam(¶ms) == 0, "the context parameters did not reset");
|
||||
std::size_t size = 0;
|
||||
Require(sceAudioOut2LoContextQueryMemory(¶ms, &size) == 0 && size == 0x5b1c, "the low-latency memory query returned the wrong size");
|
||||
size = 0;
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, nullptr, &size) == 0 && size == 0x5b1c, "the extended memory query returned the wrong size");
|
||||
Require(sceAudioOut2LoContextQueryMemory(nullptr, &size) == errorInvalidParam, "a null-parameter memory query was not refused");
|
||||
params.max_object_ports = 0x81;
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, nullptr, &size) == errorInvalidParam, "an oversized object port count was accepted");
|
||||
params.max_object_ports = 0;
|
||||
params.max_ports = 0x21;
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, nullptr, &size) == errorInvalidParam, "an oversized port count was accepted");
|
||||
params.max_ports = 8;
|
||||
params.num_grains = 0x180;
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, nullptr, &size) == errorInvalidGrains, "a misaligned grain count was accepted");
|
||||
params.num_grains = 0x80;
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, nullptr, &size) == errorInvalidGrains, "an undersized grain count was accepted");
|
||||
params.num_grains = 256;
|
||||
params.queue_depth = 0x11;
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, nullptr, &size) == errorInvalidParam, "an oversized queue depth was accepted");
|
||||
const std::uint32_t extension[2] = {0, 0};
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, extension, &size) == 0, "an extension-relaxed queue depth was refused");
|
||||
params.queue_depth = 0x41;
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, extension, &size) == errorInvalidParam, "a queue depth above the extended bound was accepted");
|
||||
params.queue_depth = 1;
|
||||
const std::uint32_t badExtension[2] = {0x16, 0};
|
||||
Require(sceAudioOut2LoContextQueryMemoryEx(¶ms, badExtension, &size) == errorInvalidParam, "an oversized extension count was accepted");
|
||||
|
||||
AudioOut2ContextHandle context = 0;
|
||||
Require(sceAudioOut2LoContextCreate(¶ms, nullptr, 0, &context) == errorInvalidParam, "a context was created over a null buffer");
|
||||
Require(sceAudioOut2LoContextCreateEx(nullptr, nullptr, &context, 0, &context) == errorInvalidParam, "a context was created over null parameters");
|
||||
Require(sceAudioOut2LoContextCreateEx(¶ms, nullptr, nullptr, 0, &context) == errorInvalidParam, "a context was created over a null buffer through the ex call");
|
||||
Require(sceAudioOut2LoContextCreateEx(¶ms, nullptr, &context, 0, nullptr) == errorInvalidParam, "a context was created over a null output");
|
||||
context = 0;
|
||||
Require(sceAudioOut2LoContextCreateEx(¶ms, nullptr, &context, 1, &context) == errorInvalidParam && context == static_cast<AudioOut2ContextHandle>(-1), "a short buffer was not refused with the sentinel handle");
|
||||
const std::uint32_t boundExtension[2] = {0, 1};
|
||||
Require(sceAudioOut2LoContextCreateEx(¶ms, boundExtension, &context, 0x20000, &context) == errorInvalidParam, "an extension over the object port bound was accepted");
|
||||
std::vector<std::byte> buffer(0x20000);
|
||||
Require(sceAudioOut2LoContextCreateEx(¶ms, extension, buffer.data(), buffer.size(), &context) == 0 && context != 0 && context != static_cast<AudioOut2ContextHandle>(-1), "a context was not created through the ex call");
|
||||
|
||||
AudioOut2PortHandle port = 0;
|
||||
Require(CreatePort(context, &port) == 0, "a port was not created on the extended context");
|
||||
AudioOut2PortHandle exPort = 0;
|
||||
Require(sceAudioOut2PortCreateEx(context, nullptr, &exPort) == errorInvalidArgument, "a port was created through the ex call over null parameters");
|
||||
AudioOut2PortParam portParams{};
|
||||
portParams.data_format = formatStereoFloat;
|
||||
portParams.sampling_freq = 48000;
|
||||
Require(sceAudioOut2LoPortCreateEx(context, &portParams, &exPort) == 0 && exPort != 0, "a port was not created through the low-latency ex call");
|
||||
|
||||
float volume[2] = {0.5f, 0.25f};
|
||||
AudioOut2Attribute setVolume{};
|
||||
setVolume.attribute_id = 1;
|
||||
setVolume.value = volume;
|
||||
setVolume.value_size = sizeof(volume);
|
||||
Require(sceAudioOut2LoPortSetAttributesEx(exPort, &setVolume, 1) == 0, "the extended attribute set was refused");
|
||||
|
||||
float readBack[2] = {0.0f, 0.0f};
|
||||
AudioOut2Attribute getVolume{};
|
||||
getVolume.attribute_id = 1;
|
||||
getVolume.value = readBack;
|
||||
getVolume.value_size = sizeof(readBack);
|
||||
Require(sceAudioOut2LoPortGetAttributes(exPort, &getVolume, 1) == 0 && readBack[0] == 0.5f && readBack[1] == 0.25f, "the volume attribute did not round trip");
|
||||
AudioOut2Attribute badAttribute{};
|
||||
badAttribute.attribute_id = 5;
|
||||
badAttribute.value = readBack;
|
||||
badAttribute.value_size = sizeof(readBack);
|
||||
Require(sceAudioOut2LoPortGetAttributes(exPort, &badAttribute, 1) == errorInvalidParam, "an unreadable port attribute was accepted");
|
||||
badAttribute.attribute_id = 9;
|
||||
Require(sceAudioOut2LoPortGetAttributes(portSentinel, &getVolume, 1) == errorInvalidHandle, "a port attribute read on a dead port was not refused");
|
||||
|
||||
Require(sceAudioOut2LoContextGetAttributes(context, &badAttribute, 0) == 0, "an empty context attribute read was refused");
|
||||
Require(sceAudioOut2LoContextGetAttributes(context, &badAttribute, 1) == errorInvalidParam, "an unknown context attribute was accepted");
|
||||
badAttribute.attribute_id = 0x1e;
|
||||
Require(sceAudioOut2LoContextGetAttributes(context + 8, &badAttribute, 1) == errorInvalidParam, "a context attribute read on a dead context was not refused");
|
||||
|
||||
Require(sceAudioOut2PortDestroy(port) == 0, "a live port was not destroyed");
|
||||
Require(sceAudioOut2PortDestroy(exPort) == 0, "a live extended port was not destroyed");
|
||||
Require(sceAudioOut2Terminate() == 0, "terminate with a live context did not return 0");
|
||||
Require(sceAudioOut2ContextGetQueueLevel(context, nullptr, nullptr) == errorInvalidHandle, "a context survived terminate");
|
||||
Require(sceAudioOut2Terminate() == 0, "a repeated terminate did not return 0");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
@@ -87,6 +190,7 @@ int main() {
|
||||
std::filesystem::remove(path);
|
||||
SetEnvironment("SDL_AUDIODRIVER", "disk");
|
||||
SetEnvironment("SDL_DISKAUDIOFILE", path.string());
|
||||
FirmwareExSignatures();
|
||||
UncreatedContextIsInvalid();
|
||||
DestroyedContextIsInvalid();
|
||||
std::filesystem::remove(path);
|
||||
|
||||
@@ -57,6 +57,7 @@ struct Session {
|
||||
std::filesystem::path path;
|
||||
AudioOut2ContextHandle context = 0;
|
||||
AudioOut2PortHandle port = 0;
|
||||
std::vector<std::byte> memory;
|
||||
std::vector<float> buffer = std::vector<float>(static_cast<std::size_t>(grain) * 2, 0.0f);
|
||||
|
||||
bool low;
|
||||
@@ -68,7 +69,14 @@ struct Session {
|
||||
Require(sceAudioOut2ContextResetParam(¶ms) == 0);
|
||||
params.num_grains = grain;
|
||||
params.queue_depth = queueDepth;
|
||||
Require((low ? sceAudioOut2LoContextCreate : sceAudioOut2ContextCreate)(¶ms, nullptr, 0, &context) == 0);
|
||||
if (low) {
|
||||
std::size_t memorySize = 0;
|
||||
Require(sceAudioOut2LoContextQueryMemory(¶ms, &memorySize) == 0);
|
||||
memory = std::vector<std::byte>(memorySize);
|
||||
Require(sceAudioOut2LoContextCreate(¶ms, memory.data(), memory.size(), &context) == 0);
|
||||
} else {
|
||||
Require(sceAudioOut2ContextCreate(¶ms, nullptr, 0, &context) == 0);
|
||||
}
|
||||
AudioOut2PortParam port{};
|
||||
port.port_type = 0;
|
||||
port.data_format = formatStereoFloat;
|
||||
@@ -339,21 +347,24 @@ void TestLowLatencyCallsRejectBadArguments() {
|
||||
Require(sceAudioOut2ContextResetParam(¶ms) == 0);
|
||||
params.num_grains = grain;
|
||||
params.queue_depth = queueDepth;
|
||||
constexpr int errorInvalidParam = static_cast<int>(0x80268001);
|
||||
const std::size_t sizeSentinel = 0x1234;
|
||||
std::size_t size = sizeSentinel;
|
||||
Require(sceAudioOut2LoContextQueryMemory(nullptr, &size) == errorInvalidArgument);
|
||||
Require(sceAudioOut2LoContextQueryMemory(¶ms, nullptr) == errorInvalidArgument);
|
||||
Require(sceAudioOut2LoContextQueryMemory(nullptr, &size) == errorInvalidParam);
|
||||
Require(sceAudioOut2LoContextQueryMemory(¶ms, nullptr) == 0);
|
||||
Require(size == sizeSentinel);
|
||||
Require(sceAudioOut2LoContextQueryMemory(¶ms, &size) == 0);
|
||||
std::size_t standardSize = sizeSentinel;
|
||||
Require(sceAudioOut2ContextQueryMemory(¶ms, &standardSize) == 0);
|
||||
Require(size == standardSize && size != sizeSentinel);
|
||||
Require(size == 0x5b1c && standardSize == 0x10000);
|
||||
|
||||
const AudioOut2ContextHandle contextSentinel = 0x5A5A;
|
||||
AudioOut2ContextHandle context = contextSentinel;
|
||||
Require(sceAudioOut2LoContextCreate(nullptr, nullptr, 0, &context) == errorInvalidArgument);
|
||||
Require(sceAudioOut2LoContextCreate(nullptr, nullptr, 0, &context) == errorInvalidParam);
|
||||
Require(context == contextSentinel);
|
||||
Require(sceAudioOut2LoContextCreate(¶ms, nullptr, 0, nullptr) == errorInvalidParam);
|
||||
Require(sceAudioOut2LoContextCreate(¶ms, nullptr, 0, &context) == errorInvalidParam);
|
||||
Require(context == contextSentinel);
|
||||
Require(sceAudioOut2LoContextCreate(¶ms, nullptr, 0, nullptr) == errorInvalidArgument);
|
||||
|
||||
Require(sceAudioOut2LoContextDestroy(0) == errorInvalidHandle);
|
||||
Require(sceAudioOut2LoContextAdvance(0) == errorInvalidHandle);
|
||||
|
||||
@@ -89,12 +89,6 @@
|
||||
| Name | NID |
|
||||
| --- | --- |
|
||||
| `sceAudioOut2GetSystemDebugState` | `1kUphng3rOk` |
|
||||
| `sceAudioOut2LoContextCreateEx` | `o+Ol1OcMbBo` |
|
||||
| `sceAudioOut2LoContextGetAttributes` | `Nb3DK8hNqeY` |
|
||||
| `sceAudioOut2LoContextQueryMemoryEx` | `+8fuZ1rh4PA` |
|
||||
| `sceAudioOut2LoPortCreateEx` | `eD21Kabealg` |
|
||||
| `sceAudioOut2LoPortGetAttributes` | `45qxRgFYZZg` |
|
||||
| `sceAudioOut2LoPortSetAttributesEx` | `3o6lDIe0iY0` |
|
||||
| `sceAudioOut2PortSetAttributesEx` | `11yhLGUG49M` |
|
||||
| `sceAudioOut2SetHrtfIdForCronos` | `PA3AjhcS+w4` |
|
||||
| `sceAudioOut2SetSpeakerInfo` | `-Bn3G37Q1qU` |
|
||||
@@ -129,7 +123,17 @@
|
||||
- [sceAudioOut2GetSpeakerInfo](../../../core/libs/prx/libSceAudioOut/src/AudioOut2SpeakerArray.cpp) (libSceAudioOut) - The speaker info reports type 0 with available bits `0x3`, the front left speaker at +30 degrees and the front right one at -30, and -360 for the azimuth and elevation of every other slot. On that console the type followed the HDMI device type and the available bits its channels: type 0 with the device set to TV, 1 to AV amplifier and 2 to sound bar, which [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Audio/AudioOut2.cs) names television, AV receiver and sound bar (3 is headphones there), and available bits `0x3` for 2 channels and `0x3F` for 5.1 (centre at 0, surround pair at +110 and -110, -360 for the LFE).
|
||||
- [sceAudioOut2GetSpeakerInfo](../../../core/libs/prx/libSceAudioOut/src/AudioOut2SpeakerArray.cpp) (libSceAudioOut) - The front pair and the empty slots read the same in every setting; 7.1 on the AV amplifier reported 2 channels on that console's HDMI chain. The host output is always reported as a stereo television here. The console also refuses flag 1 below a per-process libkernel value whose source is unidentified; BunnyFl measured the boundary between `0x14FFFFF` and `0x1500000`, and it is not modelled here. ASTRO BOT and ASTRO's PLAYROOM reportedly stop on an assertion that depends on these values (#4317), but which field matters has not been isolated
|
||||
- [sceAudioOut2InitializeEx and sceAudioOut2LoInit repeats](../../../core/libs/prx/libSceAudioOut/src/AudioOut2System.cpp) (libSceAudioOut) - a repeated `sceAudioOut2InitializeEx` or `sceAudioOut2LoInit` returns 0, and either one after `sceAudioOut2Initialize` or `sceAudioOutInit` returns 0 too; the console was not measured for these two. On PS5 firmware 13.60 a repeated `sceAudioOut2Initialize` returns `0x80268004` and a repeated `sceAudioOutInit` `0x8026000e`, and `sceAudioOutInit` after `sceAudioOut2Initialize` still returns 0, which AnyPS5 follows.
|
||||
- [sceAudioOut2UserCreateEx](../../../core/libs/prx/libSceAudioOut/src/Unimplemented.cpp) (libSceAudioOut) - unknown signature
|
||||
- [sceAudioOut2UserCreateEx](../../../core/libs/prx/libSceAudioOut/src/AudioOut2User.cpp) (libSceAudioOut) - the PS5 4.03 module takes three arguments `(userId, attributes, handle)` and passes all three to the shared user-create core, skipping `sceAudioOut2UserCreate`'s own null/user checks and its system-state gate. The host creates a user the same way as `sceAudioOut2UserCreate`; the second argument's service-side meaning is unverified and ignored.
|
||||
- [sceAudioOut2Terminate](../../../core/libs/prx/libSceAudioOut/src/AudioOut2System.cpp) (libSceAudioOut) - the PS5 4.03 module takes no arguments, iterates the 32 context slots destroying every live context, releases the service handle and its mutex, and returns 0; it does not clear the initialized flag, so `sceAudioOut2GetSystemState` calls still succeed afterwards. The host destroys every live context the same way and keeps the initialized flag. The console's service teardown has no host equivalent.
|
||||
- [sceAudioOut2GetSystemStateEx](../../../core/libs/prx/libSceAudioOut/src/AudioOut2System.cpp) (libSceAudioOut) - the PS5 4.03 module takes one output pointer, returns `0x80268006` before initialization, then writes a 12-byte packed state (a code word, a shared-memory counter and a size code) read from service shared memory. The host reproduces the init gate and throws past it; the field semantics are service state the host does not model.
|
||||
- [sceAudioOut2ContextBedWrite](../../../core/libs/prx/libSceAudioOut/src/AudioOut2Context.cpp) (libSceAudioOut) - the PS5 4.03 module takes seven arguments: a context handle, four register-width arguments, a layout selector in {0,1,2} and a trailing byte flag on the stack; it resolves the context, reads a bed descriptor through `0x283c0` (a `0x80268002` failure becomes `0x80268008`) and selects a layout before a service write. Service-side write semantics are unimplemented; the export throws.
|
||||
- [sceAudioOut2PortCreateEx](../../../core/libs/prx/libSceAudioOut/src/AudioOut2Port.cpp) (libSceAudioOut) - the PS5 4.03 module takes the same three arguments as `sceAudioOut2PortCreate` and passes an internal extension flag into the shared create core, which accepts a wider parameter interpretation. The host forwards to `sceAudioOut2PortCreate`; how the extended interpretation differs is unverified.
|
||||
- [sceAudioOut2LoContextCreateEx and sceAudioOut2LoContextQueryMemoryEx](../../../core/libs/prx/libSceAudioOut/src/AudioOut2Low.cpp) (libSceAudioOut) - the PS5 4.03 module inserts an optional extension pointer as the second argument: `LoContextQueryMemoryEx(params, exParams, size*)` and `LoContextCreateEx(params, exParams, buffer, bufferSize, ctx*)`. The query core validates params null, `max_object_ports` <= `0x80`, `max_ports` <= `0x20`, `guarantee_object_ports` <= `max_object_ports`, `num_grains` in `0x100..0x800` step `0x100` (`0x8026800d`), extension count <= `0x15`, and `queue_depth` <= `0x40` with an extension or `0x10` without (`0x80268001`); the host returns the same firmware memory size. Create also requires a non-null buffer and output, writes -1 to the output first, requires `exParams[1]` <= `max_object_ports` and `bufferSize` >= the computed size, then forwards to `sceAudioOut2ContextCreate`. The extension's service-side meaning is unverified.
|
||||
- [sceAudioOut2LoContextGetAttributes](../../../core/libs/prx/libSceAudioOut/src/AudioOut2Low.cpp) (libSceAudioOut) - the PS5 4.03 module takes `(ctx, attributes, num)` over 24-byte entries, reads only ids `0x1e` (u32) and `0x1f` (float) from context state and returns `0x80268001` on any other id or an unknown context. The host keeps the lookup and id checks and throws on a valid read; the context fields are unmodelled.
|
||||
- [sceAudioOut2LoPortCreateEx](../../../core/libs/prx/libSceAudioOut/src/AudioOut2Low.cpp) (libSceAudioOut) - the PS5 4.03 module takes the same three arguments as `sceAudioOut2LoPortCreate` and passes an internal flag into the shared core, which widens the accepted port-type set (the `0x80`-family and `0x3f`). The host forwards to `sceAudioOut2PortCreate`; the wider types' semantics are unverified.
|
||||
- [sceAudioOut2LoPortGetAttributes](../../../core/libs/prx/libSceAudioOut/src/AudioOut2Port.cpp) (libSceAudioOut) - the PS5 4.03 module takes `(port, attributes, num)` where the port packs a context id in its high 32 bits, requires port class 2 (`0x80268008`) and reads attributes through one of two jump tables selected by a port flag bit. In the base table only ids 1 (a float gain per channel), 9, `0xa` and `0x21` are readable; any other id returns `0x80268001`. The host returns the stored per-channel gains for id 1, throws on the other three documented ids, and returns `0x80268001` otherwise. The flag-selected table's extra ids and the host port-handle layout differences are unmodelled.
|
||||
- [sceAudioOut2LoPortSetAttributesEx](../../../core/libs/prx/libSceAudioOut/src/AudioOut2Port.cpp) (libSceAudioOut) - the PS5 4.03 module takes the same three arguments as `sceAudioOut2LoPortSetAttributes` and passes an internal flag into the shared core, which widens the writable attribute-id mask (`0x200000603` vs `0x603`). The host forwards to `sceAudioOut2PortSetAttributes`; the extra writable id's semantics are unverified.
|
||||
- [sceAudioOut2PortSetAttributesEx, sceAudioOut2LoPortGetStateEx and sceAudioOut2GetAmbisonicsEncodeCoefficients](../../../core/libs/prx/libSceAudioOut/src/Unimplemented.cpp) (libSceAudioOut) - absent from the PS5 4.03 module's export table (later-firmware additions); signatures and behavior remain unverified and the exports still throw through `NotImplemented_nid_no_patch`.
|
||||
- [sceAudioOutOpenEx](../../../core/libs/prx/libSceAudioOut/src/Unimplemented.cpp) (libSceAudioOut) - unknown signature
|
||||
- [sceAudioOutSetSystemDebugState](../../../core/libs/prx/libSceAudioOut/src/Unimplemented.cpp) (libSceAudioOut) - unknown signature
|
||||
- [sceAudioOutGetHandleStatusInfo](../../../core/libs/prx/libSceAudioOut/src/Unimplemented.cpp) (libSceAudioOut) - unknown signature
|
||||
|
||||
Reference in new issue
Block a user