diff --git a/core/libs/prx/libSceVoiceQoS/CMakeLists.txt b/core/libs/prx/libSceVoiceQoS/CMakeLists.txt new file mode 100644 index 000000000..29d56e9ad --- /dev/null +++ b/core/libs/prx/libSceVoiceQoS/CMakeLists.txt @@ -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:$") + endif() +endif() diff --git a/core/libs/prx/libSceVoiceQoS/Export.cpp b/core/libs/prx/libSceVoiceQoS/Export.cpp index a0af71ff3..725088af0 100644 --- a/core/libs/prx/libSceVoiceQoS/Export.cpp +++ b/core/libs/prx/libSceVoiceQoS/Export.cpp @@ -1,16 +1,29 @@ #include #include +#include +#include +#include #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; } } diff --git a/core/libs/tests/GuestVoiceQoS.cpp b/core/libs/tests/GuestVoiceQoS.cpp new file mode 100644 index 000000000..9f9e668a6 --- /dev/null +++ b/core/libs/tests/GuestVoiceQoS.cpp @@ -0,0 +1,30 @@ +#include "prx/libc/include/general/VabiMacros.hpp" +#include +#include +#include +#include + +extern "C" { +int APS5_VABI sceVoiceQoSInit(void*, std::uint32_t, std::int32_t); +} + +static void Require(bool value) { if (!value) std::abort(); } + +template +static bool Throws(TFunction function) { + try { + function(); + } catch (const TException&) { + return true; + } + return false; +} + +int main() { + std::vector memory(0x40000); + Require(Throws([&] { sceVoiceQoSInit(nullptr, 0x40000, 0x20000000); })); + Require(Throws([&] { sceVoiceQoSInit(memory.data(), 0, 0x20000000); })); + Require(Throws([&] { sceVoiceQoSInit(memory.data(), 0x40000, 0); })); + Require(sceVoiceQoSInit(memory.data(), 0x40000, 0x20000000) == 0); + Require(Throws([&] { sceVoiceQoSInit(memory.data(), 0x40000, 0x20000000); })); +} diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 02ea84a84..a501121c5 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -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`