Files
AnyPS5/core/libs/prx/libSceProprietaryVoiceChatHelperPrx/Export.cpp
T
Matheus Lima da SilvaandClaude Opus 5 e933285d82 feat(libSceProprietaryVoiceChatHelperPrx): implement the voice chat helper lifecycle
Initialize and Terminate track whether the library is initialized, and
SetVoiceChatState returns success without recording anything: the host has
no system voice chat for a title's own voice chat to announce itself to,
and the state argument is unknown.

GetVoiceChatUsageState keeps throwing. With the state argument unreadable
there is no recorded usage state, and whether the console returns the state
or writes it through an output pointer, and how it encodes it, is unknown.

Misuse throws rather than guessing an error code, as the library's error
codes are unknown.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-13 10:34:39 +02:00

63 lines
1.4 KiB
C++

#include <mutex>
#include <stdexcept>
#include <string>
#include "prx/libc/include/General.hpp"
namespace {
struct Helper {
std::mutex mutex;
bool initialized = false;
};
Helper& State() {
static Helper helper;
return helper;
}
[[noreturn]] void Fail(const char* function, const std::string& why) {
throw std::logic_error(std::string(function) + ": " + why);
}
void RequireInitialized(const Helper& helper, const char* function) {
if (!helper.initialized) Fail(function, "library not initialized");
}
} // namespace
extern "C" {
int APS5_VABI sceProprietaryVoiceChatHelperInitialize(void) {
auto& helper = State();
std::lock_guard lock(helper.mutex);
if (helper.initialized) Fail(__func__, "already initialized");
helper.initialized = true;
return 0;
}
int APS5_VABI sceProprietaryVoiceChatHelperTerminate(void) {
auto& helper = State();
std::lock_guard lock(helper.mutex);
RequireInitialized(helper, __func__);
helper.initialized = false;
return 0;
}
int APS5_VABI sceProprietaryVoiceChatHelperSetVoiceChatState(void) {
auto& helper = State();
std::lock_guard lock(helper.mutex);
RequireInitialized(helper, __func__);
return 0;
}
int APS5_VABI sceProprietaryVoiceChatHelperGetVoiceChatUsageState(void) {
auto& helper = State();
std::lock_guard lock(helper.mutex);
RequireInitialized(helper, __func__);
NotImplemented_nid_no_patch(__func__);
return 0;
}
}