mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-02 07:22:24 +00:00
clang
This commit is contained in:
parent
cc1d44a836
commit
807ea7a7f6
@ -12,154 +12,154 @@ using namespace Libraries::Kernel;
|
|||||||
|
|
||||||
namespace Libraries::Ngs2 {
|
namespace Libraries::Ngs2 {
|
||||||
|
|
||||||
s32 Ngs2::ReportInvalid(u32 handle_type) const {
|
s32 Ngs2::ReportInvalid(u32 handle_type) const {
|
||||||
switch (handle_type) {
|
switch (handle_type) {
|
||||||
case 1:
|
case 1:
|
||||||
LOG_ERROR(Lib_Ngs2, "Invalid system handle {}", this);
|
LOG_ERROR(Lib_Ngs2, "Invalid system handle {}", this);
|
||||||
return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE;
|
return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE;
|
||||||
case 2:
|
case 2:
|
||||||
LOG_ERROR(Lib_Ngs2, "Invalid rack handle {}", this);
|
LOG_ERROR(Lib_Ngs2, "Invalid rack handle {}", this);
|
||||||
return ORBIS_NGS2_ERROR_INVALID_RACK_HANDLE;
|
return ORBIS_NGS2_ERROR_INVALID_RACK_HANDLE;
|
||||||
case 4:
|
case 4:
|
||||||
LOG_ERROR(Lib_Ngs2, "Invalid voice handle {}", this);
|
LOG_ERROR(Lib_Ngs2, "Invalid voice handle {}", this);
|
||||||
return ORBIS_NGS2_ERROR_INVALID_VOICE_HANDLE;
|
return ORBIS_NGS2_ERROR_INVALID_VOICE_HANDLE;
|
||||||
case 8:
|
case 8:
|
||||||
LOG_ERROR(Lib_Ngs2, "Invalid report handle {}", this);
|
LOG_ERROR(Lib_Ngs2, "Invalid report handle {}", this);
|
||||||
return ORBIS_NGS2_ERROR_INVALID_REPORT_HANDLE;
|
return ORBIS_NGS2_ERROR_INVALID_REPORT_HANDLE;
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(Lib_Ngs2, "Invalid handle {}", this);
|
LOG_ERROR(Lib_Ngs2, "Invalid handle {}", this);
|
||||||
return ORBIS_NGS2_ERROR_INVALID_HANDLE;
|
return ORBIS_NGS2_ERROR_INVALID_HANDLE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s32 Ngs2::HandleSetup(Ngs2Handle* handle, void* data, std::atomic<u32>* atomic, u32 type,
|
s32 Ngs2::HandleSetup(Ngs2Handle* handle, void* data, std::atomic<u32>* atomic, u32 type,
|
||||||
u32 flags) {
|
u32 flags) {
|
||||||
handle->dataPointer = data;
|
handle->dataPointer = data;
|
||||||
handle->atomicPtr = atomic;
|
handle->atomicPtr = atomic;
|
||||||
handle->handleType = type;
|
handle->handleType = type;
|
||||||
handle->flags_unk = flags;
|
handle->flags_unk = flags;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Ngs2::HandleCleanup(Ngs2Handle* handle, u32 hType, void* dataOut) {
|
s32 Ngs2::HandleCleanup(Ngs2Handle* handle, u32 hType, void* dataOut) {
|
||||||
if (handle && handle->selfPointer == handle) {
|
if (handle && handle->selfPointer == handle) {
|
||||||
std::atomic<u32>* tmp_atomic = handle->atomicPtr;
|
std::atomic<u32>* tmp_atomic = handle->atomicPtr;
|
||||||
if (tmp_atomic && handle->handleType == hType) {
|
if (tmp_atomic && handle->handleType == hType) {
|
||||||
while (tmp_atomic->load() != 0) {
|
while (tmp_atomic->load() != 0) {
|
||||||
u32 expected = 1;
|
u32 expected = 1;
|
||||||
if (tmp_atomic->compare_exchange_strong(expected, 0)) {
|
if (tmp_atomic->compare_exchange_strong(expected, 0)) {
|
||||||
if (dataOut) {
|
if (dataOut) {
|
||||||
dataOut = handle->dataPointer;
|
dataOut = handle->dataPointer;
|
||||||
}
|
|
||||||
// sceNgs2MemoryClear(handle, 32);
|
|
||||||
return ORBIS_OK;
|
|
||||||
}
|
}
|
||||||
tmp_atomic = handle->atomicPtr;
|
// sceNgs2MemoryClear(handle, 32);
|
||||||
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
tmp_atomic = handle->atomicPtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HandleReportInvalid(handle, hType);
|
}
|
||||||
|
return HandleReportInvalid(handle, hType);
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 Ngs2::HandleEnter(Ngs2Handle* handle, u32 hType, Ngs2Handle* handleOut) {
|
||||||
|
if (!handle) {
|
||||||
|
return HandleReportInvalid(handle, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Ngs2::HandleEnter(Ngs2Handle* handle, u32 hType, Ngs2Handle* handleOut) {
|
if (handle->selfPointer != handle || !handle->atomicPtr || !handle->dataPointer ||
|
||||||
if (!handle) {
|
(~hType & handle->handleType)) {
|
||||||
return HandleReportInvalid(handle, 0);
|
return HandleReportInvalid(handle, handle->handleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle->selfPointer != handle || !handle->atomicPtr || !handle->dataPointer ||
|
std::atomic<u32>* atomic = handle->atomicPtr;
|
||||||
(~hType & handle->handleType)) {
|
while (true) {
|
||||||
|
u32 i = atomic->load();
|
||||||
|
if (i == 0) {
|
||||||
return HandleReportInvalid(handle, handle->handleType);
|
return HandleReportInvalid(handle, handle->handleType);
|
||||||
}
|
}
|
||||||
|
if (atomic->compare_exchange_strong(i, i + 1)) {
|
||||||
std::atomic<u32>* atomic = handle->atomicPtr;
|
break;
|
||||||
while (true) {
|
|
||||||
u32 i = atomic->load();
|
|
||||||
if (i == 0) {
|
|
||||||
return HandleReportInvalid(handle, handle->handleType);
|
|
||||||
}
|
|
||||||
if (atomic->compare_exchange_strong(i, i + 1)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handleOut) {
|
|
||||||
*handleOut = handle;
|
|
||||||
}
|
|
||||||
return ORBIS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Ngs2::HandleLeave(Ngs2Handle* handle) {
|
if (handleOut) {
|
||||||
std::atomic<u32>* tmp_atomic;
|
*handleOut = handle;
|
||||||
u32 i;
|
}
|
||||||
do {
|
return ORBIS_OK;
|
||||||
tmp_atomic = handle->atomicPtr;
|
}
|
||||||
i = tmp_atomic->load();
|
|
||||||
} while (!tmp_atomic->compare_exchange_strong(i, i - 1));
|
s32 Ngs2::HandleLeave(Ngs2Handle* handle) {
|
||||||
return ORBIS_OK;
|
std::atomic<u32>* tmp_atomic;
|
||||||
|
u32 i;
|
||||||
|
do {
|
||||||
|
tmp_atomic = handle->atomicPtr;
|
||||||
|
i = tmp_atomic->load();
|
||||||
|
} while (!tmp_atomic->compare_exchange_strong(i, i - 1));
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 Ngs2::StackBufferOpen(StackBuffer* buf, void* base_addr, size_t size, void** stackTop,
|
||||||
|
bool verify) {
|
||||||
|
buf->top = stackTop;
|
||||||
|
buf->base = base_addr;
|
||||||
|
buf->curr = base_addr;
|
||||||
|
buf->usedSize = 0;
|
||||||
|
buf->totalSize = size;
|
||||||
|
buf->alignment = 8;
|
||||||
|
buf->isVerifyEnabled = verify;
|
||||||
|
|
||||||
|
if (stackTop) {
|
||||||
|
*stackTop = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Ngs2::StackBufferOpen(StackBuffer* buf, void* base_addr, size_t size, void** stackTop,
|
return ORBIS_OK;
|
||||||
bool verify) {
|
}
|
||||||
buf->top = stackTop;
|
|
||||||
buf->base = base_addr;
|
|
||||||
buf->curr = base_addr;
|
|
||||||
buf->usedSize = 0;
|
|
||||||
buf->totalSize = size;
|
|
||||||
buf->alignment = 8;
|
|
||||||
buf->isVerifyEnabled = verify;
|
|
||||||
|
|
||||||
if (stackTop) {
|
s32 Ngs2::StackBufferClose(StackBuffer* buf, size_t* usedSize) {
|
||||||
*stackTop = nullptr;
|
if (usedSize) {
|
||||||
}
|
*usedSize = buf->usedSize + buf->alignment;
|
||||||
|
|
||||||
return ORBIS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Ngs2::StackBufferClose(StackBuffer* buf, size_t* usedSize) {
|
return ORBIS_OK;
|
||||||
if (usedSize) {
|
}
|
||||||
*usedSize = buf->usedSize + buf->alignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ORBIS_OK;
|
s32 Ngs2::SystemSetupCore(StackBuffer* buf, SystemOptions* options, Ngs2Handle** sysOut) {
|
||||||
|
u32 maxGrainSamples = 512;
|
||||||
|
u32 numGrainSamples = 256;
|
||||||
|
u32 sampleRate = 48000;
|
||||||
|
|
||||||
|
if (options) {
|
||||||
|
maxGrainSamples = options->maxGrainSamples;
|
||||||
|
numGrainSamples = options->numGrainSamples;
|
||||||
|
sampleRate = options->sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Ngs2::SystemSetupCore(StackBuffer* buf, SystemOptions* options, Ngs2Handle** sysOut) {
|
// Validate maxGrainSamples
|
||||||
u32 maxGrainSamples = 512;
|
if (maxGrainSamples < 64 || maxGrainSamples > 1024 || (maxGrainSamples & 0x3F) != 0) {
|
||||||
u32 numGrainSamples = 256;
|
LOG_ERROR(Lib_Ngs2, "Invalid system option (maxGrainSamples={},x64)", maxGrainSamples);
|
||||||
u32 sampleRate = 48000;
|
return ORBIS_NGS2_ERROR_INVALID_MAXIMUM_GRAIN_SAMPLES;
|
||||||
|
|
||||||
if (options) {
|
|
||||||
maxGrainSamples = options->maxGrainSamples;
|
|
||||||
numGrainSamples = options->numGrainSamples;
|
|
||||||
sampleRate = options->sampleRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate maxGrainSamples
|
|
||||||
if (maxGrainSamples < 64 || maxGrainSamples > 1024 || (maxGrainSamples & 0x3F) != 0) {
|
|
||||||
LOG_ERROR(Lib_Ngs2, "Invalid system option (maxGrainSamples={},x64)", maxGrainSamples);
|
|
||||||
return ORBIS_NGS2_ERROR_INVALID_MAXIMUM_GRAIN_SAMPLES;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate numGrainSamples
|
|
||||||
if (numGrainSamples < 64 || numGrainSamples > 1024 || (numGrainSamples & 0x3F) != 0) {
|
|
||||||
LOG_ERROR(Lib_Ngs2, "Invalid system option (numGrainSamples={},x64)", numGrainSamples);
|
|
||||||
return ORBIS_NGS2_ERROR_INVALID_GRAIN_SAMPLES;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate sampleRate
|
|
||||||
if (sampleRate != 11025 && sampleRate != 12000 && sampleRate != 22050 &&
|
|
||||||
sampleRate != 24000 && sampleRate != 44100 && sampleRate != 48000 &&
|
|
||||||
sampleRate != 88200 && sampleRate != 96000) {
|
|
||||||
LOG_ERROR(Lib_Ngs2, "Invalid system option(sampleRate={}:44.1/48kHz series)",
|
|
||||||
sampleRate);
|
|
||||||
return ORBIS_NGS2_ERROR_INVALID_SAMPLE_RATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int result = ORBIS_OK;
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
return result; // Success
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate numGrainSamples
|
||||||
|
if (numGrainSamples < 64 || numGrainSamples > 1024 || (numGrainSamples & 0x3F) != 0) {
|
||||||
|
LOG_ERROR(Lib_Ngs2, "Invalid system option (numGrainSamples={},x64)", numGrainSamples);
|
||||||
|
return ORBIS_NGS2_ERROR_INVALID_GRAIN_SAMPLES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate sampleRate
|
||||||
|
if (sampleRate != 11025 && sampleRate != 12000 && sampleRate != 22050 &&
|
||||||
|
sampleRate != 24000 && sampleRate != 44100 && sampleRate != 48000 &&
|
||||||
|
sampleRate != 88200 && sampleRate != 96000) {
|
||||||
|
LOG_ERROR(Lib_Ngs2, "Invalid system option(sampleRate={}:44.1/48kHz series)",
|
||||||
|
sampleRate);
|
||||||
|
return ORBIS_NGS2_ERROR_INVALID_SAMPLE_RATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = ORBIS_OK;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return result; // Success
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Libraries::Ngs2
|
} // namespace Libraries::Ngs2
|
||||||
|
Loading…
Reference in New Issue
Block a user