mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(voiceqos): implement sceVoiceQoSInit
A title passes a work memory block and app type 0x20000000, and turns voice chat off when initialization fails. Initialization now records the library as initialized and succeeds. A null or empty memory block, another app type and a second initialization throw, as their error codes are unknown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
add_library(libSceVoiceQoS SHARED EXCLUDE_FROM_ALL Export.cpp)
|
||||
target_include_directories(libSceVoiceQoS PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
configure_windows_unwind(libSceVoiceQoS)
|
||||
|
||||
if(MINGW)
|
||||
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
|
||||
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_test_executable(guest_voice_qos_tests ${LIBS_INCLUDE_DIR}/tests/GuestVoiceQoS.cpp)
|
||||
target_include_directories(guest_voice_qos_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(guest_voice_qos_tests PRIVATE libSceVoiceQoS libc)
|
||||
configure_windows_unwind(guest_voice_qos_tests)
|
||||
add_test(NAME guest_voice_qos COMMAND guest_voice_qos_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_voice_qos PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceVoiceQoS>")
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,16 +1,29 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr std::int32_t VOICE_QOS_APP_TYPE_GAME = 0x20000000;
|
||||
|
||||
std::mutex g_mutex;
|
||||
bool g_initialized = false;
|
||||
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceVoiceQoSInit(void* mem_block, uint32_t mem_size, int32_t app_type) {
|
||||
(void)mem_block;
|
||||
(void)mem_size;
|
||||
(void)app_type;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
if (!mem_block || mem_size == 0) throw std::invalid_argument("sceVoiceQoSInit: null or empty memory block");
|
||||
if (app_type != VOICE_QOS_APP_TYPE_GAME) throw std::invalid_argument("sceVoiceQoSInit: unsupported app type " + std::to_string(app_type));
|
||||
std::lock_guard lock(g_mutex);
|
||||
if (g_initialized) throw std::runtime_error("sceVoiceQoSInit: already initialized");
|
||||
g_initialized = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "prx/libc/include/general/VabiMacros.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
extern "C" {
|
||||
int APS5_VABI sceVoiceQoSInit(void*, std::uint32_t, std::int32_t);
|
||||
}
|
||||
|
||||
static void Require(bool value) { if (!value) std::abort(); }
|
||||
|
||||
template<typename TException, typename TFunction>
|
||||
static bool Throws(TFunction function) {
|
||||
try {
|
||||
function();
|
||||
} catch (const TException&) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::vector<std::uint8_t> memory(0x40000);
|
||||
Require(Throws<std::invalid_argument>([&] { sceVoiceQoSInit(nullptr, 0x40000, 0x20000000); }));
|
||||
Require(Throws<std::invalid_argument>([&] { sceVoiceQoSInit(memory.data(), 0, 0x20000000); }));
|
||||
Require(Throws<std::invalid_argument>([&] { sceVoiceQoSInit(memory.data(), 0x40000, 0); }));
|
||||
Require(sceVoiceQoSInit(memory.data(), 0x40000, 0x20000000) == 0);
|
||||
Require(Throws<std::runtime_error>([&] { sceVoiceQoSInit(memory.data(), 0x40000, 0x20000000); }));
|
||||
}
|
||||
@@ -59,6 +59,7 @@ Throughout the project, every function at every stage either **does exactly what
|
||||
- [scePsmlMfsrGetContextBufferRequirement1100, scePsmlMfsrCreateContext1100, scePsmlMfsrGetDispatchMfsrPacket1100](../../core/libs/prx/libScePsml_debug/Export.cpp) (libScePsml_debug) - argument layouts unknown; only 0x8A810001 (not initialized) is returned
|
||||
- [BnMAMrsfVWo](../../core/libs/prx/libc/src/HeapDiagnostics.cpp) (libc) - unknown name, signature
|
||||
- [scePngEncEncode](../../core/libs/prx/libScePngEnc/Export.cpp) (libScePngEnc) - whether rows may stay unfiltered when `filter_type` names a subset of the filters is unknown; as in shadPS4, they may only for 0 and for the all-filters mask
|
||||
- [sceVoiceQoSInit](../../core/libs/prx/libSceVoiceQoS/Export.cpp) (libSceVoiceQoS) - the error codes are unknown: a null or empty memory block, an app type other than 0x20000000 (the value PPSA14632 passes) and a second initialization throw. The minimum memory size is unknown and the block is not used, as no endpoint is implemented
|
||||
- AudioIn, NpSessionSignaling and PlayerInvitationDialog exports added without an implementation have assumed signatures
|
||||
- [libSceAudioPropagation](../../core/libs/prx/libSceAudioPropagation/Export.cpp) (libSceAudioPropagation) - signatures and struct descriptors recovered from PPSA21567's calls (#481), not from documentation. The system options layout is unknown (only checked for non-null); the fourth argument of `sceAudioPropagationSourceCalculateAudioPaths` is unknown; `sceAudioPropagationSourceGetAudioPath` is assumed to output an 8-byte path handle. The meaning of the `RenderInfo` word at +0x28 is unknown (PPSA21567 and PPSA21564 pass 2); only 2 is accepted. Both titles pass one `RenderInfo` per call: a count of 0 throws, and larger counts are handled element by element without proof. No error code is known, so invalid input throws instead of returning one
|
||||
- [sceAvPlayerStartEx](../../core/libs/prx/libSceAvPlayer/Export.cpp) (libSceAvPlayer) - start info layout unknown; it is ignored and playback starts as with `sceAvPlayerStart`
|
||||
|
||||
Reference in New Issue
Block a user