From 0300cac3ff571a98581b492c62503dbf07ce7d68 Mon Sep 17 00:00:00 2001 From: Lizardy <6063922+lzardy@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:51:15 -0400 Subject: [PATCH] [libSceAudio3d] Initialize Audio3d Library (#761) * init libSceAudio3d * complete header and func params * clang * rm incl * incl stddef * revert module num * print params * correct logs * clang --------- Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com> --- CMakeLists.txt | 5 + src/common/logging/filter.cpp | 1 + src/common/logging/types.h | 1 + src/core/libraries/audio3d/audio3d.cpp | 344 ++++++++++++++++++++ src/core/libraries/audio3d/audio3d.h | 134 ++++++++ src/core/libraries/audio3d/audio3d_error.h | 13 + src/core/libraries/audio3d/audio3d_impl.cpp | 13 + src/core/libraries/audio3d/audio3d_impl.h | 16 + src/core/libraries/libs.cpp | 2 + 9 files changed, 529 insertions(+) create mode 100644 src/core/libraries/audio3d/audio3d.cpp create mode 100644 src/core/libraries/audio3d/audio3d.h create mode 100644 src/core/libraries/audio3d/audio3d_error.h create mode 100644 src/core/libraries/audio3d/audio3d_impl.cpp create mode 100644 src/core/libraries/audio3d/audio3d_impl.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a24d6df7..90496953 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,6 +260,11 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp src/core/libraries/ngs2/ngs2_impl.cpp src/core/libraries/ngs2/ngs2_impl.h src/core/libraries/ajm/ajm_error.h + src/core/libraries/audio3d/audio3d.cpp + src/core/libraries/audio3d/audio3d.h + src/core/libraries/audio3d/audio3d_error.h + src/core/libraries/audio3d/audio3d_impl.cpp + src/core/libraries/audio3d/audio3d_impl.h ) set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 3257a601..c3088f92 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -113,6 +113,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Lib, ImeDialog) \ SUB(Lib, AvPlayer) \ SUB(Lib, Ngs2) \ + SUB(Lib, Audio3d) \ CLS(Frontend) \ CLS(Render) \ SUB(Render, Vulkan) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index dbae836c..749568da 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -80,6 +80,7 @@ enum class Class : u8 { Lib_ImeDialog, ///< The LibSceImeDialog implementation. Lib_AvPlayer, ///< The LibSceAvPlayer implementation. Lib_Ngs2, ///< The LibSceNgs2 implementation. + Lib_Audio3d, ///< The LibSceAudio3d implementation. Frontend, ///< Emulator UI Render, ///< Video Core Render_Vulkan, ///< Vulkan backend diff --git a/src/core/libraries/audio3d/audio3d.cpp b/src/core/libraries/audio3d/audio3d.cpp new file mode 100644 index 00000000..63815a06 --- /dev/null +++ b/src/core/libraries/audio3d/audio3d.cpp @@ -0,0 +1,344 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "audio3d.h" +#include "audio3d_error.h" +#include "audio3d_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/audio/audioout.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" + +namespace Libraries::Audio3d { + +// Audio3d + +int PS4_SYSV_ABI sceAudio3dInitialize(s64 iReserved) { + LOG_INFO(Lib_Audio3d, "iReserved = {}", iReserved); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dTerminate() { + // TODO: When not initialized or some ports still open, return ORBIS_AUDIO3D_ERROR_NOT_READY + LOG_INFO(Lib_Audio3d, "called"); + return ORBIS_OK; +} + +void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* sParameters) { + if (sParameters != NULL) { + sParameters->szSizeThis = sizeof(OrbisAudio3dOpenParameters); + sParameters->uiGranularity = 256; + sParameters->eRate = ORBIS_AUDIO3D_RATE_48000; + sParameters->uiMaxObjects = 512; + sParameters->uiQueueDepth = 2; + sParameters->eBufferMode = ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH; + sParameters->uiNumBeds = 2; + } else { + LOG_ERROR(Lib_Audio3d, "Invalid OpenParameters ptr"); + } +} + +int PS4_SYSV_ABI sceAudio3dPortOpen(OrbisUserServiceUserId iUserId, + const OrbisAudio3dOpenParameters* pParameters, + OrbisAudio3dPortId* pId) { + LOG_INFO(Lib_Audio3d, "iUserId = {}", iUserId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortClose(OrbisAudio3dPortId uiPortId) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortSetAttribute(OrbisAudio3dPortId uiPortId, + OrbisAudio3dAttributeId uiAttributeId, + const void* pAttribute, size_t szAttribute) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiAttributeId = {}, szAttribute = {}", uiPortId, + uiAttributeId, szAttribute); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortFlush(OrbisAudio3dPortId uiPortId) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortAdvance(OrbisAudio3dPortId uiPortId) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortPush(OrbisAudio3dPortId uiPortId, OrbisAudio3dBlocking eBlocking) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortGetAttributesSupported(OrbisAudio3dPortId uiPortId, + OrbisAudio3dAttributeId* pCapabilities, + unsigned int* pNumCapabilities) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortGetQueueLevel(OrbisAudio3dPortId uiPortId, unsigned int* pQueueLevel, + unsigned int* pQueueAvailable) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dObjectReserve(OrbisAudio3dPortId uiPortId, OrbisAudio3dObjectId* pId) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dObjectUnreserve(OrbisAudio3dPortId uiPortId, + OrbisAudio3dObjectId uiObjectId) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiObjectId = {}", uiPortId, uiObjectId); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dObjectSetAttributes(OrbisAudio3dPortId uiPortId, + OrbisAudio3dObjectId uiObjectId, + size_t szNumAttributes, + const OrbisAudio3dAttribute* pAttributeArray) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiObjectId = {}, szNumAttributes = {}", uiPortId, + uiObjectId, szNumAttributes); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dBedWrite(OrbisAudio3dPortId uiPortId, unsigned int uiNumChannels, + OrbisAudio3dFormat eFormat, const void* pBuffer, + unsigned int uiNumSamples) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}", uiPortId, + uiNumChannels, uiNumSamples); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dBedWrite2(OrbisAudio3dPortId uiPortId, unsigned int uiNumChannels, + OrbisAudio3dFormat eFormat, const void* pBuffer, + unsigned int uiNumSamples, + OrbisAudio3dOutputRoute eOutputRoute, bool bRestricted) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}, bRestricted = {}", + uiPortId, uiNumChannels, uiNumSamples, bRestricted); + return ORBIS_OK; +} + +size_t PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMemorySize(unsigned int uiNumSpeakers, bool bIs3d) { + LOG_INFO(Lib_Audio3d, "uiNumSpeakers = {}, bIs3d = {}", uiNumSpeakers, bIs3d); + return ORBIS_OK; +} + +int PS4_SYSV_ABI +sceAudio3dCreateSpeakerArray(OrbisAudio3dSpeakerArrayHandle* pHandle, + const OrbisAudio3dSpeakerArrayParameters* pParameters) { + if (pHandle == nullptr || pParameters == nullptr) { + LOG_ERROR(Lib_Audio3d, "invalid SpeakerArray parameters"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + LOG_INFO(Lib_Audio3d, "called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dDeleteSpeakerArray(OrbisAudio3dSpeakerArrayHandle handle) { + if (handle == nullptr) { + LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + LOG_INFO(Lib_Audio3d, "called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients(OrbisAudio3dSpeakerArrayHandle handle, + OrbisAudio3dPosition pos, float fSpread, + float* pCoefficients, + unsigned int uiNumCoefficients) { + LOG_INFO(Lib_Audio3d, "fSpread = {}, uiNumCoefficients = {}", fSpread, uiNumCoefficients); + if (handle == nullptr) { + LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients2(OrbisAudio3dSpeakerArrayHandle handle, + OrbisAudio3dPosition pos, float fSpread, + float* pCoefficients, + unsigned int uiNumCoefficients, + bool bHeightAware, + float fDownmixSpreadRadius) { + LOG_INFO(Lib_Audio3d, + "fSpread = {}, uiNumCoefficients = {}, bHeightAware = {}, fDownmixSpreadRadius = {}", + fSpread, uiNumCoefficients, bHeightAware, fDownmixSpreadRadius); + if (handle == nullptr) { + LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dAudioOutOpen(OrbisAudio3dPortId uiPortId, OrbisUserServiceUserId userId, + s32 type, s32 index, u32 len, u32 freq, u32 param) { + LOG_INFO(Lib_Audio3d, + "uiPortId = {}, userId = {}, type = {}, index = {}, len = {}, freq = {}, param = {}", + uiPortId, userId, type, index, len, freq, param); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dAudioOutClose(s32 handle) { + LOG_INFO(Lib_Audio3d, "handle = {}", handle); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dAudioOutOutput(s32 handle, const void* ptr) { + LOG_INFO(Lib_Audio3d, "handle = {}", handle); + if (ptr == nullptr) { + LOG_ERROR(Lib_Audio3d, "invalid Output ptr"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dAudioOutOutputs(::Libraries::AudioOut::OrbisAudioOutOutputParam* param, + s32 num) { + LOG_INFO(Lib_Audio3d, "num = {}", num); + if (param == nullptr) { + LOG_ERROR(Lib_Audio3d, "invalid OutputParam ptr"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortCreate(unsigned int uiGranularity, OrbisAudio3dRate eRate, + s64 iReserved, OrbisAudio3dPortId* pId) { + LOG_INFO(Lib_Audio3d, "uiGranularity = {}, iReserved = {}", uiGranularity, iReserved); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortDestroy(OrbisAudio3dPortId uiPortId) { + LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); + return ORBIS_OK; +} + +// Audio3dPrivate + +const char* PS4_SYSV_ABI sceAudio3dStrError(int iErrorCode) { + LOG_ERROR(Lib_Audio3d, "(PRIVATE) called, iErrorCode = {}", iErrorCode); + return "NOT_IMPLEMENTED"; +} + +// Audio3dDebug + +int PS4_SYSV_ABI sceAudio3dPortQueryDebug() { + LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortQueryDebug called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortGetList() { + LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortGetList called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortGetParameters() { + LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortGetParameters called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortGetState() { + LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortGetState called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortFreeState() { + LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortFreeState called"); + return ORBIS_OK; +} + +// Unknown + +int PS4_SYSV_ABI sceAudio3dPortGetBufferLevel() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dPortGetStatus() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dReportRegisterHandler() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dReportUnregisterHandler() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceAudio3dSetGpuRenderer() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("-R1DukFq7Dk", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dGetSpeakerArrayMixCoefficients); + LIB_FUNCTION("-Re+pCWvwjQ", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dGetSpeakerArrayMixCoefficients2); + LIB_FUNCTION("-pzYDZozm+M", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortQueryDebug); + LIB_FUNCTION("1HXxo-+1qCw", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dObjectUnreserve); + LIB_FUNCTION("4uyHN9q4ZeU", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dObjectSetAttributes); + LIB_FUNCTION("7NYEzJ9SJbM", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dAudioOutOutput); + LIB_FUNCTION("8hm6YdoQgwg", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dDeleteSpeakerArray); + LIB_FUNCTION("9ZA23Ia46Po", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortGetAttributesSupported); + LIB_FUNCTION("9tEwE0GV0qo", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dBedWrite); + LIB_FUNCTION("Aacl5qkRU6U", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dStrError); + LIB_FUNCTION("CKHlRW2E9dA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetState); + LIB_FUNCTION("HbxYY27lK6E", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dAudioOutOutputs); + LIB_FUNCTION("Im+jOoa5WAI", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dGetDefaultOpenParameters); + LIB_FUNCTION("Mw9mRQtWepY", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortDestroy); + LIB_FUNCTION("OyVqOeVNtSk", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortClose); + LIB_FUNCTION("QfNXBrKZeI0", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dReportRegisterHandler); + LIB_FUNCTION("QqgTQQdzEMY", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortGetBufferLevel); + LIB_FUNCTION("SEggctIeTcI", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetList); + LIB_FUNCTION("UHFOgVNz0kk", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortCreate); + LIB_FUNCTION("UmCvjSmuZIw", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dInitialize); + LIB_FUNCTION("VEVhZ9qd4ZY", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortPush); + LIB_FUNCTION("WW1TS2iz5yc", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dTerminate); + LIB_FUNCTION("XeDDK0xJWQA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortOpen); + LIB_FUNCTION("YaaDbDwKpFM", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortGetQueueLevel); + LIB_FUNCTION("Yq9bfUQ0uJg", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortSetAttribute); + LIB_FUNCTION("ZOGrxWLgQzE", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortFlush); + LIB_FUNCTION("flPcUaXVXcw", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortGetParameters); + LIB_FUNCTION("iRX6GJs9tvE", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetStatus); + LIB_FUNCTION("jO2tec4dJ2M", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dObjectReserve); + LIB_FUNCTION("kEqqyDkmgdI", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dGetSpeakerArrayMemorySize); + LIB_FUNCTION("lvWMW6vEqFU", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dCreateSpeakerArray); + LIB_FUNCTION("lw0qrdSjZt8", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortAdvance); + LIB_FUNCTION("pZlOm1aF3aA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutClose); + LIB_FUNCTION("psv2gbihC1A", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dReportUnregisterHandler); + LIB_FUNCTION("uJ0VhGcxCTQ", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortFreeState); + LIB_FUNCTION("ucEsi62soTo", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutOpen); + LIB_FUNCTION("xH4Q9UILL3o", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dBedWrite2); + LIB_FUNCTION("yEYXcbAGK14", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dSetGpuRenderer); +}; + +} // namespace Libraries::Audio3d \ No newline at end of file diff --git a/src/core/libraries/audio3d/audio3d.h b/src/core/libraries/audio3d/audio3d.h new file mode 100644 index 00000000..6cbe2d02 --- /dev/null +++ b/src/core/libraries/audio3d/audio3d.h @@ -0,0 +1,134 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +#include + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::Audio3d { + +class Audio3d; + +typedef int OrbisUserServiceUserId; +typedef unsigned int OrbisAudio3dPortId; +typedef unsigned int OrbisAudio3dObjectId; +typedef unsigned int OrbisAudio3dAttributeId; + +enum OrbisAudio3dFormat { + ORBIS_AUDIO3D_FORMAT_S16 = 0, // s16 + ORBIS_AUDIO3D_FORMAT_FLOAT = 1 // f32 +}; + +enum OrbisAudio3dRate { ORBIS_AUDIO3D_RATE_48000 = 0 }; + +enum OrbisAudio3dBufferMode { + ORBIS_AUDIO3D_BUFFER_NO_ADVANCE = 0, + ORBIS_AUDIO3D_BUFFER_ADVANCE_NO_PUSH = 1, + ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH = 2 +}; + +enum OrbisAudio3dBlocking { ORBIS_AUDIO3D_BLOCKING_ASYNC = 0, ORBIS_AUDIO3D_BLOCKING_SYNC = 1 }; + +enum OrbisAudio3dPassthrough { + ORBIS_AUDIO3D_PASSTHROUGH_NONE = 0, + ORBIS_AUDIO3D_PASSTHROUGH_LEFT = 1, + ORBIS_AUDIO3D_PASSTHROUGH_RIGHT = 2 +}; + +enum OrbisAudio3dOutputRoute { + ORBIS_AUDIO3D_OUTPUT_BOTH = 0, + ORBIS_AUDIO3D_OUTPUT_HMU_ONLY = 1, + ORBIS_AUDIO3D_OUTPUT_TV_ONLY = 2 +}; + +enum OrbisAudio3dAmbisonics { + ORBIS_AUDIO3D_AMBISONICS_NONE = ~0, + ORBIS_AUDIO3D_AMBISONICS_W = 0, + ORBIS_AUDIO3D_AMBISONICS_X = 1, + ORBIS_AUDIO3D_AMBISONICS_Y = 2, + ORBIS_AUDIO3D_AMBISONICS_Z = 3, + ORBIS_AUDIO3D_AMBISONICS_R = 4, + ORBIS_AUDIO3D_AMBISONICS_S = 5, + ORBIS_AUDIO3D_AMBISONICS_T = 6, + ORBIS_AUDIO3D_AMBISONICS_U = 7, + ORBIS_AUDIO3D_AMBISONICS_V = 8, + ORBIS_AUDIO3D_AMBISONICS_K = 9, + ORBIS_AUDIO3D_AMBISONICS_L = 10, + ORBIS_AUDIO3D_AMBISONICS_M = 11, + ORBIS_AUDIO3D_AMBISONICS_N = 12, + ORBIS_AUDIO3D_AMBISONICS_O = 13, + ORBIS_AUDIO3D_AMBISONICS_P = 14, + ORBIS_AUDIO3D_AMBISONICS_Q = 15 +}; + +static const OrbisAudio3dAttributeId s_sceAudio3dAttributePcm = 0x00000001; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributePriority = 0x00000002; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributePosition = 0x00000003; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeSpread = 0x00000004; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeGain = 0x00000005; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributePassthrough = 0x00000006; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeResetState = 0x00000007; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeApplicationSpecific = 0x00000008; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeAmbisonics = 0x00000009; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeRestricted = 0x0000000A; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeOutputRoute = 0x0000000B; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeLateReverbLevel = 0x00010001; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeDownmixSpreadRadius = 0x00010002; +static const OrbisAudio3dAttributeId s_sceAudio3dAttributeDownmixSpreadHeightAware = 0x00010003; + +struct OrbisAudio3dSpeakerArray; +using OrbisAudio3dSpeakerArrayHandle = OrbisAudio3dSpeakerArray*; // head + +struct OrbisAudio3dOpenParameters { + size_t szSizeThis; + unsigned int uiGranularity; + OrbisAudio3dRate eRate; + unsigned int uiMaxObjects; + unsigned int uiQueueDepth; + OrbisAudio3dBufferMode eBufferMode; + char padding[32]; + unsigned int uiNumBeds; +}; + +struct OrbisAudio3dAttribute { + OrbisAudio3dAttributeId uiAttributeId; + char padding[32]; + const void* pValue; + size_t szValue; +}; + +struct OrbisAudio3dPosition { + float fX; + float fY; + float fZ; +}; + +struct OrbisAudio3dPcm { + OrbisAudio3dFormat eFormat; + const void* pSampleBuffer; + unsigned int uiNumSamples; +}; + +struct OrbisAudio3dSpeakerArrayParameters { + OrbisAudio3dPosition* pSpeakerPosition; + unsigned int uiNumSpeakers; + bool bIs3d; + void* pBuffer; + size_t szSize; +}; + +struct OrbisAudio3dApplicationSpecific { + size_t szSizeThis; + u8 cApplicationSpecific[32]; +}; + +void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* sParameters); + +void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::Audio3d \ No newline at end of file diff --git a/src/core/libraries/audio3d/audio3d_error.h b/src/core/libraries/audio3d/audio3d_error.h new file mode 100644 index 00000000..ff9d9749 --- /dev/null +++ b/src/core/libraries/audio3d/audio3d_error.h @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +constexpr int ORBIS_AUDIO3D_ERROR_UNKNOWN = 0x80EA0001; +constexpr int ORBIS_AUDIO3D_ERROR_INVALID_PORT = 0x80EA0002; +constexpr int ORBIS_AUDIO3D_ERROR_INVALID_OBJECT = 0x80EA0003; +constexpr int ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER = 0x80EA0004; +constexpr int ORBIS_AUDIO3D_ERROR_OUT_OF_MEMORY = 0x80EA0005; +constexpr int ORBIS_AUDIO3D_ERROR_OUT_OF_RESOURCES = 0x80EA0006; +constexpr int ORBIS_AUDIO3D_ERROR_NOT_READY = 0x80EA0007; +constexpr int ORBIS_AUDIO3D_ERROR_NOT_SUPPORTED = 0x80EA0008; diff --git a/src/core/libraries/audio3d/audio3d_impl.cpp b/src/core/libraries/audio3d/audio3d_impl.cpp new file mode 100644 index 00000000..c267c096 --- /dev/null +++ b/src/core/libraries/audio3d/audio3d_impl.cpp @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "audio3d_error.h" +#include "audio3d_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/kernel/libkernel.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Audio3d {} // namespace Libraries::Audio3d diff --git a/src/core/libraries/audio3d/audio3d_impl.h b/src/core/libraries/audio3d/audio3d_impl.h new file mode 100644 index 00000000..4e6342b1 --- /dev/null +++ b/src/core/libraries/audio3d/audio3d_impl.h @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "audio3d.h" + +namespace Libraries::Audio3d { + +class Audio3d { +public: +private: + typedef unsigned int OrbisAudio3dPluginId; +}; + +} // namespace Libraries::Audio3d diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index e91a51e6..da41eaf0 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -6,6 +6,7 @@ #include "core/libraries/app_content/app_content.h" #include "core/libraries/audio/audioin.h" #include "core/libraries/audio/audioout.h" +#include "core/libraries/audio3d/audio3d.h" #include "core/libraries/avplayer/avplayer.h" #include "core/libraries/dialogs/error_dialog.h" #include "core/libraries/dialogs/ime_dialog.h" @@ -75,6 +76,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::ErrorDialog::RegisterlibSceErrorDialog(sym); Libraries::ImeDialog::RegisterlibSceImeDialog(sym); Libraries::AvPlayer::RegisterlibSceAvPlayer(sym); + Libraries::Audio3d::RegisterlibSceAudio3d(sym); } } // namespace Libraries