diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 90c1d8cf54eb..1f9d9ac95827 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -270,6 +270,7 @@ if(AX_ENABLE_AUDIO) # The openal-soft(LGPL 2.1) if(NOT EMSCRIPTEN) set(alsoft_opts + "ALSOFT_ENABLE_MODULES OFF" "ALSOFT_DLOPEN OFF" "ALSOFT_UTILS OFF" "ALSOFT_EXAMPLES OFF" diff --git a/3rdparty/README.md b/3rdparty/README.md index 964adfd6b9ce..7d0d2b18be14 100644 --- a/3rdparty/README.md +++ b/3rdparty/README.md @@ -183,12 +183,13 @@ ## OpenAL Soft - [![Upstream](https://img.shields.io/github/v/release/kcat/openal-soft?label=Upstream)](https://github.com/kcat/openal-soft) -- Version: 1.25.1-b2255be +- Version: 1.25.2 - Modifications: - Remove `-Werror=undef` - Linking `fmt::fmt` instead `alsoft::fmt` - Exclude target `alsoft::excommon` - Fix `al::char_as_u8/al::u8_as_char` in `common/alstring.hpp` with compiler flag: `-fno-char8_t` or `/Zc:char8_t-` + - Disable non‑standard [[clang::nonblocking]] attribute on Win32 to avoid compiler compatibility issues - License: LGPL-2.1 ## OpenSSL diff --git a/3rdparty/jolt/Jolt/Jolt.cmake b/3rdparty/jolt/Jolt/Jolt.cmake index cb1a92709652..fc0787d62446 100644 --- a/3rdparty/jolt/Jolt/Jolt.cmake +++ b/3rdparty/jolt/Jolt/Jolt.cmake @@ -1026,7 +1026,7 @@ else() endif() # On Unix flavors we need the pthread library -if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") AND NOT EMSCRIPTEN) +if (NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") AND NOT EMSCRIPTEN) target_compile_options(Jolt PUBLIC -pthread) target_link_options(Jolt PUBLIC -pthread) endif() diff --git a/3rdparty/openal/CMakeLists.txt b/3rdparty/openal/CMakeLists.txt index 8a85c929cdcd..9b5e4c6557f6 100644 --- a/3rdparty/openal/CMakeLists.txt +++ b/3rdparty/openal/CMakeLists.txt @@ -41,7 +41,7 @@ else() endif() project(OpenAL - VERSION 1.25.1 + VERSION 1.25.2 LANGUAGES C CXX) if(NOT CMAKE_BUILD_TYPE) @@ -79,6 +79,8 @@ include(CheckStructHasMember) include(CMakePackageConfigHelpers) include(GNUInstallDirs) +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads) find_package(PkgConfig) find_package(SDL3 QUIET) @@ -268,10 +270,20 @@ set(LINKER_FLAGS_DEBUG ) set(LINKER_FLAGS_RELEASE ) set(EXTRA_LIBS ) +if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0) + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20.0)) + check_cxx_compiler_flag(-Wfunction-effects HAVE_WFUNCTION_EFFECTS) + if(HAVE_WFUNCTION_EFFECTS) + list(APPEND C_FLAGS $<$:-Wfunction-effects>) + endif() +endif() + if(WIN32) - set(CPP_DEFS ${CPP_DEFS} _WIN32 NOMINMAX WIN32_LEAN_AND_MEAN) + list(APPEND CPP_DEFS _WIN32 NOMINMAX WIN32_LEAN_AND_MEAN) if(MINGW) - set(CPP_DEFS ${CPP_DEFS} __USE_MINGW_ANSI_STDIO) + list(APPEND CPP_DEFS __USE_MINGW_ANSI_STDIO) endif() option(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF) @@ -290,7 +302,7 @@ if(WIN32) return 0; }" HAVE_SHGETKNOWNFOLDERPATH_NO_NTDDI) if(NOT HAVE_SHGETKNOWNFOLDERPATH_NO_NTDDI) - set(CPP_DEFS ${CPP_DEFS} NTDDI_VERSION=NTDDI_VISTA) + list(APPEND CPP_DEFS NTDDI_VERSION=NTDDI_VISTA) endif() endif() elseif(APPLE) @@ -300,8 +312,8 @@ endif() # QNX's gcc do not uses /usr/include and /usr/lib paths by default if("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX") - set(INC_PATHS ${INC_PATHS} /usr/include) - set(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib) + list(APPEND INC_PATHS /usr/include) + list(APPEND LINKER_FLAGS -L/usr/lib) endif() # When the library is built for static linking, apps should define @@ -321,9 +333,9 @@ std::atomic foo{0}; int main() { return foo.fetch_add(2); }" HAVE_LIBATOMIC) if(NOT HAVE_LIBATOMIC) - set(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}") + set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES}) else() - set(EXTRA_LIBS atomic ${EXTRA_LIBS}) + list(APPEND EXTRA_LIBS atomic) endif() unset(OLD_REQUIRED_LIBRARIES) @@ -331,8 +343,8 @@ if(ANDROID) # Include liblog for Android logging check_library_exists(log __android_log_print "" HAVE_LIBLOG) if(HAVE_LIBLOG) - set(EXTRA_LIBS log ${EXTRA_LIBS}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log) + list(APPEND EXTRA_LIBS log) + list(APPEND CMAKE_REQUIRED_LIBRARIES log) endif() endif() @@ -342,17 +354,17 @@ if(MSVC) # when locked. Ideally the runtime should be updated on the system, but # until the update becomes more widespread, this helps avoid some pain # points. - set(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) + list(APPEND CPP_DEFS _CRT_SECURE_NO_WARNINGS _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) check_cxx_compiler_flag(/permissive- HAVE_PERMISSIVE_SWITCH) if(HAVE_PERMISSIVE_SWITCH) - set(C_FLAGS ${C_FLAGS} $<$:/permissive->) + list(APPEND C_FLAGS $<$:/permissive->) endif() # C4127 - conditional expression is constant # C4324 - structure was padded due to alignment specifier # C4373 - virtual function overrides 'base_function', previous versions of # the compiler did not override when parameters only differed by # const/volatile qualifiers - set(C_FLAGS ${C_FLAGS} /W4 /wd4127 /wd4324 /wd4373 /utf-8 $<$:/EHsc>) + list(APPEND C_FLAGS /W4 /wd4127 /wd4324 /wd4373 /utf-8 $<$:/EHsc>) if(NOT DXSDK_DIR) string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}") @@ -369,38 +381,37 @@ else() # feeble_inline gets implemented and used, or inline is ignored by default, # we'll have to ignore inline warning. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93008 - set(C_FLAGS ${C_FLAGS} -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align -Wpedantic + list(APPEND C_FLAGS -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align -Wpedantic -Wformat -Wformat=2 $<$:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>) check_c_compiler_flag(-Wtrampolines HAVE_WTRAMPOLINES) if(HAVE_WTRAMPOLINES) - set(C_FLAGS ${C_FLAGS} -Wtrampolines) + list(APPEND C_FLAGS -Wtrampolines) endif() check_c_compiler_flag(-Wconversion HAVE_WCONVERSION) if(HAVE_WCONVERSION) - set(C_FLAGS ${C_FLAGS} -Wconversion) - endif() - check_c_compiler_flag(-Warith-conversion HAVE_WARITH_CONVERSION) - if(HAVE_WARITH_CONVERSION) - set(C_FLAGS ${C_FLAGS} -Warith-conversion) + list(APPEND C_FLAGS -Wconversion) endif() check_c_compiler_flag(-Wbidi-chars=any HAVE_WBIDI_CHARS_ANY) if(HAVE_WBIDI_CHARS_ANY) - set(C_FLAGS ${C_FLAGS} -Wbidi-chars=any) + list(APPEND C_FLAGS -Wbidi-chars=any) endif() check_cxx_compiler_flag(-Wno-interference-size HAVE_WNO_INTERFERENCE_SIZE) if(HAVE_WNO_INTERFERENCE_SIZE) - set(C_FLAGS ${C_FLAGS} $<$:-Wno-interference-size>) + list(APPEND C_FLAGS $<$:-Wno-interference-size>) endif() # Axmol spec: avoid affect other thirdparty libs # if(ALSOFT_WERROR) - # set(C_FLAGS ${C_FLAGS} -Werror) + # list(APPEND C_FLAGS -Werror) # else() - # set(C_FLAGS ${C_FLAGS} -Werror=undef -Werror=format-security + # list(APPEND C_FLAGS -Werror=undef -Werror=format-security # $<$:-Werror=implicit -Werror=incompatible-pointer-types # -Werror=int-conversion>) + # if(HAVE_WFUNCTION_EFFECTS) + # list(APPEND C_FLAGS $<$:-Werror=function-effects>) + # endif() # endif() # NOTE: This essentially provides the equivalent of the C++26 feature to @@ -409,35 +420,35 @@ else() # initialization where necessary. check_c_compiler_flag(-ftrivial-auto-var-init=pattern HAVE_FTRIVIAL_AUTO_VAR_INIT) if(HAVE_FTRIVIAL_AUTO_VAR_INIT) - set(C_FLAGS ${C_FLAGS} -ftrivial-auto-var-init=pattern) + list(APPEND C_FLAGS -ftrivial-auto-var-init=pattern) endif() check_c_compiler_flag(-fno-math-errno HAVE_FNO_MATH_ERRNO) if(HAVE_FNO_MATH_ERRNO) - set(C_FLAGS ${C_FLAGS} -fno-math-errno) + list(APPEND C_FLAGS -fno-math-errno) endif() check_linker_flag(C "-Wl,-z,noexecstack" HAVE_WL_Z_NOEXECSTACK) if(HAVE_WL_Z_NOEXECSTACK) - set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,-z,noexecstack") + list(APPEND LINKER_FLAGS "-Wl,-z,noexecstack") endif() check_linker_flag(C "-Wl,-z,relro" HAVE_WL_Z_RELRO) if(HAVE_WL_Z_RELRO) - set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,-z,relro") + list(APPEND LINKER_FLAGS "-Wl,-z,relro") endif() check_linker_flag(C "-Wl,-z,now" HAVE_WL_Z_NOW) if(HAVE_WL_Z_NOW) - set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,-z,now") + list(APPEND LINKER_FLAGS "-Wl,-z,now") endif() check_linker_flag(C "-Wl,--as-needed,--no-copy-dt-needed-entries" HAVE_WL_AS_NEEDED) if(HAVE_WL_AS_NEEDED) - set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--as-needed,--no-copy-dt-needed-entries") + list(APPEND LINKER_FLAGS "-Wl,--as-needed,--no-copy-dt-needed-entries") endif() option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF) if(ALSOFT_STATIC_LIBGCC) set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc) + list(APPEND CMAKE_REQUIRED_LIBRARIES -static-libgcc) check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBGCC_SWITCH) set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES}) unset(OLD_REQUIRED_LIBRARIES) @@ -445,13 +456,13 @@ else() if(NOT HAVE_STATIC_LIBGCC_SWITCH) message(FATAL_ERROR "Cannot static link libgcc") endif() - set(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc) + list(APPEND LINKER_FLAGS -static-libgcc) endif() option(ALSOFT_STATIC_STDCXX "Static link libstdc++" OFF) if(ALSOFT_STATIC_STDCXX) set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-static-libstdc++") + list(APPEND CMAKE_REQUIRED_LIBRARIES "-static-libstdc++") check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBSTDCXX_SWITCH) set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES}) unset(OLD_REQUIRED_LIBRARIES) @@ -459,14 +470,14 @@ else() if(NOT HAVE_STATIC_LIBSTDCXX_SWITCH) message(FATAL_ERROR "Cannot static link libstdc++") endif() - set(LINKER_FLAGS ${LINKER_FLAGS} "-static-libstdc++") + list(APPEND LINKER_FLAGS "-static-libstdc++") endif() if(WIN32) option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF) if(ALSOFT_STATIC_WINPTHREAD) set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state") + list(APPEND CMAKE_REQUIRED_LIBRARIES "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state") check_cxx_source_compiles("int main() { }" HAVE_STATIC_LIBWINPTHREAD_SWITCH) set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES}) unset(OLD_REQUIRED_LIBRARIES) @@ -474,7 +485,7 @@ else() if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH) message(FATAL_ERROR "Cannot static link libwinpthread") endif() - set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state") + list(APPEND LINKER_FLAGS "-Wl,--push-state,-Bstatic,-lstdc++,-lwinpthread,--pop-state") endif() endif() endif() @@ -484,27 +495,21 @@ if(NOT LIBTYPE STREQUAL "STATIC") if(WIN32) set(EXPORT_DECL "__declspec(dllexport)") else() - set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) # Yes GCC, really don't accept visibility modes you don't support - set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror") + list(APPEND CMAKE_REQUIRED_FLAGS -Wattributes -Werror) - check_c_source_compiles("int foo() __attribute__((visibility(\"protected\"))); - int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY) - if(HAVE_GCC_PROTECTED_VISIBILITY) - set(EXPORT_DECL "__attribute__((visibility(\"protected\")))") - else() - check_c_source_compiles("int foo() __attribute__((visibility(\"default\"))); - int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY) - if(HAVE_GCC_DEFAULT_VISIBILITY) - set(EXPORT_DECL "__attribute__((visibility(\"default\")))") - endif() + check_c_source_compiles("int foo() __attribute__((visibility(\"default\"))); + int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY) + if(HAVE_GCC_DEFAULT_VISIBILITY) + set(EXPORT_DECL "__attribute__((visibility(\"default\")))") endif() - if(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY) + if(HAVE_GCC_DEFAULT_VISIBILITY) set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) endif() - set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}") + set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) endif() endif() @@ -514,13 +519,18 @@ set(SSE2_SWITCH "") if(NOT MSVC) set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) # Yes GCC, really don't accept command line options you don't support - set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror") + list(APPEND CMAKE_REQUIRED_FLAGS -Werror) check_c_compiler_flag(-msse2 HAVE_MSSE2_SWITCH) if(HAVE_MSSE2_SWITCH) set(SSE2_SWITCH "-msse2") endif() set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) unset(OLD_REQUIRED_FLAGS) + # Allow detection of the OpenPOWER<-->SSE translation layer + if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64.*") + list(APPEND C_FLAGS -DNO_WARN_X86_INTRINSICS) + list(APPEND CMAKE_REQUIRED_FLAGS -DNO_WARN_X86_INTRINSICS) + endif() endif() check_include_file(xmmintrin.h HAVE_XMMINTRIN_H) @@ -600,15 +610,15 @@ if(CMAKE_SIZEOF_VOID_P MATCHES "4" AND HAVE_SSE2) if(MSVC) check_c_compiler_flag("/arch:SSE2" HAVE_ARCH_SSE2) if(HAVE_ARCH_SSE2) - set(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2") - set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS}) + list(APPEND SSE_FLAGS "/arch:SSE2") + list(APPEND C_FLAGS ${SSE_FLAGS}) set(FPMATH_SET 2) endif() elseif(SSE2_SWITCH) check_c_compiler_flag("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2) if(HAVE_MFPMATH_SSE_2) - set(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse) - set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS}) + list(APPEND SSE_FLAGS ${SSE2_SWITCH} -mfpmath=sse) + list(APPEND C_FLAGS ${SSE_FLAGS}) set(FPMATH_SET 2) endif() # SSE depends on a 16-byte aligned stack, and by default, GCC @@ -623,14 +633,13 @@ endif() if(HAVE_SSE2) set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) - foreach(flag_var ${SSE_FLAGS}) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}") - endforeach() + list(APPEND CMAKE_REQUIRED_FLAGS ${SSE_FLAGS}) check_c_source_compiles("#include int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS) set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) + unset(OLD_REQUIRED_FLAGS) endif() @@ -642,8 +651,8 @@ check_include_file(guiddef.h HAVE_GUIDDEF_H) set(MATH_LIB ) check_library_exists(m pow "" HAVE_LIBM) if(HAVE_LIBM) - set(MATH_LIB ${MATH_LIB} m) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) + list(APPEND MATH_LIB m) + list(APPEND CMAKE_REQUIRED_LIBRARIES m) endif() # Some systems need to link with -lrt for clock_gettime as used by the common @@ -655,12 +664,17 @@ if(HAVE_LIBRT) endif() # Check for the dlopen API (for dynamically loading backend libs) +set(HAVE_DYNLOAD 0) if(ALSOFT_DLOPEN) check_include_file(dlfcn.h HAVE_DLFCN_H) check_library_exists(dl dlopen "" HAVE_LIBDL) if(HAVE_LIBDL) - set(EXTRA_LIBS dl ${EXTRA_LIBS}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl) + list(APPEND EXTRA_LIBS dl) + list(APPEND CMAKE_REQUIRED_LIBRARIES dl) + endif() + + if(HAVE_LIBDL OR WIN32) + set(HAVE_DYNLOAD 1) endif() endif() @@ -686,20 +700,6 @@ endif() check_symbol_exists(proc_pidpath libproc.h HAVE_PROC_PIDPATH) if(NOT WIN32) - # We need pthreads outside of Windows, for semaphores. It's also used to - # set the priority and name of threads, when possible. - check_include_file(pthread.h HAVE_PTHREAD_H) - if(NOT HAVE_PTHREAD_H) - message(FATAL_ERROR "PThreads is required for non-Windows builds!") - endif() - - check_c_compiler_flag(-pthread HAVE_PTHREAD) - if(HAVE_PTHREAD) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread") - set(C_FLAGS ${C_FLAGS} -pthread) - set(LINKER_FLAGS ${LINKER_FLAGS} -pthread) - endif() - check_symbol_exists(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM) # Some systems need pthread_np.h to get pthread_setname_np @@ -720,39 +720,43 @@ endif() # Common sources used by both the OpenAL implementation library, the OpenAL # router, and certain tools and examples. -set(COMMON_OBJS - common/albit.h +set(COMMON_MODS ) +set(COMMON_SRCS common/alcomplex.cpp + common/almalloc.cpp + common/alstring.cpp + common/althrd_setname.cpp + common/altypes.cpp + common/dynload.cpp + common/filesystem.cpp + common/pffft.cpp + common/polyphase_resampler.cpp + common/strutils.cpp +) +set(COMMON_HDRS + common/albit.h common/alcomplex.h common/alformat.hpp - common/almalloc.cpp common/almalloc.h common/alnumeric.h - common/alstring.cpp common/alstring.h - common/althrd_setname.cpp common/althrd_setname.h common/althreads.h common/altypes.hpp common/atomic.h + common/bitset.hpp common/comptr.h - common/dynload.cpp common/dynload.h common/dlopennote.h common/expected.hpp - common/filesystem.cpp common/filesystem.h common/flexarray.h common/intrusive_ptr.h common/opthelpers.h - common/pffft.cpp common/pffft.h - common/phase_shifter.h - common/polyphase_resampler.cpp common/polyphase_resampler.h common/pragmadefs.h common/ringbuffer.h - common/strutils.cpp common/strutils.hpp common/vecmat.h common/vector.h @@ -767,79 +771,101 @@ set(COMMON_OBJS gsl/include/gsl/util gsl/include/gsl/zstring ) +if(HAVE_CXXMODULES) + list(APPEND COMMON_MODS + alsoft-modules/gsl.cppm + alsoft-modules/hann_window.cppm + alsoft-modules/phase_shifter.cppm + common/alformattypes.cppm + ) +else() + list(APPEND COMMON_HDRS + common/alformattypes.hpp + common/hann_window.hpp + common/phase_shifter.hpp + ) +endif() + # Core library routines -set(CORE_OBJS +set(CORE_MODS ) +set(CORE_SRCS + core/ambdec.cpp + core/ambidefs.cpp + core/bformatdec.cpp + core/bs2b.cpp + core/bsinc_tables.cpp + core/context.cpp + core/converter.cpp + core/cpu_caps.cpp + core/cubic_tables.cpp + core/devformat.cpp + core/device.cpp + core/effectslot.cpp + core/except.cpp + core/filters/biquad.cpp + core/filters/nfc.cpp + core/filters/splitter.cpp + core/fpu_ctrl.cpp + core/helpers.cpp + core/hrtf.cpp + core/hrtf_loader.cpp + core/hrtf_resource.cpp + core/logging.cpp + core/mastering.cpp + core/mixer.cpp + core/storage_formats.cpp + core/tsmefilter.cpp + core/uhjfilter.cpp + core/uiddefs.cpp + core/voice.cpp) +set(CORE_HDRS core/allpass_conv.hpp core/allpass_iir.hpp - core/ambdec.cpp core/ambdec.h - core/ambidefs.cpp core/ambidefs.h core/async_event.h - core/bformatdec.cpp core/bformatdec.h - core/bs2b.cpp core/bs2b.h core/bsinc_defs.h - core/bsinc_tables.cpp core/bsinc_tables.h core/bufferline.h core/buffer_storage.h - core/context.cpp core/context.h - core/converter.cpp core/converter.h - core/cpu_caps.cpp core/cpu_caps.h core/cubic_defs.h - core/cubic_tables.cpp core/cubic_tables.h - core/devformat.cpp + core/decoderbase.hpp core/devformat.h - core/device.cpp core/device.h core/effects/base.h - core/effectslot.cpp core/effectslot.h core/encoderbase.hpp - core/except.cpp core/except.h core/filters/biquad.h - core/filters/biquad.cpp - core/filters/nfc.cpp core/filters/nfc.h - core/filters/splitter.cpp core/filters/splitter.h core/fmt_traits.h - core/fpu_ctrl.cpp core/fpu_ctrl.h core/front_stablizer.h - core/helpers.cpp core/helpers.h - core/hrtf.cpp core/hrtf.h - core/hrtf_loader.cpp core/hrtf_loader.hpp - core/hrtf_resource.cpp core/hrtf_resource.hpp - core/logging.cpp - core/logging.h - core/mastering.cpp core/mastering.h - core/mixer.cpp core/mixer.h core/resampler_limits.h - core/storage_formats.cpp core/storage_formats.h - core/tsmefilter.cpp core/tsmefilter.hpp - core/uhjfilter.cpp core/uhjfilter.h - core/uiddefs.cpp - core/voice.cpp core/voice.h core/voice_change.h) +if(HAVE_CXXMODULES) + list(APPEND CORE_MODS core/logging.cppm) +else() + list(APPEND CORE_HDRS core/logging.h) +endif() set(HAVE_RTKIT 0) if(NOT WIN32) @@ -852,18 +878,19 @@ if(NOT WIN32) endif() if(DBus1_FOUND OR DBUS_FOUND) set(HAVE_RTKIT 1) - set(CORE_OBJS ${CORE_OBJS} core/rtkit.cpp core/rtkit.h) + list(APPEND CORE_SRCS core/rtkit.cpp) + list(APPEND CORE_HDRS core/rtkit.h) if(NOT DBus1_FOUND) - set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS}) - set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER}) + list(APPEND INC_PATHS ${DBUS_INCLUDE_DIRS}) + list(APPEND CPP_DEFS ${DBUS_CFLAGS_OTHER}) if(NOT HAVE_DLFCN_H) - set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES}) + list(APPEND EXTRA_LIBS ${DBUS_LINK_LIBRARIES}) endif() elseif(HAVE_DLFCN_H) - set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS}) - set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS}) + list(APPEND INC_PATHS ${DBus1_INCLUDE_DIRS}) + list(APPEND CPP_DEFS ${DBus1_DEFINITIONS}) else() - set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES}) + list(APPEND EXTRA_LIBS ${DBus1_LIBRARIES}) endif() else() set(MISSING_VARS "") @@ -883,23 +910,19 @@ if(ALSOFT_REQUIRE_RTKIT AND NOT HAVE_RTKIT) endif() # Default mixers, always available -set(CORE_OBJS ${CORE_OBJS} +list(APPEND CORE_SRCS + core/mixer/mixer_c.cpp) +list(APPEND CORE_HDRS core/mixer/defs.h core/mixer/hrtfbase.h - core/mixer/hrtfdefs.h - core/mixer/mixer_c.cpp) + core/mixer/hrtfdefs.h) # AL and related routines -set(OPENAL_OBJS +set(OPENAL_SRCS al/auxeffectslot.cpp - al/auxeffectslot.h al/buffer.cpp - al/buffer.h al/debug.cpp - al/debug.h - al/direct_defs.h al/effect.cpp - al/effect.h al/effects/autowah.cpp al/effects/chorus.cpp al/effects/compressor.cpp @@ -908,7 +931,6 @@ set(OPENAL_OBJS al/effects/distortion.cpp al/effects/echo.cpp al/effects/effects.cpp - al/effects/effects.h al/effects/equalizer.cpp al/effects/fshifter.cpp al/effects/modulator.cpp @@ -918,28 +940,30 @@ set(OPENAL_OBJS al/effects/vmorpher.cpp al/error.cpp al/event.cpp - al/event.h al/extension.cpp al/filter.cpp - al/filter.h al/listener.cpp - al/listener.h al/source.cpp - al/source.h al/state.cpp) +set(OPENAL_HDRS + al/auxeffectslot.h + al/buffer.h + al/debug.h + al/direct_defs.h + al/effect.h + al/effects/effects.h + al/event.h + al/filter.h + al/listener.h + al/source.h) # ALC and related routines -set(ALC_OBJS +set(ALC_SRCS alc/alc.cpp alc/alu.cpp - alc/alu.h alc/alconfig.cpp - alc/alconfig.h alc/context.cpp - alc/context.h alc/device.cpp - alc/device.h - alc/effects/base.h alc/effects/autowah.cpp alc/effects/chorus.cpp alc/effects/compressor.cpp @@ -955,28 +979,38 @@ set(ALC_OBJS alc/effects/reverb.cpp alc/effects/vmorpher.cpp alc/events.cpp + alc/panning.cpp) +set(ALC_HDRS + alc/alu.h + alc/alconfig.h + alc/context.hpp + alc/device.h + alc/effects/base.h alc/events.h alc/export_list.h - alc/inprogext.h - alc/panning.cpp) + alc/inprogext.h) +if(HAVE_CXXMODULES) + list(APPEND CORE_MODS alc/context.cppm) +endif() if(ALSOFT_EAX) - set(OPENAL_OBJS - ${OPENAL_OBJS} + list(APPEND OPENAL_SRCS al/eax.cpp al/eax/api.cpp - al/eax/api.h al/eax/call.cpp + al/eax/exception.cpp + al/eax/fx_slot_index.cpp + al/eax/fx_slots.cpp + al/eax/utils.cpp + ) + list(APPEND OPENAL_HDRS + al/eax/api.h al/eax/call.h al/eax/effect.h - al/eax/exception.cpp al/eax/exception.h - al/eax/fx_slot_index.cpp al/eax/fx_slot_index.h - al/eax/fx_slots.cpp al/eax/fx_slots.h al/eax/globals.h - al/eax/utils.cpp al/eax/utils.h al/eax/x_ram.h ) @@ -985,23 +1019,23 @@ endif() # Include SIMD mixers set(CPU_EXTS "Default") if(HAVE_SSE) - set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse.cpp) + list(APPEND CORE_SRCS core/mixer/mixer_sse.cpp) set(CPU_EXTS "${CPU_EXTS}, SSE") endif() if(HAVE_SSE2) - set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse2.cpp) + list(APPEND CORE_SRCS core/mixer/mixer_sse2.cpp) set(CPU_EXTS "${CPU_EXTS}, SSE2") endif() if(HAVE_SSE3) - set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse3.cpp) + list(APPEND CORE_SRCS core/mixer/mixer_sse3.cpp) set(CPU_EXTS "${CPU_EXTS}, SSE3") endif() if(HAVE_SSE4_1) - set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse41.cpp) + list(APPEND CORE_SRCS core/mixer/mixer_sse41.cpp) set(CPU_EXTS "${CPU_EXTS}, SSE4.1") endif() if(HAVE_NEON) - set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_neon.cpp) + list(APPEND CORE_SRCS core/mixer/mixer_neon.cpp) set(CPU_EXTS "${CPU_EXTS}, Neon") endif() @@ -1030,18 +1064,20 @@ if(WIN32 OR HAVE_DLFCN_H) else() set(IS_LINKED " (linked)") macro(ADD_BACKEND_LIBS _LIBS) - set(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS}) + list(APPEND EXTRA_LIBS ${_LIBS}) endmacro() endif() set(BACKENDS "") -set(ALC_OBJS ${ALC_OBJS} +list(APPEND ALC_SRCS alc/backends/base.cpp - alc/backends/base.h # Default backends, always available alc/backends/loopback.cpp - alc/backends/loopback.h alc/backends/null.cpp +) +list(APPEND ALC_HDRS + alc/backends/base.h + alc/backends/loopback.h alc/backends/null.h ) @@ -1053,9 +1089,10 @@ if(ALSOFT_BACKEND_PIPEWIRE AND PkgConfig_FOUND) if(PIPEWIRE_FOUND) set(HAVE_PIPEWIRE 1) set(BACKENDS "${BACKENDS} PipeWire${IS_LINKED},") - set(ALC_OBJS ${ALC_OBJS} alc/backends/pipewire.cpp alc/backends/pipewire.h) + list(APPEND ALC_SRCS alc/backends/pipewire.cpp) + list(APPEND ALC_HDRS alc/backends/pipewire.h) add_backend_libs(${PIPEWIRE_LIBRARIES}) - set(INC_PATHS ${INC_PATHS} ${PIPEWIRE_INCLUDE_DIRS}) + list(APPEND INC_PATHS ${PIPEWIRE_INCLUDE_DIRS}) endif() endif() if(ALSOFT_REQUIRE_PIPEWIRE AND NOT HAVE_PIPEWIRE) @@ -1070,9 +1107,10 @@ if(ALSOFT_BACKEND_PULSEAUDIO) if(PULSEAUDIO_FOUND) set(HAVE_PULSEAUDIO 1) set(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},") - set(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h) + list(APPEND ALC_SRCS alc/backends/pulseaudio.cpp) + list(APPEND ALC_HDRS alc/backends/pulseaudio.h) add_backend_libs(${PULSEAUDIO_LIBRARY}) - set(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIR}) + list(APPEND INC_PATHS ${PULSEAUDIO_INCLUDE_DIR}) endif() endif() if(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO) @@ -1088,9 +1126,10 @@ if(NOT WIN32) if(ALSA_FOUND) set(HAVE_ALSA 1) set(BACKENDS "${BACKENDS} ALSA${IS_LINKED},") - set(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h) + list(APPEND ALC_SRCS alc/backends/alsa.cpp) + list(APPEND ALC_HDRS alc/backends/alsa.h) add_backend_libs(${ALSA_LIBRARIES}) - set(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS}) + list(APPEND INC_PATHS ${ALSA_INCLUDE_DIRS}) endif() endif() @@ -1102,11 +1141,12 @@ if(NOT WIN32) if(OSS_FOUND) set(HAVE_OSS 1) set(BACKENDS "${BACKENDS} OSS,") - set(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h) + list(APPEND ALC_SRCS alc/backends/oss.cpp) + list(APPEND ALC_HDRS alc/backends/oss.h) if(OSS_LIBRARIES) - set(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS}) + list(APPEND EXTRA_LIBS ${OSS_LIBRARIES}) endif() - set(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS}) + list(APPEND INC_PATHS ${OSS_INCLUDE_DIRS}) endif() endif() @@ -1118,8 +1158,9 @@ if(NOT WIN32) if(AUDIOIO_FOUND) set(HAVE_SOLARIS 1) set(BACKENDS "${BACKENDS} Solaris,") - set(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h) - set(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS}) + list(APPEND ALC_SRCS alc/backends/solaris.cpp) + list(APPEND ALC_HDRS alc/backends/solaris.h) + list(APPEND INC_PATHS ${AUDIOIO_INCLUDE_DIRS}) endif() endif() @@ -1135,9 +1176,10 @@ if(NOT WIN32) if(SNDIO_FOUND) set(HAVE_SNDIO 1) set(BACKENDS "${BACKENDS} SndIO (linked),") - set(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.hpp) - set(EXTRA_LIBS ${SNDIO_LIBRARIES} ${EXTRA_LIBS}) - set(INC_PATHS ${INC_PATHS} ${SNDIO_INCLUDE_DIRS}) + list(APPEND ALC_SRCS alc/backends/sndio.cpp) + list(APPEND ALC_HDRS alc/backends/sndio.hpp) + list(APPEND EXTRA_LIBS ${SNDIO_LIBRARIES}) + list(APPEND INC_PATHS ${SNDIO_INCLUDE_DIRS}) endif() endif() endif() @@ -1164,10 +1206,10 @@ if(WIN32) if(HAVE_MMDEVICEAPI_H) set(HAVE_WASAPI 1) set(BACKENDS "${BACKENDS} WASAPI,") - set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h) - + list(APPEND ALC_SRCS alc/backends/wasapi.cpp) + list(APPEND ALC_HDRS alc/backends/wasapi.h) if(NOT ALSOFT_UWP) - set(EXTRA_LIBS avrt ${EXTRA_LIBS}) + list(APPEND EXTRA_LIBS avrt) endif() endif() endif() @@ -1186,10 +1228,10 @@ if(WIN32) if(HAVE_DSOUND_H OR DSOUND_INCLUDE_DIR) set(HAVE_DSOUND 1) set(BACKENDS "${BACKENDS} DirectSound,") - set(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h) - + list(APPEND ALC_SRCS alc/backends/dsound.cpp) + list(APPEND ALC_HDRS alc/backends/dsound.h) if(NOT HAVE_DSOUND_H) - set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIR}) + list(APPEND INC_PATHS ${DSOUND_INCLUDE_DIR}) endif() endif() endif() @@ -1200,12 +1242,13 @@ if(WIN32) if(ALSOFT_BACKEND_WINMM) set(HAVE_WINMM 1) set(BACKENDS "${BACKENDS} WinMM,") - set(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h) + list(APPEND ALC_SRCS alc/backends/winmm.cpp) + list(APPEND ALC_HDRS alc/backends/winmm.h) # There doesn't seem to be good way to search for winmm.lib for MSVC. # find_library doesn't find it without being told to look in a specific # place in the WindowsSDK, but it links anyway. If there ends up being # Windows targets without this, another means to detect it is needed. - set(EXTRA_LIBS winmm ${EXTRA_LIBS}) + list(APPEND EXTRA_LIBS winmm) endif() endif() endif() @@ -1227,9 +1270,10 @@ if(ALSOFT_BACKEND_JACK) if(JACK_FOUND) set(HAVE_JACK 1) set(BACKENDS "${BACKENDS} JACK${IS_LINKED},") - set(ALC_OBJS ${ALC_OBJS} alc/backends/jack.cpp alc/backends/jack.h) + list(APPEND ALC_SRCS alc/backends/jack.cpp) + list(APPEND ALC_HDRS alc/backends/jack.h) add_backend_libs(${JACK_LIBRARIES}) - set(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS}) + list(APPEND INC_PATHS ${JACK_INCLUDE_DIRS}) endif() endif() if(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK) @@ -1244,27 +1288,28 @@ if(ALSOFT_BACKEND_COREAUDIO) find_path(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit/AudioUnit.h) if(COREAUDIO_FRAMEWORK AND AUDIOUNIT_INCLUDE_DIR) set(HAVE_COREAUDIO 1) - set(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h) set(BACKENDS "${BACKENDS} CoreAudio,") + list(APPEND ALC_SRCS alc/backends/coreaudio.cpp) + list(APPEND ALC_HDRS alc/backends/coreaudio.h) + + # Some versions of OSX may need the AudioToolbox framework. Add it if + # it's found. + find_library(AUDIOTOOLBOX_LIBRARY NAMES AudioToolbox) + if(AUDIOTOOLBOX_LIBRARY) + list(APPEND EXTRA_LIBS "-Wl,-framework,AudioToolbox") + endif() - set(EXTRA_LIBS -Wl,-framework,CoreAudio ${EXTRA_LIBS}) if(CMAKE_SYSTEM_NAME MATCHES "^(iOS|tvOS|visionOS)$") find_library(COREFOUNDATION_FRAMEWORK NAMES CoreFoundation) if(COREFOUNDATION_FRAMEWORK) - set(EXTRA_LIBS -Wl,-framework,CoreFoundation ${EXTRA_LIBS}) + list(APPEND EXTRA_LIBS "-Wl,-framework,CoreFoundation") endif() else() - set(EXTRA_LIBS -Wl,-framework,AudioUnit,-framework,ApplicationServices ${EXTRA_LIBS}) + list(APPEND EXTRA_LIBS "-Wl,-framework,AudioUnit,-framework,ApplicationServices") endif() + list(APPEND EXTRA_LIBS "-Wl,-framework,CoreAudio") - # Some versions of OSX may need the AudioToolbox framework. Add it if - # it's found. - find_library(AUDIOTOOLBOX_LIBRARY NAMES AudioToolbox) - if(AUDIOTOOLBOX_LIBRARY) - set(EXTRA_LIBS -Wl,-framework,AudioToolbox ${EXTRA_LIBS}) - endif() - - set(INC_PATHS ${INC_PATHS} ${AUDIOUNIT_INCLUDE_DIR}) + list(APPEND INC_PATHS ${AUDIOUNIT_INCLUDE_DIR}) endif() endif() if(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO) @@ -1294,9 +1339,10 @@ if(ALSOFT_BACKEND_OBOE) if(OBOE_TARGET) set(HAVE_OBOE 1) - set(ALC_OBJS ${ALC_OBJS} alc/backends/oboe.cpp alc/backends/oboe.h) set(BACKENDS "${BACKENDS} Oboe,") - set(EXTRA_LIBS ${OBOE_TARGET} ${EXTRA_LIBS}) + list(APPEND ALC_SRCS alc/backends/oboe.cpp) + list(APPEND ALC_HDRS alc/backends/oboe.h) + list(APPEND EXTRA_LIBS ${OBOE_TARGET}) endif() endif() if(ALSOFT_REQUIRE_OBOE AND NOT HAVE_OBOE) @@ -1310,10 +1356,11 @@ if(ALSOFT_BACKEND_OPENSL) find_package(OpenSL) if(OPENSL_FOUND) set(HAVE_OPENSL 1) - set(ALC_OBJS ${ALC_OBJS} alc/backends/opensl.cpp alc/backends/opensl.h) set(BACKENDS "${BACKENDS} OpenSL${IS_LINKED},") + list(APPEND ALC_SRCS alc/backends/opensl.cpp) + list(APPEND ALC_HDRS alc/backends/opensl.h) add_backend_libs(${OPENSL_LIBRARIES}) - set(INC_PATHS ${INC_PATHS} ${OPENSL_INCLUDE_DIRS}) + list(APPEND INC_PATHS ${OPENSL_INCLUDE_DIRS}) endif() endif() if(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL) @@ -1328,9 +1375,10 @@ if(ALSOFT_BACKEND_PORTAUDIO) if(PORTAUDIO_FOUND) set(HAVE_PORTAUDIO 1) set(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},") - set(ALC_OBJS ${ALC_OBJS} alc/backends/portaudio.cpp alc/backends/portaudio.hpp) + list(APPEND ALC_SRCS alc/backends/portaudio.cpp) + list(APPEND ALC_HDRS alc/backends/portaudio.hpp) add_backend_libs(${PORTAUDIO_LIBRARIES}) - set(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS}) + list(APPEND INC_PATHS ${PORTAUDIO_INCLUDE_DIRS}) endif() endif() if(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO) @@ -1345,9 +1393,10 @@ option(ALSOFT_REQUIRE_SDL3 "Require SDL3 backend" OFF) if(ALSOFT_BACKEND_SDL3) if(SDL3_FOUND) set(HAVE_SDL3 1) - set(ALC_OBJS ${ALC_OBJS} alc/backends/sdl3.cpp alc/backends/sdl3.h) set(BACKENDS "${BACKENDS} SDL3,") - set(EXTRA_LIBS ${EXTRA_LIBS} SDL3::SDL3) + list(APPEND ALC_SRCS alc/backends/sdl3.cpp) + list(APPEND ALC_HDRS alc/backends/sdl3.h) + list(APPEND EXTRA_LIBS SDL3::SDL3) else() message(STATUS "Could NOT find SDL3") endif() @@ -1362,9 +1411,10 @@ if(ALSOFT_BACKEND_SDL2 AND NOT HAVE_SDL3) find_package(SDL2) if(SDL2_FOUND) set(HAVE_SDL2 1) - set(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h) set(BACKENDS "${BACKENDS} SDL2,") - set(EXTRA_LIBS ${EXTRA_LIBS} SDL2::SDL2) + list(APPEND ALC_SRCS alc/backends/sdl2.cpp) + list(APPEND ALC_HDRS alc/backends/sdl2.h) + list(APPEND EXTRA_LIBS SDL2::SDL2) else() message(STATUS "Could NOT find SDL2") endif() @@ -1377,8 +1427,9 @@ endif() option(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON) if(ALSOFT_BACKEND_WAVE) set(HAVE_WAVE 1) - set(ALC_OBJS ${ALC_OBJS} alc/backends/wave.cpp alc/backends/wave.h) set(BACKENDS "${BACKENDS} WaveFile,") + list(APPEND ALC_SRCS alc/backends/wave.cpp) + list(APPEND ALC_HDRS alc/backends/wave.h) endif() # This is always available @@ -1386,8 +1437,8 @@ set(BACKENDS "${BACKENDS} Null") # Get the known version info to create version.h +set(LIB_VERSION ${OpenAL_VERSION}) set(LIB_VERSION_NUM ${OpenAL_VERSION_MAJOR},${OpenAL_VERSION_MINOR},${OpenAL_VERSION_PATCH},0) - find_package(Git) if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git") set(GIT_DIR "${OpenAL_SOURCE_DIR}/.git") @@ -1405,7 +1456,7 @@ if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.g add_custom_command(OUTPUT "${OpenAL_BINARY_DIR}/version_witness.txt" BYPRODUCTS "${OpenAL_BINARY_DIR}/version.h" COMMAND ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} - -D LIB_VERSION=${OpenAL_VERSION} -D LIB_VERSION_NUM=${LIB_VERSION_NUM} + -D LIB_VERSION=${LIB_VERSION} -D LIB_VERSION_NUM=${LIB_VERSION_NUM} -D SRC=${OpenAL_SOURCE_DIR}/version.h.in -D DST=${OpenAL_BINARY_DIR}/version.h -P ${OpenAL_SOURCE_DIR}/version.cmake COMMAND ${CMAKE_COMMAND} -E touch "${OpenAL_BINARY_DIR}/version_witness.txt" @@ -1425,20 +1476,29 @@ else() endif() +set(HRTF_DATA_FILES ) +set(HRTF_DATA_TARGETS ) option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" ON) if(ALSOFT_EMBED_HRTF_DATA) macro(make_hrtf_header FILENAME VARNAME) - set(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}") - set(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.txt") + set(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}") + set(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.hpp") + set(witnessfile "${OpenAL_BINARY_DIR}/${VARNAME}_witness.txt") - add_custom_command(OUTPUT "${outfile}" + add_custom_command(OUTPUT "${witnessfile}" + BYPRODUCTS "${outfile}" COMMAND ${CMAKE_COMMAND} -D "INPUT_FILE=${infile}" -D "OUTPUT_FILE=${outfile}" - -P "${CMAKE_MODULE_PATH}/bin2h.script.cmake" + -D "VARNAME=${VARNAME}" -P "${CMAKE_MODULE_PATH}/bin2h.script.cmake" + COMMAND ${CMAKE_COMMAND} -E touch "${OpenAL_BINARY_DIR}/${VARNAME}_witness.txt" WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}" - DEPENDS "${infile}" "${CMAKE_MODULE_PATH}/bin2h.script.cmake" + MAIN_DEPENDENCY "${infile}" + DEPENDS "${CMAKE_MODULE_PATH}/bin2h.script.cmake" VERBATIM ) - set(ALC_OBJS ${ALC_OBJS} "${outfile}") + + add_custom_target(alsoft.${VARNAME}_data DEPENDS "${witnessfile}") + list(APPEND HRTF_DATA_FILES "${outfile}") + list(APPEND HRTF_DATA_TARGETS "alsoft.${VARNAME}_data") endmacro() make_hrtf_header("Default HRTF.mhr" "default_hrtf") @@ -1449,7 +1509,7 @@ if(ANDROID) set(CPP_DEFS ${CPP_DEFS} __BIONIC_NO_PAGE_SIZE_MACRO) check_linker_flag(C "-Wl,-z,max-page-size=16384" HAS_MAX_PAGE_SIZE_16384) if(HAS_MAX_PAGE_SIZE_16384) - set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,-z,max-page-size=16384") + list(APPEND LINKER_FLAGS "-Wl,-z,max-page-size=16384") endif() endif() @@ -1539,54 +1599,83 @@ configure_file( @ONLY) -set(MODULES_OBJS ) +set(PUBLIC_MODULES ) +set(MODULES_TARGET ) if(HAVE_CXXMODULES) - set(MODULES_OBJS modules/alc.cppm modules/al.cppm modules/alstd.cppm modules/efx.cppm + set(PUBLIC_MODULES modules/alc.cppm modules/al.cppm modules/alstd.cppm modules/efx.cppm modules/alext.cppm modules/openal.cppm) # For importing while building the examples and utilities (functions are # set to be imported from the shared library, or as free functions with # static library builds). - add_library(openal.modules OBJECT EXCLUDE_FROM_ALL) - target_sources(openal.modules PUBLIC FILE_SET CXX_MODULES FILES ${MODULES_OBJS}) - target_include_directories(openal.modules PRIVATE ${OpenAL_SOURCE_DIR}/include) - target_compile_definitions(openal.modules PRIVATE ${CPP_DEFS}) - target_compile_options(openal.modules PRIVATE ${C_FLAGS}) - set_target_properties(openal.modules PROPERTIES ${ALSOFT_STD_VERSION_PROPS} + # TODO: Expose a "pure" version of this target for projects that have + # OpenAL Soft as a sub-project in its own build? It would depend on the + # parent or builder setting properties globally for this to inherit the + # desired build settings, since modules need to build with the same + # settings as the sources they're imported into. + add_library(alsoft.api-modules OBJECT EXCLUDE_FROM_ALL) + target_sources(alsoft.api-modules PUBLIC FILE_SET CXX_MODULES FILES ${PUBLIC_MODULES}) + target_include_directories(alsoft.api-modules PRIVATE ${OpenAL_SOURCE_DIR}/include) + target_compile_definitions(alsoft.api-modules PRIVATE ${CPP_DEFS}) + target_compile_options(alsoft.api-modules PRIVATE ${C_FLAGS}) + target_link_libraries(alsoft.api-modules PRIVATE Threads::Threads) + set_target_properties(alsoft.api-modules PROPERTIES ${ALSOFT_STD_VERSION_PROPS} POSITION_INDEPENDENT_CODE TRUE) - set(MODULES_TARGET openal.modules) + add_library(alsoft::api-modules ALIAS alsoft.api-modules) + set(MODULES_TARGET alsoft::api-modules) # For importing while building the library (functions are set to be # exported from the shared library). - add_library(alsoft.modules OBJECT EXCLUDE_FROM_ALL) - target_sources(alsoft.modules PUBLIC FILE_SET CXX_MODULES FILES ${MODULES_OBJS}) - target_compile_definitions(alsoft.modules PRIVATE AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" - "AL_API=${EXPORT_DECL}" ${CPP_DEFS}) - target_compile_options(alsoft.modules PRIVATE ${C_FLAGS}) - set_target_properties(alsoft.modules PROPERTIES ${ALSOFT_STD_VERSION_PROPS} + add_library(alsoft.buildapi-modules OBJECT EXCLUDE_FROM_ALL) + target_sources(alsoft.buildapi-modules PUBLIC FILE_SET CXX_MODULES FILES ${PUBLIC_MODULES}) + target_compile_definitions(alsoft.buildapi-modules PRIVATE AL_ALEXT_PROTOTYPES + "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}" ${CPP_DEFS}) + target_compile_options(alsoft.buildapi-modules PRIVATE ${C_FLAGS}) + target_link_libraries(alsoft.buildapi-modules PRIVATE Threads::Threads) + set_target_properties(alsoft.buildapi-modules PROPERTIES ${ALSOFT_STD_VERSION_PROPS} POSITION_INDEPENDENT_CODE TRUE) -else() - set(MODULES_TARGET ) + add_library(alsoft::buildapi-modules ALIAS alsoft.buildapi-modules) endif() -add_library(alsoft.common STATIC EXCLUDE_FROM_ALL ${COMMON_OBJS}) -target_include_directories(alsoft.common PRIVATE ${OpenAL_SOURCE_DIR}/include +add_library(alsoft.common STATIC EXCLUDE_FROM_ALL) +if(CMAKE_VERSION GREATER_EQUAL 3.23) + target_sources(alsoft.common PRIVATE ${COMMON_SRCS} + PUBLIC FILE_SET HEADERS FILES ${COMMON_HDRS}) + if(HAVE_CXXMODULES) + target_sources(alsoft.common PUBLIC FILE_SET CXX_MODULES FILES ${COMMON_MODS}) + endif() +else() + target_sources(alsoft.common PRIVATE ${COMMON_SRCS} PUBLIC ${COMMON_HDRS}) +endif() +target_include_directories(alsoft.common PUBLIC ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common ${OpenAL_SOURCE_DIR}/gsl/include) -target_compile_definitions(alsoft.common PRIVATE ${CPP_DEFS}) -target_compile_options(alsoft.common PRIVATE ${C_FLAGS}) -target_link_libraries(alsoft.common PRIVATE fmt::fmt) +target_compile_definitions(alsoft.common PUBLIC ${CPP_DEFS}) +target_compile_options(alsoft.common PUBLIC ${C_FLAGS}) +target_link_libraries(alsoft.common PUBLIC Threads::Threads ${LINKER_FLAGS} fmt::fmt) set_target_properties(alsoft.common PROPERTIES ${ALSOFT_STD_VERSION_PROPS} POSITION_INDEPENDENT_CODE TRUE) -if(HAVE_CXXMODULES) - set(MODULES_OBJS ${MODULES_OBJS} alsoft-modules/gsl.cppm) - target_sources(alsoft.common PUBLIC FILE_SET CXX_MODULES FILES alsoft-modules/gsl.cppm) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND DEFINED CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.13") - # Targeting versions prior to macOS 10.13 requires specifying custom - # alignment-aware operators, which we do. This lets the compiler know they - # exist and it can use them. - target_compile_options(alsoft.common PUBLIC "-faligned-allocation") + check_cxx_compiler_flag("-faligned-allocation" HAVE_FALIGNED_ALLOCATION) + if(HAVE_FALIGNED_ALLOCATION) + # Targeting versions prior to macOS 10.13 requires specifying custom + # alignment-aware operators, which we do. This lets the compiler know + # they exist and it can use them. + target_compile_options(alsoft.common PUBLIC "-faligned-allocation") + endif() +endif() +add_library(alsoft::common ALIAS alsoft.common) + +if(HAVE_CXXMODULES) + add_library(alsoft.core-modules OBJECT EXCLUDE_FROM_ALL) + target_sources(alsoft.core-modules PUBLIC FILE_SET CXX_MODULES FILES ${CORE_MODS}) + target_include_directories(alsoft.core-modules PRIVATE + ${INC_PATHS} ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR} ${OpenAL_SOURCE_DIR}/include + ${OpenAL_SOURCE_DIR}/common + ) + target_link_libraries(alsoft.core-modules PRIVATE alsoft::common ${EXTRA_LIBS} ${MATH_LIB}) + set_target_properties(alsoft.core-modules PROPERTIES ${ALSOFT_STD_VERSION_PROPS} + POSITION_INDEPENDENT_CODE TRUE) endif() @@ -1595,29 +1684,49 @@ set(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal. set(NEED_ANALYZE_SOURCE_FILES "") -foreach(obj ${CORE_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${COMMON_OBJS} ${MODULES_OBJS}) - # CMake 3.20+ can use cmake_path(COMPARE ...), or CMake 3.24+ can use - # PATH_EQUAL. - if(NOT obj STREQUAL "${OpenAL_BINARY_DIR}/default_hrtf.txt") +foreach(obj ${OPENAL_SRCS} ${OPENAL_HDRS} ${ALC_SRCS} ${ALC_HDRS} ${CORE_SRCS} ${CORE_HDRS} + ${CORE_MODS} ${COMMON_SRCS} ${COMMON_HDRS} ${COMMON_MODS} ${PUBLIC_MODULES}) + if(IS_ABSOLUTE "${obj}") + list(APPEND NEED_ANALYZE_SOURCE_FILES "${obj}") + else() list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/${obj}") endif() endforeach() +set(TARGET_PUBLIC_HEADERS include/AL/al.h include/AL/alc.h include/AL/alext.h include/AL/efx.h + include/AL/efx-presets.h) + # Build main library if(LIBTYPE STREQUAL "STATIC") - if(TARGET openal.modules) - target_compile_definitions(openal.modules PUBLIC AL_LIBTYPE_STATIC) + if(TARGET alsoft.api-modules) + target_compile_definitions(alsoft.api-modules PUBLIC AL_LIBTYPE_STATIC) + endif() + + add_library(${IMPL_TARGET} STATIC) + if(CMAKE_VERSION GREATER_EQUAL 3.23) + target_sources(${IMPL_TARGET} + PRIVATE ${COMMON_SRCS} ${OPENAL_SRCS} ${ALC_SRCS} ${CORE_SRCS} + PRIVATE FILE_SET internal_headers TYPE HEADERS + FILES ${COMMON_HDRS} ${OPENAL_HDRS} ${ALC_HDRS} ${CORE_HDRS} + PUBLIC FILE_SET public_headers TYPE HEADERS + BASE_DIRS "${OpenAL_SOURCE_DIR}/include" FILES ${TARGET_PUBLIC_HEADERS} + ) + if(HAVE_CXXMODULES) + target_sources(${IMPL_TARGET} PRIVATE FILE_SET CXX_MODULES + FILES ${COMMON_MODS} ${CORE_MODS}) + endif() + else() + target_sources(${IMPL_TARGET} PRIVATE ${COMMON_SRCS} ${COMMON_HDRS} ${OPENAL_SRCS} + ${OPENAL_HDRS} ${ALC_SRCS} ${ALC_HDRS} ${CORE_SRCS} ${CORE_HDRS}) endif() - - add_library(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS}) target_compile_definitions(${IMPL_TARGET} PUBLIC AL_LIBTYPE_STATIC) target_include_directories(${IMPL_TARGET} PRIVATE ${OpenAL_SOURCE_DIR}/gsl/include) - target_link_libraries(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB} - $) + target_link_libraries(${IMPL_TARGET} PRIVATE Threads::Threads ${LINKER_FLAGS} ${EXTRA_LIBS} + ${MATH_LIB} $) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND DEFINED CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.13") - # The static library doesn't link with alsoft.common, so needs this + # The static library doesn't link with alsoft::common, so needs this # compile flag set for itself. target_compile_options(${IMPL_TARGET} PRIVATE "-faligned-allocation") endif() @@ -1634,39 +1743,47 @@ if(LIBTYPE STREQUAL "STATIC") else() set(RC_CONFIG resources/openal32.rc) if(WIN32 AND ALSOFT_BUILD_ROUTER) + set(ROUTER_MODULES_TARGET ) if(HAVE_CXXMODULES) add_library(alsoft.router-modules OBJECT EXCLUDE_FROM_ALL) target_sources(alsoft.router-modules PUBLIC FILE_SET CXX_MODULES FILES - alsoft-modules/router.cppm) + router/router.cppm) target_compile_definitions(alsoft.router-modules PRIVATE AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}" ${CPP_DEFS}) target_compile_options(alsoft.router-modules PRIVATE ${C_FLAGS}) - target_link_libraries(alsoft.router-modules PRIVATE fmt::fmt alsoft.modules) + target_link_libraries(alsoft.router-modules PRIVATE Threads::Threads fmt::fmt + PUBLIC alsoft::buildapi-modules) set_target_properties(alsoft.router-modules PROPERTIES ${ALSOFT_STD_VERSION_PROPS} POSITION_INDEPENDENT_CODE TRUE) - list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/alsoft-modules/router.cppm") + set(ROUTER_MODULES_TARGET alsoft.router-modules) + list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/router/router.cppm") endif() - add_library(OpenAL SHARED - resources/router.rc - router/router.cpp - router/router.h - router/alc.cpp - router/al.cpp - ) + add_library(OpenAL SHARED) + if(CMAKE_VERSION GREATER_EQUAL 3.23) + target_sources(OpenAL + PRIVATE resources/router.rc router/router.cpp router/alc.cpp router/al.cpp + PUBLIC FILE_SET public_headers TYPE HEADERS + BASE_DIRS "${OpenAL_SOURCE_DIR}/include" FILES ${TARGET_PUBLIC_HEADERS}) + if(NOT HAVE_CXXMODULES) + target_sources(OpenAL PRIVATE FILE_SET internal_headers TYPE HEADERS + FILES router/router.h) + endif() + else() + target_sources(OpenAL PRIVATE resources/router.rc router/router.cpp router/router.h + router/alc.cpp router/al.cpp) + endif() target_compile_definitions(OpenAL PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}" ${CPP_DEFS}) - target_compile_options(OpenAL PRIVATE ${C_FLAGS}) - target_link_libraries(OpenAL PRIVATE alsoft.common ${LINKER_FLAGS} fmt::fmt - $<$:alsoft.modules alsoft.router-modules>) + target_link_libraries(OpenAL PRIVATE alsoft::common ${ROUTER_MODULES_TARGET}) target_include_directories(OpenAL - PUBLIC - $ - $ - PRIVATE - ${OpenAL_SOURCE_DIR}/common - ${OpenAL_BINARY_DIR} + PUBLIC + $ + $ + PRIVATE + ${OpenAL_SOURCE_DIR}/common + ${OpenAL_BINARY_DIR} ) set_target_properties(OpenAL PROPERTIES ${ALSOFT_STD_VERSION_PROPS} PREFIX "" OUTPUT_NAME ${LIBNAME}) @@ -1680,22 +1797,40 @@ else() set(RC_CONFIG resources/soft_oal.rc) endif() - # !important: for osx framework public header works, the headers must be in - # the project - set(TARGET_PUBLIC_HEADERS include/AL/al.h include/AL/alc.h include/AL/alext.h include/AL/efx.h - include/AL/efx-presets.h) + add_library(${IMPL_TARGET} SHARED) + if(CMAKE_VERSION GREATER_EQUAL 3.23) + target_sources(${IMPL_TARGET} + PRIVATE ${OPENAL_SRCS} ${ALC_SRCS} ${CORE_SRCS} ${RC_CONFIG} + PRIVATE FILE_SET internal_headers TYPE HEADERS + FILES ${OPENAL_HDRS} ${ALC_HDRS} ${CORE_HDRS} + PUBLIC FILE_SET public_headers TYPE HEADERS + BASE_DIRS "${OpenAL_SOURCE_DIR}/include" FILES ${TARGET_PUBLIC_HEADERS}) + # FIXME: Why can't I do this without CMake complaining that the private + # alsoft.common and alsoft.fmt libs aren't in some export set? Yet + # adding alsoft.core-modules as another lib that has the modules works + # without error? + #if(HAVE_CXXMODULES) + # target_sources(${IMPL_TARGET} PRIVATE FILE_SET CXX_MODULES FILES ${CORE_MODS}) + #endif() + else() + target_sources(${IMPL_TARGET} PRIVATE ${OPENAL_SRCS} ${OPENAL_HDRS} ${ALC_SRCS} ${ALC_HDRS} + ${CORE_SRCS} ${CORE_HDRS} ${RC_CONFIG} ${TARGET_PUBLIC_HEADERS}) + endif() - add_library(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS} ${RC_CONFIG} - ${TARGET_PUBLIC_HEADERS}) if(WIN32) set_target_properties(${IMPL_TARGET} PROPERTIES PREFIX "") endif() - target_link_libraries(${IMPL_TARGET} PRIVATE alsoft.common ${LINKER_FLAGS} ${EXTRA_LIBS} - ${MATH_LIB} fmt::fmt) + target_link_libraries(${IMPL_TARGET} PRIVATE alsoft::common ${EXTRA_LIBS} ${MATH_LIB}) + # FIXME: Can't have the modules as part of ${IMPL_TARGET} directly for some + # reason, causing problems with the private alsoft.common and alsoft.fmt + # libs, so they're added through this target to work around the bug. + if(TARGET alsoft.core-modules) + target_link_libraries(${IMPL_TARGET} PRIVATE alsoft.core-modules) + endif() if(ALSOFT_UWP) find_package(cppwinrt CONFIG) - if (TARGET Microsoft::CppWinRT) + if(TARGET Microsoft::CppWinRT) target_link_libraries(${IMPL_TARGET} PRIVATE Microsoft::CppWinRT) else() set(ALSOFT_CPPWINRT_VERSION "2.0.230706.1" CACHE STRING "The soft-oal default cppwinrt version") @@ -1767,17 +1902,17 @@ else() endif() target_include_directories(${IMPL_TARGET} - PUBLIC - $ - INTERFACE - $ - $ - $ - PRIVATE - ${INC_PATHS} - ${OpenAL_BINARY_DIR} - ${OpenAL_SOURCE_DIR} - ${OpenAL_SOURCE_DIR}/common + PUBLIC + $ + INTERFACE + $ + $ + $ + PRIVATE + ${INC_PATHS} + ${OpenAL_BINARY_DIR} + ${OpenAL_SOURCE_DIR} + ${OpenAL_SOURCE_DIR}/common ) set_target_properties(${IMPL_TARGET} PROPERTIES ${ALSOFT_STD_VERSION_PROPS} @@ -1786,13 +1921,14 @@ set_target_properties(${IMPL_TARGET} PROPERTIES ${ALSOFT_STD_VERSION_PROPS} SOVERSION ${OpenAL_VERSION_MAJOR} ) target_compile_definitions(${IMPL_TARGET} - PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}" + PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}" ${CPP_DEFS}) target_compile_options(${IMPL_TARGET} PRIVATE ${C_FLAGS}) if(TARGET alsoft.build_version) add_dependencies(${IMPL_TARGET} alsoft.build_version) endif() +add_dependencies(${IMPL_TARGET} ${HRTF_DATA_TARGETS}) if(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC") find_program(SED_EXECUTABLE NAMES sed DOC "sed executable") @@ -1860,9 +1996,16 @@ add_library(OpenAL::OpenAL ALIAS OpenAL) if(ALSOFT_INSTALL) configure_package_config_file(OpenALConfig.cmake.in OpenALConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL) - install(TARGETS OpenAL EXPORT OpenAL - FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL) + if(CMAKE_VERSION GREATER_EQUAL 3.23) + install(TARGETS OpenAL EXPORT OpenAL FILE_SET public_headers + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL) + else() + install(TARGETS OpenAL EXPORT OpenAL + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL) + install(DIRECTORY include/AL TYPE INCLUDE) + endif() export(TARGETS OpenAL NAMESPACE OpenAL:: FILE OpenALTargets.cmake) @@ -1870,8 +2013,6 @@ if(ALSOFT_INSTALL) DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL NAMESPACE OpenAL:: FILE OpenALTargets.cmake) - install(DIRECTORY include/AL - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES "${OpenAL_BINARY_DIR}/openal.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") install(FILES "${OpenAL_BINARY_DIR}/OpenALConfig.cmake" @@ -1889,13 +2030,11 @@ if(ALSOFT_INSTALL_CONFIG) DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) message(STATUS "Installing sample configuration") endif() - if(ALSOFT_INSTALL_HRTF_DATA) install(DIRECTORY hrtf DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) message(STATUS "Installing HRTF data files") endif() - if(ALSOFT_INSTALL_AMBDEC_PRESETS) install(DIRECTORY presets DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) @@ -1907,69 +2046,44 @@ set(UNICODE_FLAG ) if(MINGW) set(UNICODE_FLAG ${UNICODE_FLAG} -municode) endif() -set(EXTRA_INSTALLS ) if(ALSOFT_UTILS) add_executable(openal-info utils/openal-info.c) target_include_directories(openal-info PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common) target_compile_options(openal-info PRIVATE ${C_FLAGS}) - target_link_libraries(openal-info PRIVATE ${LINKER_FLAGS} OpenAL ${UNICODE_FLAG}) + target_link_libraries(openal-info PRIVATE Threads::Threads ${LINKER_FLAGS} OpenAL + ${UNICODE_FLAG}) set_target_properties(openal-info PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/utils/openal-info.c") if(ALSOFT_INSTALL_UTILS) - set(EXTRA_INSTALLS ${EXTRA_INSTALLS} openal-info) + install(TARGETS openal-info) endif() if(SNDFILE_FOUND) add_executable(uhjdecoder utils/uhjdecoder.cpp) - target_compile_definitions(uhjdecoder PRIVATE ${CPP_DEFS}) - target_include_directories(uhjdecoder - PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common) - target_compile_options(uhjdecoder PRIVATE ${C_FLAGS}) - target_link_libraries(uhjdecoder PUBLIC alsoft.common - PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG} fmt::fmt) + target_link_libraries(uhjdecoder PRIVATE alsoft::common SndFile::SndFile ${UNICODE_FLAG}) set_target_properties(uhjdecoder PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/utils/uhjdecoder.cpp") add_executable(uhjencoder utils/uhjencoder.cpp) - target_compile_definitions(uhjencoder PRIVATE ${CPP_DEFS}) - target_include_directories(uhjencoder - PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common) - target_compile_options(uhjencoder PRIVATE ${C_FLAGS}) - target_link_libraries(uhjencoder PUBLIC alsoft.common - PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG} fmt::fmt) + target_link_libraries(uhjencoder PRIVATE alsoft::common SndFile::SndFile ${UNICODE_FLAG}) set_target_properties(uhjencoder PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/utils/uhjencoder.cpp") endif() if(MYSOFA_FOUND) - set(SOFA_SUPPORT_SRCS - utils/sofa-support.cpp + add_library(alsoft.sofa-support STATIC EXCLUDE_FROM_ALL utils/sofa-support.cpp utils/sofa-support.h) - add_library(alsoft.sofa-support STATIC EXCLUDE_FROM_ALL ${SOFA_SUPPORT_SRCS}) - target_compile_definitions(alsoft.sofa-support PRIVATE ${CPP_DEFS}) - target_include_directories(alsoft.sofa-support PUBLIC ${OpenAL_SOURCE_DIR}/common) - target_compile_options(alsoft.sofa-support PRIVATE ${C_FLAGS}) - target_link_libraries(alsoft.sofa-support PUBLIC alsoft.common MySOFA::MySOFA - PRIVATE ${LINKER_FLAGS} fmt::fmt) + target_include_directories(alsoft.sofa-support PUBLIC ${OpenAL_SOURCE_DIR}/utils) + target_link_libraries(alsoft.sofa-support PUBLIC alsoft::common MySOFA::MySOFA) set_target_properties(alsoft.sofa-support PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/utils/sofa-support.cpp" "${OpenAL_SOURCE_DIR}/utils/sofa-support.h") - set(MAKEMHR_SRCS - utils/makemhr/loaddef.cpp - utils/makemhr/loaddef.h - utils/makemhr/loadsofa.cpp - utils/makemhr/loadsofa.h - utils/makemhr/makemhr.cpp - utils/makemhr/makemhr.h) - add_executable(makemhr ${MAKEMHR_SRCS}) - target_compile_definitions(makemhr PRIVATE ${CPP_DEFS}) - target_include_directories(makemhr - PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/utils) - target_compile_options(makemhr PRIVATE ${C_FLAGS}) - target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} alsoft.sofa-support ${UNICODE_FLAG} - fmt::fmt) + add_executable(makemhr utils/makemhr/loaddef.cpp utils/makemhr/loaddef.h + utils/makemhr/loadsofa.cpp utils/makemhr/loadsofa.h + utils/makemhr/makemhr.cpp utils/makemhr/makemhr.h) + target_link_libraries(makemhr PRIVATE alsoft::common alsoft.sofa-support ${UNICODE_FLAG}) set_target_properties(makemhr PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/utils/makemhr/loaddef.cpp" "${OpenAL_SOURCE_DIR}/utils/makemhr/loaddef.h" @@ -1978,17 +2092,11 @@ if(ALSOFT_UTILS) "${OpenAL_SOURCE_DIR}/utils/makemhr/makemhr.cpp" "${OpenAL_SOURCE_DIR}/utils/makemhr/makemhr.h") if(ALSOFT_INSTALL_UTILS) - set(EXTRA_INSTALLS ${EXTRA_INSTALLS} makemhr) + install(TARGETS makemhr) endif() - set(SOFAINFO_SRCS utils/sofa-info.cpp) - add_executable(sofa-info ${SOFAINFO_SRCS}) - target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS}) - target_include_directories(sofa-info - PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/utils) - target_compile_options(sofa-info PRIVATE ${C_FLAGS}) - target_link_libraries(sofa-info PRIVATE alsoft.common ${LINKER_FLAGS} alsoft.sofa-support - ${UNICODE_FLAG} fmt::fmt) + add_executable(sofa-info utils/sofa-info.cpp) + target_link_libraries(sofa-info PRIVATE alsoft::common alsoft.sofa-support ${UNICODE_FLAG}) set_target_properties(sofa-info PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/utils/sofa-info.cpp") endif() @@ -2008,7 +2116,7 @@ if(ALSOFT_UTILS) message(STATUS "Building configuration program") if(ALSOFT_INSTALL_UTILS) - set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alsoft-config) + install(TARGETS alsoft-config) endif() endif() endif() @@ -2017,7 +2125,6 @@ endif() # Add a static library with common functions used by multiple example targets -# Axmol spec: don't add example common when ALSOFT_EXAMPLES disabled if(ALSOFT_EXAMPLES) add_library(alsoft.excommon STATIC EXCLUDE_FROM_ALL examples/common/alhelpers.c @@ -2026,11 +2133,9 @@ if(ALSOFT_EXAMPLES) target_compile_definitions(alsoft.excommon PUBLIC ${CPP_DEFS}) target_include_directories(alsoft.excommon PUBLIC ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common) target_compile_options(alsoft.excommon PUBLIC ${C_FLAGS}) - target_link_libraries(alsoft.excommon PUBLIC OpenAL PRIVATE ${RT_LIB}) + target_link_libraries(alsoft.excommon PUBLIC Threads::Threads OpenAL PRIVATE ${RT_LIB}) set_target_properties(alsoft.excommon PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) -endif() -if(ALSOFT_EXAMPLES) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/common/alhelpers.c" "${OpenAL_SOURCE_DIR}/examples/common/alhelpers.h") @@ -2046,19 +2151,19 @@ if(ALSOFT_EXAMPLES) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alrecord.c") add_executable(aldebug examples/aldebug.cpp) - target_link_libraries(aldebug PRIVATE ${LINKER_FLAGS} alsoft.common alsoft.excommon - ${UNICODE_FLAG} fmt::fmt ${MODULES_TARGET}) + target_link_libraries(aldebug PRIVATE alsoft::common alsoft.excommon ${UNICODE_FLAG} + ${MODULES_TARGET}) set_target_properties(aldebug PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/aldebug.cpp") add_executable(allafplay examples/allafplay.cpp) - target_link_libraries(allafplay PRIVATE ${LINKER_FLAGS} alsoft.common alsoft.excommon - ${UNICODE_FLAG} fmt::fmt ${MODULES_TARGET}) + target_link_libraries(allafplay PRIVATE alsoft::common alsoft.excommon ${UNICODE_FLAG} + ${MODULES_TARGET}) set_target_properties(allafplay PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/allafplay.cpp") if(ALSOFT_INSTALL_EXAMPLES) - set(EXTRA_INSTALLS ${EXTRA_INSTALLS} altonegen alrecord aldebug allafplay) + install(TARGETS altonegen alrecord aldebug allafplay) endif() message(STATUS "Building example programs") @@ -2101,26 +2206,24 @@ if(ALSOFT_EXAMPLES) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alhrtf.c") add_executable(alstreamcb examples/alstreamcb.cpp) - target_link_libraries(alstreamcb PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.common - alsoft.excommon ${UNICODE_FLAG} fmt::fmt ${MODULES_TARGET}) + target_link_libraries(alstreamcb PRIVATE SndFile::SndFile alsoft::common alsoft.excommon + ${UNICODE_FLAG} ${MODULES_TARGET}) set_target_properties(alstreamcb PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alstreamcb.cpp") add_executable(aldirect examples/aldirect.cpp) - target_link_libraries(aldirect PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.common - alsoft.excommon ${UNICODE_FLAG} fmt::fmt ${MODULES_TARGET}) + target_link_libraries(aldirect PRIVATE SndFile::SndFile alsoft::common alsoft.excommon + ${UNICODE_FLAG} ${MODULES_TARGET}) set_target_properties(aldirect PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/aldirect.cpp") add_executable(alconvolve examples/alconvolve.c) - target_link_libraries(alconvolve PRIVATE ${LINKER_FLAGS} alsoft.common SndFile::SndFile - alsoft.excommon ${UNICODE_FLAG}) + target_link_libraries(alconvolve PRIVATE SndFile::SndFile alsoft.excommon ${UNICODE_FLAG}) set_target_properties(alconvolve PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alconvolve.c") if(ALSOFT_INSTALL_EXAMPLES) - set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alplay alstream alreverb almultireverb allatency - alhrtf aldirect) + install(TARGETS alplay alstream alreverb almultireverb allatency alhrtf aldirect) endif() message(STATUS "Building SndFile example programs") @@ -2131,13 +2234,13 @@ if(ALSOFT_EXAMPLES) message(STATUS "Building SDL3 example programs") add_executable(alloopback examples/alloopback.c) - target_link_libraries(alloopback - PRIVATE ${LINKER_FLAGS} SDL3::SDL3 alsoft.excommon ${MATH_LIB}) + target_link_libraries(alloopback PRIVATE ${LINKER_FLAGS} SDL3::SDL3 alsoft.excommon + ${MATH_LIB}) set_target_properties(alloopback PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alloopback.c") if(ALSOFT_INSTALL_EXAMPLES) - set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alloopback) + install(TARGETS alloopback) endif() set(FFVER_OK FALSE) @@ -2167,14 +2270,13 @@ if(ALSOFT_EXAMPLES) if(FFVER_OK) add_executable(alffplay examples/alffplay.cpp) target_include_directories(alffplay PRIVATE ${FFMPEG_INCLUDE_DIRS}) - target_link_libraries(alffplay - PRIVATE ${LINKER_FLAGS} SDL3::SDL3 ${FFMPEG_LIBRARIES} alsoft.common - alsoft.excommon fmt::fmt ${MODULES_TARGET}) + target_link_libraries(alffplay PRIVATE SDL3::SDL3 ${FFMPEG_LIBRARIES} alsoft::common + alsoft.excommon ${MODULES_TARGET}) set_target_properties(alffplay PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alffplay.cpp") if(ALSOFT_INSTALL_EXAMPLES) - set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alffplay) + install(TARGETS alffplay) endif() message(STATUS "Building SDL3+FFmpeg example programs") endif() @@ -2186,16 +2288,11 @@ set(CLANG_TIDY_EXECUTABLE "clang-tidy") if(DEFINED ENV{CLANG_TIDY_EXECUTABLE}) set(CLANG_TIDY_EXECUTABLE $ENV{CLANG_TIDY_EXECUTABLE}) endif() -add_custom_target(clang-tidy-check ${CLANG_TIDY_EXECUTABLE} -format-style=file -p ${CMAKE_BINARY_DIR}/compile_commands.json ${NEED_ANALYZE_SOURCE_FILES} DEPENDS ${NEED_ANALYZE_SOURCE_FILES}) +add_custom_target(clang-tidy-check + ${CLANG_TIDY_EXECUTABLE} -format-style=file -p ${CMAKE_BINARY_DIR}/compile_commands.json + ${NEED_ANALYZE_SOURCE_FILES} ${HRTF_DATA_FILES} + DEPENDS ${NEED_ANALYZE_SOURCE_FILES} ${HRTF_DATA_TARGETS}) if(ALSOFT_TESTS) add_subdirectory(tests) endif() - -if(EXTRA_INSTALLS) - install(TARGETS ${EXTRA_INSTALLS} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() diff --git a/3rdparty/openal/ChangeLog b/3rdparty/openal/ChangeLog index 557e4db5a570..3b5d17c3a631 100644 --- a/3rdparty/openal/ChangeLog +++ b/3rdparty/openal/ChangeLog @@ -1,3 +1,35 @@ +openal-soft-1.25.2: + + Fixed the library version string for builds made without Git repo info. + + Fixed an STL hardening assertion in the reverb effect. + + Fixed a potential crash for builds made with older PipeWire headers. + + Fixed capturing mono from a stereo or greater WASAPI input device. + + Fixed building on macOS without std::format. + + Fixed height encoding for TSME output. + + Fixed the Super Stereo decoder's stereo separation with TSME output. + + Implemented 3D processing for the Distortion, Chorus, Flanger, Pitch + Shifter, and Frequency Shifter effects. + + Improved handling duplicate device names from PipeWire. + + Added support for 7.1.4 output autodetection with CoreAudio. + + Added capture support to the SDL3 backend. + + Added support for device added and removed events to the SDL3 backend. + + Removed use of "protected" visibility for exported symbols, now using the + normal "default" visibility. + + Actually changed the default Super Stereo width to 0.46. + openal-soft-1.25.1: Fixed the OpenSL and JACK backends. diff --git a/3rdparty/openal/al/auxeffectslot.cpp b/3rdparty/openal/al/auxeffectslot.cpp index c1bf31303014..77cfa5793721 100644 --- a/3rdparty/openal/al/auxeffectslot.cpp +++ b/3rdparty/openal/al/auxeffectslot.cpp @@ -23,8 +23,6 @@ #include "auxeffectslot.h" #include -#include -#include #include #include #include @@ -42,11 +40,9 @@ #include "AL/efx.h" #include "alc/alu.h" -#include "alc/context.h" #include "alc/device.h" #include "alc/effects/base.h" #include "alc/inprogext.h" -#include "alformat.hpp" #include "almalloc.h" #include "alnumeric.h" #include "atomic.h" @@ -54,11 +50,9 @@ #include "core/device.h" #include "core/except.h" #include "core/fpu_ctrl.h" -#include "core/logging.h" #include "direct_defs.h" #include "effect.h" #include "flexarray.h" -#include "gsl/gsl" #include "opthelpers.h" #if ALSOFT_EAX @@ -68,6 +62,18 @@ #include "eax/fx_slot_index.h" #endif +#if HAVE_CXXMODULES +import alc.context; +import format.types; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "alformattypes.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { using SubListAllocator = al::allocator>; @@ -269,9 +275,9 @@ auto EnsureEffectSlots(gsl::not_null const context, usize const ne -> bool try { auto count = std::accumulate(context->mEffectSlotList.cbegin(), - context->mEffectSlotList.cend(), 0_uz, + context->mEffectSlotList.cend(), 0_usize, [](usize const cur, const EffectSlotSubList &sublist) noexcept -> usize - { return cur + sublist.mFreeMask.popcount().c_val; }); + { return cur + sublist.mFreeMask.popcount(); }); while(needed > count) { @@ -341,7 +347,7 @@ void UpdateProps(gsl::not_null const slot, } -void alGenAuxiliaryEffectSlots(gsl::not_null const context, ALsizei const n, +void alGenAuxiliaryEffectSlots_(gsl::not_null const context, ALsizei const n, ALuint *const effectslots) noexcept try { if(n < 0) @@ -391,7 +397,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alDeleteAuxiliaryEffectSlots(gsl::not_null const context, ALsizei const n, +void alDeleteAuxiliaryEffectSlots_(gsl::not_null const context, ALsizei const n, ALuint const *const effectslots) noexcept try { if(n < 0) [[unlikely]] @@ -440,7 +446,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -auto alIsAuxiliaryEffectSlot(gsl::not_null const context, ALuint const effectslot) +auto alIsAuxiliaryEffectSlot_(gsl::not_null const context, ALuint const effectslot) noexcept -> ALboolean { const auto slotlock = std::lock_guard{context->mEffectSlotLock}; @@ -450,7 +456,7 @@ auto alIsAuxiliaryEffectSlot(gsl::not_null const context, ALuint c } -void alAuxiliaryEffectSloti(gsl::not_null const context, ALuint const effectslot, +void alAuxiliaryEffectSloti_(gsl::not_null const context, ALuint const effectslot, ALenum const param, ALint const value) noexcept try { const auto proplock = std::lock_guard{context->mPropLock}; @@ -607,7 +613,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alAuxiliaryEffectSlotiv(gsl::not_null context, ALuint effectslot, ALenum param, +void alAuxiliaryEffectSlotiv_(gsl::not_null context, ALuint effectslot, ALenum param, const ALint *values) noexcept try { switch(param) @@ -616,7 +622,7 @@ try { case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: case AL_EFFECTSLOT_TARGET_SOFT: case AL_BUFFER: - alAuxiliaryEffectSloti(context, effectslot, param, *values); + alAuxiliaryEffectSloti_(context, effectslot, param, *values); return; } @@ -632,7 +638,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alAuxiliaryEffectSlotf(gsl::not_null context, ALuint effectslot, ALenum param, +void alAuxiliaryEffectSlotf_(gsl::not_null context, ALuint effectslot, ALenum param, ALfloat value) noexcept try { const auto proplock = std::lock_guard{context->mPropLock}; @@ -661,13 +667,13 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alAuxiliaryEffectSlotfv(gsl::not_null context, ALuint effectslot, ALenum param, +void alAuxiliaryEffectSlotfv_(gsl::not_null context, ALuint effectslot, ALenum param, const ALfloat *values) noexcept try { switch(param) { case AL_EFFECTSLOT_GAIN: - alAuxiliaryEffectSlotf(context, effectslot, param, *values); + alAuxiliaryEffectSlotf_(context, effectslot, param, *values); return; } @@ -684,7 +690,7 @@ catch(std::exception &e) { } -void alGetAuxiliaryEffectSloti(gsl::not_null context, ALuint effectslot, +void alGetAuxiliaryEffectSloti_(gsl::not_null context, ALuint effectslot, ALenum param, ALint *value) noexcept try { const auto slotlock = std::lock_guard{context->mEffectSlotLock}; @@ -724,7 +730,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetAuxiliaryEffectSlotiv(gsl::not_null context, ALuint effectslot, +void alGetAuxiliaryEffectSlotiv_(gsl::not_null context, ALuint effectslot, ALenum param, ALint *values) noexcept try { switch(param) @@ -733,7 +739,7 @@ try { case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: case AL_EFFECTSLOT_TARGET_SOFT: case AL_BUFFER: - alGetAuxiliaryEffectSloti(context, effectslot, param, values); + alGetAuxiliaryEffectSloti_(context, effectslot, param, values); return; } @@ -749,7 +755,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetAuxiliaryEffectSlotf(gsl::not_null context, ALuint effectslot, +void alGetAuxiliaryEffectSlotf_(gsl::not_null context, ALuint effectslot, ALenum param, ALfloat *value) noexcept try { const auto slotlock = std::lock_guard{context->mEffectSlotLock}; @@ -769,13 +775,13 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetAuxiliaryEffectSlotfv(gsl::not_null context, ALuint effectslot, +void alGetAuxiliaryEffectSlotfv_(gsl::not_null context, ALuint effectslot, ALenum param, ALfloat *values) noexcept try { switch(param) { case AL_EFFECTSLOT_GAIN: - alGetAuxiliaryEffectSlotf(context, effectslot, param, values); + alGetAuxiliaryEffectSlotf_(context, effectslot, param, values); return; } @@ -794,18 +800,18 @@ catch(std::exception &e) { } // namespace -AL_API DECL_FUNC2(void, alGenAuxiliaryEffectSlots, ALsizei,n, ALuint*,effectslots) -AL_API DECL_FUNC2(void, alDeleteAuxiliaryEffectSlots, ALsizei,n, const ALuint*,effectslots) -AL_API DECL_FUNC1(ALboolean, alIsAuxiliaryEffectSlot, ALuint,effectslot) +DECL_FUNC(AL_API, void, alGenAuxiliaryEffectSlots, ALsizei,n, ALuint*,effectslots) +DECL_FUNC(AL_API, void, alDeleteAuxiliaryEffectSlots, ALsizei,n, const ALuint*,effectslots) +DECL_FUNC(AL_API, ALboolean, alIsAuxiliaryEffectSlot, ALuint,effectslot) -AL_API DECL_FUNC3(void, alAuxiliaryEffectSloti, ALuint,effectslot, ALenum,param, ALint,value) -AL_API DECL_FUNC3(void, alAuxiliaryEffectSlotiv, ALuint,effectslot, ALenum,param, const ALint*,values) -AL_API DECL_FUNC3(void, alAuxiliaryEffectSlotf, ALuint,effectslot, ALenum,param, ALfloat,value) -AL_API DECL_FUNC3(void, alAuxiliaryEffectSlotfv, ALuint,effectslot, ALenum,param, const ALfloat*,values) -AL_API DECL_FUNC3(void, alGetAuxiliaryEffectSloti, ALuint,effectslot, ALenum,param, ALint*,value) -AL_API DECL_FUNC3(void, alGetAuxiliaryEffectSlotiv, ALuint,effectslot, ALenum,param, ALint*,values) -AL_API DECL_FUNC3(void, alGetAuxiliaryEffectSlotf, ALuint,effectslot, ALenum,param, ALfloat*,value) -AL_API DECL_FUNC3(void, alGetAuxiliaryEffectSlotfv, ALuint,effectslot, ALenum,param, ALfloat*,values) +DECL_FUNC(AL_API, void, alAuxiliaryEffectSloti, ALuint,effectslot, ALenum,param, ALint,value) +DECL_FUNC(AL_API, void, alAuxiliaryEffectSlotiv, ALuint,effectslot, ALenum,param, const ALint*,values) +DECL_FUNC(AL_API, void, alAuxiliaryEffectSlotf, ALuint,effectslot, ALenum,param, ALfloat,value) +DECL_FUNC(AL_API, void, alAuxiliaryEffectSlotfv, ALuint,effectslot, ALenum,param, const ALfloat*,values) +DECL_FUNC(AL_API, void, alGetAuxiliaryEffectSloti, ALuint,effectslot, ALenum,param, ALint*,value) +DECL_FUNC(AL_API, void, alGetAuxiliaryEffectSlotiv, ALuint,effectslot, ALenum,param, ALint*,values) +DECL_FUNC(AL_API, void, alGetAuxiliaryEffectSlotf, ALuint,effectslot, ALenum,param, ALfloat*,value) +DECL_FUNC(AL_API, void, alGetAuxiliaryEffectSlotfv, ALuint,effectslot, ALenum,param, ALfloat*,values) al::EffectSlot::EffectSlot(gsl::not_null context) : mSlot{context->getEffectSlot()} @@ -1046,7 +1052,7 @@ void al::EffectSlot::eax4_fx_slot_ensure_unlocked() const eax_fail("Locked legacy slot."); } -ALenum al::EffectSlot::eax_get_efx_effect_type(const GUID& guid) +ALenum al::EffectSlot::eax_get_efx_effect_type(AL_GUID const& guid) { if(guid == EAX_NULL_GUID) return AL_EFFECT_NULL; @@ -1078,7 +1084,7 @@ ALenum al::EffectSlot::eax_get_efx_effect_type(const GUID& guid) eax_fail_unknown_effect_id(); } -const GUID& al::EffectSlot::eax_get_eax_default_effect_guid() const noexcept +auto al::EffectSlot::eax_get_eax_default_effect_guid() const noexcept -> AL_GUID const& { switch(mEaxFXSlotIndex) { @@ -1463,7 +1469,7 @@ auto eax_create_al_effect_slot(gsl::not_null const context) -> Eax ERR(EAX_PREFIX "Out of memory."); return nullptr; } - if(!EnsureEffectSlots(context, 1)) + if(!EnsureEffectSlots(context, 1u)) { ERR(EAX_PREFIX "Failed to ensure."); return nullptr; diff --git a/3rdparty/openal/al/auxeffectslot.h b/3rdparty/openal/al/auxeffectslot.h index 7e681fe24fc8..76fd7055ef93 100644 --- a/3rdparty/openal/al/auxeffectslot.h +++ b/3rdparty/openal/al/auxeffectslot.h @@ -7,14 +7,12 @@ #include #include #include -#include #include #include -#include #include "AL/al.h" -#include "alnumeric.h" +#include "altypes.hpp" #include "core/effects/base.h" #include "core/effectslot.h" #include "gsl/gsl" @@ -140,7 +138,7 @@ struct EffectSlot { }; struct Eax4GuidLoadEffectValidator { - void operator()(const GUID& guidLoadEffect) const + void operator()(AL_GUID const& guidLoadEffect) const { if (guidLoadEffect != EAX_NULL_GUID && guidLoadEffect != EAX_REVERB_EFFECT && @@ -296,8 +294,8 @@ struct EffectSlot { void eax4_fx_slot_ensure_unlocked() const; - [[nodiscard]] static auto eax_get_efx_effect_type(const GUID& guid) -> ALenum; - [[nodiscard]] auto eax_get_eax_default_effect_guid() const noexcept -> const GUID&; + [[nodiscard]] static auto eax_get_efx_effect_type(AL_GUID const& guid) -> ALenum; + [[nodiscard]] auto eax_get_eax_default_effect_guid() const noexcept -> AL_GUID const&; [[nodiscard]] auto eax_get_eax_default_lock() const noexcept -> eax_long; void eax4_fx_slot_set_defaults(EAX40FXSLOTPROPERTIES& props) const noexcept; diff --git a/3rdparty/openal/al/buffer.cpp b/3rdparty/openal/al/buffer.cpp index 4faff0fe9bdd..e76ef3cd1351 100644 --- a/3rdparty/openal/al/buffer.cpp +++ b/3rdparty/openal/al/buffer.cpp @@ -25,10 +25,7 @@ #include #include #include -#include #include -#include -#include #include #include #include @@ -47,19 +44,15 @@ #include "AL/al.h" #include "AL/alext.h" -#include "alc/context.h" #include "alc/device.h" #include "alc/inprogext.h" -#include "alformat.hpp" #include "almalloc.h" #include "alnumeric.h" #include "core/device.h" #include "core/except.h" -#include "core/logging.h" #include "core/resampler_limits.h" #include "core/voice.h" #include "direct_defs.h" -#include "gsl/gsl" #include "intrusive_ptr.h" #include "opthelpers.h" @@ -70,6 +63,17 @@ #include "eax/x_ram.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import format.types; +import logging; +import gsl; +#else +#include "alc/context.hpp" +#include "alformattypes.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif namespace { @@ -184,9 +188,9 @@ constexpr auto INVALID_MAP_FLAGS = ~gsl::narrow(AL_MAP_READ_BIT_ [[nodiscard]] auto EnsureBuffers(gsl::not_null const device, usize const needed) noexcept -> bool try { - auto count = std::accumulate(device->BufferList.cbegin(), device->BufferList.cend(), 0_uz, + auto count = std::accumulate(device->BufferList.cbegin(), device->BufferList.cend(), 0_usize, [](usize const cur, const BufferSubList &sublist) noexcept -> usize - { return cur + sublist.mFreeMask.popcount().c_val; }); + { return cur + sublist.mFreeMask.popcount(); }); while(needed > count) { @@ -211,7 +215,7 @@ auto AllocBuffer(gsl::not_null const device) noexcept -> gsl::not_n auto sublist = std::ranges::find_if(device->BufferList, [](BufferSubList const &slist) { return slist.mFreeMask != 0; }); auto lidx = gsl::narrow_cast(std::distance(device->BufferList.begin(), sublist)); - auto slidx = gsl::narrow_cast(sublist->mFreeMask.countr_zero().c_val); + auto slidx = sublist->mFreeMask.countr_zero().c_val; ASSUME(slidx < 64); auto const buffer = gsl::make_not_null(std::construct_at( @@ -350,7 +354,7 @@ void LoadData(gsl::not_null const context, gsl::not_null std::numeric_limits::max()/samplesPerBlock) context->throw_error(AL_OUT_OF_MEMORY, "Buffer size overflow, {} blocks x {} samples per block", blocks, samplesPerBlock); - if(blocks > std::numeric_limits::max()/bytesPerBlock) + if(blocks > usize::max()/bytesPerBlock) context->throw_error(AL_OUT_OF_MEMORY, "Buffer size overflow, {} frames x {} bytes per frame", blocks, bytesPerBlock); @@ -364,7 +368,7 @@ void LoadData(gsl::not_null const context, gsl::not_null(T &datavec) -> bool { @@ -566,7 +570,7 @@ void PrepareUserPtr(gsl::not_null const context [[maybe_unused]], if(blocks > std::numeric_limits::max()/samplesPerBlock) context->throw_error(AL_OUT_OF_MEMORY, "Buffer size overflow, {} blocks x {} samples per block", blocks, samplesPerBlock); - if(blocks > std::numeric_limits::max()/bytesPerBlock) + if(blocks > usize::max()/bytesPerBlock) context->throw_error(AL_OUT_OF_MEMORY, "Buffer size overflow, {} frames x {} bytes per frame", blocks, bytesPerBlock); @@ -734,7 +738,7 @@ auto DecomposeUserFormat(ALenum const format) noexcept -> std::optional const context, ALsizei const n, +void alGenBuffers_(gsl::not_null const context, ALsizei const n, ALuint *const buffers) noexcept try { if(n < 0) @@ -757,7 +761,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alDeleteBuffers(gsl::not_null const context, ALsizei const n, +void alDeleteBuffers_(gsl::not_null const context, ALsizei const n, const ALuint *const buffers) noexcept try { if(n < 0) @@ -790,7 +794,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -auto alIsBuffer(gsl::not_null const context, ALuint const buffer) noexcept +auto alIsBuffer_(gsl::not_null const context, ALuint const buffer) noexcept -> ALboolean { auto const device = al::get_not_null(context->mALDevice); @@ -801,7 +805,7 @@ auto alIsBuffer(gsl::not_null const context, ALuint const buffer) } -void alBufferStorageSOFT(gsl::not_null const context, ALuint const buffer, +void alBufferStorageSOFT_(gsl::not_null const context, ALuint const buffer, ALenum const format, void const *const data, ALsizei const size, ALsizei const freq, ALbitfieldSOFT const flags) noexcept try { @@ -835,13 +839,13 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alBufferData(gsl::not_null const context, ALuint const buffer, +void alBufferData_(gsl::not_null const context, ALuint const buffer, ALenum const format, void const *const data, ALsizei const size, ALsizei const freq) noexcept { - alBufferStorageSOFT(context, buffer, format, data, size, freq, 0); + alBufferStorageSOFT_(context, buffer, format, data, size, freq, 0); } -void alBufferDataStatic(gsl::not_null const context, ALuint const buffer, +void alBufferDataStatic_(gsl::not_null const context, ALuint const buffer, ALenum const format, void *const data, ALsizei const size, ALsizei const freq) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -867,7 +871,7 @@ catch(std::exception &e) { } -void alBufferCallbackSOFT(gsl::not_null const context, ALuint const buffer, +void alBufferCallbackSOFT_(gsl::not_null const context, ALuint const buffer, ALenum const format, ALsizei const freq, ALBUFFERCALLBACKTYPESOFT const callback, void *const userptr) noexcept try { @@ -893,7 +897,7 @@ catch(std::exception &e) { } -void alBufferSubDataSOFT(gsl::not_null const context, ALuint const buffer, +void alBufferSubDataSOFT_(gsl::not_null const context, ALuint const buffer, ALenum const format, void const *const data, ALsizei const offset, ALsizei const length) noexcept try { @@ -926,15 +930,15 @@ try { (albuf->mType == FmtMSADPCM) ? ((align-2u)/2u + 7u) * num_chans : (align * albuf->bytesFromFmt() * num_chans); - if(offset < 0 || length < 0 || gsl::narrow_cast(offset) > albuf->mOriginalSize - || gsl::narrow_cast(length) > albuf->mOriginalSize - gsl::narrow_cast(offset)) + if(offset < 0 || length < 0 || usize::from(offset) > albuf->mOriginalSize + || usize::from(length) > albuf->mOriginalSize - usize::from(offset)) context->throw_error(AL_INVALID_VALUE, "Invalid data sub-range {}+{} on buffer {}", offset, length, buffer); - if((gsl::narrow_cast(offset)%byte_align) != 0) + if((usize::from(offset)%byte_align) != 0) context->throw_error(AL_INVALID_VALUE, "Sub-range offset {} is not a multiple of frame size {} ({} unpack alignment)", offset, byte_align, align); - if((gsl::narrow_cast(length)%byte_align) != 0) + if((usize::from(length)%byte_align) != 0) context->throw_error(AL_INVALID_VALUE, "Sub-range length {} is not a multiple of frame size {} ({} unpack alignment)", length, byte_align, align); @@ -951,7 +955,7 @@ catch(std::exception &e) { } -auto alMapBufferSOFT(gsl::not_null const context, ALuint const buffer, +auto alMapBufferSOFT_(gsl::not_null const context, ALuint const buffer, ALsizei const offset, ALsizei const length, ALbitfieldSOFT const access) noexcept -> void* try { auto const device = al::get_not_null(context->mALDevice); @@ -980,12 +984,12 @@ try { if((unavailable&AL_MAP_PERSISTENT_BIT_SOFT)) context->throw_error(AL_INVALID_VALUE, "Mapping buffer {} persistently without persistent access", buffer); - if(offset < 0 || length <= 0 || gsl::narrow_cast(offset) >= albuf->mOriginalSize - || gsl::narrow_cast(length) > albuf->mOriginalSize - gsl::narrow_cast(offset)) + if(offset < 0 || length <= 0 || usize::from(offset) >= albuf->mOriginalSize + || usize::from(length) > albuf->mOriginalSize - usize::from(offset)) context->throw_error(AL_INVALID_VALUE, "Mapping invalid range {}+{} for buffer {}", offset, length, buffer); - auto *const retval = std::visit([ptroff=gsl::narrow_cast(offset)](auto &datavec) + auto *const retval = std::visit([ptroff=gsl::narrow(offset)](auto &datavec) { return &std::as_writable_bytes(datavec)[ptroff]; }, albuf->mData); albuf->mMappedAccess = access; albuf->mMappedOffset = offset; @@ -1000,7 +1004,7 @@ catch(std::exception &e) { return nullptr; } -void alUnmapBufferSOFT(gsl::not_null const context, ALuint const buffer) noexcept +void alUnmapBufferSOFT_(gsl::not_null const context, ALuint const buffer) noexcept try { auto const device = al::get_not_null(context->mALDevice); auto const buflock = std::lock_guard{device->BufferLock}; @@ -1019,7 +1023,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alFlushMappedBufferSOFT(gsl::not_null const context, ALuint const buffer, +void alFlushMappedBufferSOFT_(gsl::not_null const context, ALuint const buffer, ALsizei const offset, ALsizei const length) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1049,7 +1053,7 @@ catch(std::exception &e) { } -void alBufferf(gsl::not_null const context, ALuint const buffer, ALenum const param, +void alBufferf_(gsl::not_null const context, ALuint const buffer, ALenum const param, float const value [[maybe_unused]]) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1066,8 +1070,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alBuffer3f(gsl::not_null const context, ALuint const buffer, ALenum const param, - float const value1 [[maybe_unused]], float const value2 [[maybe_unused]], +void alBuffer3f_(gsl::not_null const context, ALuint const buffer, + ALenum const param, float const value1 [[maybe_unused]], float const value2 [[maybe_unused]], float const value3 [[maybe_unused]]) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1084,8 +1088,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alBufferfv(gsl::not_null const context, ALuint const buffer, ALenum const param, - float const *const values) noexcept +void alBufferfv_(gsl::not_null const context, ALuint const buffer, + ALenum const param, float const *const values) noexcept try { auto const device = al::get_not_null(context->mALDevice); auto const buflock [[maybe_unused]] = std::lock_guard{device->BufferLock}; @@ -1104,7 +1108,7 @@ catch(std::exception &e) { } -void alBufferi(gsl::not_null const context, ALuint const buffer, ALenum const param, +void alBufferi_(gsl::not_null const context, ALuint const buffer, ALenum const param, ALint const value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1173,8 +1177,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alBuffer3i(gsl::not_null const context, ALuint const buffer, ALenum const param, - ALint const value1 [[maybe_unused]], ALint const value2 [[maybe_unused]], +void alBuffer3i_(gsl::not_null const context, ALuint const buffer, + ALenum const param, ALint const value1 [[maybe_unused]], ALint const value2 [[maybe_unused]], ALint const value3 [[maybe_unused]]) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1191,8 +1195,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alBufferiv(gsl::not_null const context, ALuint const buffer, ALenum const param, - ALint const *const values) noexcept +void alBufferiv_(gsl::not_null const context, ALuint const buffer, + ALenum const param, ALint const *const values) noexcept try { if(!values) context->throw_error(AL_INVALID_VALUE, "NULL pointer"); @@ -1204,7 +1208,7 @@ try { case AL_AMBISONIC_LAYOUT_SOFT: case AL_AMBISONIC_SCALING_SOFT: case AL_UNPACK_AMBISONIC_ORDER_SOFT: - alBufferi(context, buffer, param, *values); + alBufferi_(context, buffer, param, *values); return; } @@ -1239,7 +1243,7 @@ catch(std::exception &e) { } -void alGetBufferf(gsl::not_null const context, ALuint const buffer, +void alGetBufferf_(gsl::not_null const context, ALuint const buffer, ALenum const param, float *const value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1266,7 +1270,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetBuffer3f(gsl::not_null const context, ALuint const buffer, +void alGetBuffer3f_(gsl::not_null const context, ALuint const buffer, ALenum const param, float *const value1, float *const value2, float *const value3) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1285,13 +1289,13 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetBufferfv(gsl::not_null const context, ALuint const buffer, +void alGetBufferfv_(gsl::not_null const context, ALuint const buffer, ALenum const param, float *const values) noexcept try { switch(param) { case AL_SEC_LENGTH_SOFT: - alGetBufferf(context, buffer, param, values); + alGetBufferf_(context, buffer, param, values); return; } @@ -1312,7 +1316,7 @@ catch(std::exception &e) { } -void alGetBufferi(gsl::not_null const context, ALuint const buffer, +void alGetBufferi_(gsl::not_null const context, ALuint const buffer, ALenum const param, ALint *const value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1385,7 +1389,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetBuffer3i(gsl::not_null const context, ALuint const buffer, +void alGetBuffer3i_(gsl::not_null const context, ALuint const buffer, ALenum const param, ALint *const value1, ALint *const value2, ALint *const value3) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1404,7 +1408,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetBufferiv(gsl::not_null const context, ALuint const buffer, +void alGetBufferiv_(gsl::not_null const context, ALuint const buffer, ALenum const param, ALint *const values) noexcept try { switch(param) @@ -1421,7 +1425,7 @@ try { case AL_AMBISONIC_LAYOUT_SOFT: case AL_AMBISONIC_SCALING_SOFT: case AL_UNPACK_AMBISONIC_ORDER_SOFT: - alGetBufferi(context, buffer, param, values); + alGetBufferi_(context, buffer, param, values); return; } @@ -1451,7 +1455,7 @@ catch(std::exception &e) { } -void alGetBufferPtrSOFT(gsl::not_null const context, ALuint const buffer, +void alGetBufferPtrSOFT_(gsl::not_null const context, ALuint const buffer, ALenum const param, void **const value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1481,7 +1485,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetBuffer3PtrSOFT(gsl::not_null const context, ALuint const buffer, +void alGetBuffer3PtrSOFT_(gsl::not_null const context, ALuint const buffer, ALenum const param, void **const value1, void **const value2, void **const value3) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -1500,14 +1504,14 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetBufferPtrvSOFT(gsl::not_null const context, ALuint const buffer, +void alGetBufferPtrvSOFT_(gsl::not_null const context, ALuint const buffer, ALenum const param, void **const values) noexcept try { switch(param) { case AL_BUFFER_CALLBACK_FUNCTION_SOFT: case AL_BUFFER_CALLBACK_USER_PARAM_SOFT: - alGetBufferPtrSOFT(context, buffer, param, values); + alGetBufferPtrSOFT_(context, buffer, param, values); return; } @@ -1529,7 +1533,7 @@ catch(std::exception &e) { #if ALSOFT_EAX -auto EAXSetBufferMode(gsl::not_null const context, ALsizei const n, +auto EAXSetBufferMode_(gsl::not_null const context, ALsizei const n, ALuint const *const buffers, ALint const value) noexcept -> ALboolean try { if(!eax_g_is_enabled) @@ -1602,7 +1606,7 @@ try { { if(!buffer->mEaxXRamIsHardware) { - if(std::numeric_limits::max() - buffer->mOriginalSize < total_needed) + if(usize::max() - buffer->mOriginalSize < total_needed) context->throw_error(AL_OUT_OF_MEMORY, "Size overflow ({} + {})", buffer->mOriginalSize, total_needed); @@ -1634,7 +1638,7 @@ catch(std::exception &e) { return AL_FALSE; } -auto EAXGetBufferMode(gsl::not_null const context, ALuint const buffer, +auto EAXGetBufferMode_(gsl::not_null const context, ALuint const buffer, ALint *const pReserved) noexcept -> ALenum try { if(!eax_g_is_enabled) @@ -1660,43 +1664,43 @@ catch(std::exception &e) { } // namespace -AL_API DECL_FUNC2(void, alGenBuffers, ALsizei,n, ALuint*,buffers) -AL_API DECL_FUNC2(void, alDeleteBuffers, ALsizei,n, const ALuint*,buffers) -AL_API DECL_FUNC1(ALboolean, alIsBuffer, ALuint,buffer) +DECL_FUNC(AL_API, void, alGenBuffers, ALsizei,n, ALuint*,buffers) +DECL_FUNC(AL_API, void, alDeleteBuffers, ALsizei,n, const ALuint*,buffers) +DECL_FUNC(AL_API, ALboolean, alIsBuffer, ALuint,buffer) -AL_API DECL_FUNC5(void, alBufferData, ALuint,buffer, ALenum,format, const ALvoid*,data, ALsizei,size, ALsizei,freq) -AL_API DECL_FUNCEXT6(void, alBufferStorage,SOFT, ALuint,buffer, ALenum,format, const ALvoid*,data, ALsizei,size, ALsizei,freq, ALbitfieldSOFT,flags) -FORCE_ALIGN DECL_FUNC5(void, alBufferDataStatic, ALuint,buffer, ALenum,format, ALvoid*,data, ALsizei,size, ALsizei,freq) -AL_API DECL_FUNCEXT5(void, alBufferCallback,SOFT, ALuint,buffer, ALenum,format, ALsizei,freq, ALBUFFERCALLBACKTYPESOFT,callback, ALvoid*,userptr) -AL_API DECL_FUNCEXT5(void, alBufferSubData,SOFT, ALuint,buffer, ALenum,format, const ALvoid*,data, ALsizei,offset, ALsizei,length) +DECL_FUNC(AL_API, void, alBufferData, ALuint,buffer, ALenum,format, const ALvoid*,data, ALsizei,size, ALsizei,freq) +DECL_FUNCEXT(AL_API, void, alBufferStorage,SOFT, ALuint,buffer, ALenum,format, const ALvoid*,data, ALsizei,size, ALsizei,freq, ALbitfieldSOFT,flags) +DECL_FUNC(FORCE_ALIGN, void, alBufferDataStatic, ALuint,buffer, ALenum,format, ALvoid*,data, ALsizei,size, ALsizei,freq) +DECL_FUNCEXT(AL_API, void, alBufferCallback,SOFT, ALuint,buffer, ALenum,format, ALsizei,freq, ALBUFFERCALLBACKTYPESOFT,callback, ALvoid*,userptr) +DECL_FUNCEXT(AL_API, void, alBufferSubData,SOFT, ALuint,buffer, ALenum,format, const ALvoid*,data, ALsizei,offset, ALsizei,length) -AL_API DECL_FUNCEXT4(void*, alMapBuffer,SOFT, ALuint,buffer, ALsizei,offset, ALsizei,length, ALbitfieldSOFT,access) -AL_API DECL_FUNCEXT1(void, alUnmapBuffer,SOFT, ALuint,buffer) -AL_API DECL_FUNCEXT3(void, alFlushMappedBuffer,SOFT, ALuint,buffer, ALsizei,offset, ALsizei,length) +DECL_FUNCEXT(AL_API, void*, alMapBuffer,SOFT, ALuint,buffer, ALsizei,offset, ALsizei,length, ALbitfieldSOFT,access) +DECL_FUNCEXT(AL_API, void, alUnmapBuffer,SOFT, ALuint,buffer) +DECL_FUNCEXT(AL_API, void, alFlushMappedBuffer,SOFT, ALuint,buffer, ALsizei,offset, ALsizei,length) -AL_API DECL_FUNC3(void, alBufferf, ALuint,buffer, ALenum,param, ALfloat,value) -AL_API DECL_FUNC5(void, alBuffer3f, ALuint,buffer, ALenum,param, ALfloat,value1, ALfloat,value2, ALfloat,value3) -AL_API DECL_FUNC3(void, alBufferfv, ALuint,buffer, ALenum,param, const ALfloat*,values) +DECL_FUNC(AL_API, void, alBufferf, ALuint,buffer, ALenum,param, ALfloat,value) +DECL_FUNC(AL_API, void, alBuffer3f, ALuint,buffer, ALenum,param, ALfloat,value1, ALfloat,value2, ALfloat,value3) +DECL_FUNC(AL_API, void, alBufferfv, ALuint,buffer, ALenum,param, const ALfloat*,values) -AL_API DECL_FUNC3(void, alBufferi, ALuint,buffer, ALenum,param, ALint,value) -AL_API DECL_FUNC5(void, alBuffer3i, ALuint,buffer, ALenum,param, ALint,value1, ALint,value2, ALint,value3) -AL_API DECL_FUNC3(void, alBufferiv, ALuint,buffer, ALenum,param, const ALint*,values) +DECL_FUNC(AL_API, void, alBufferi, ALuint,buffer, ALenum,param, ALint,value) +DECL_FUNC(AL_API, void, alBuffer3i, ALuint,buffer, ALenum,param, ALint,value1, ALint,value2, ALint,value3) +DECL_FUNC(AL_API, void, alBufferiv, ALuint,buffer, ALenum,param, const ALint*,values) -AL_API DECL_FUNC3(void, alGetBufferf, ALuint,buffer, ALenum,param, ALfloat*,value) -AL_API DECL_FUNC5(void, alGetBuffer3f, ALuint,buffer, ALenum,param, ALfloat*,value1, ALfloat*,value2, ALfloat*,value3) -AL_API DECL_FUNC3(void, alGetBufferfv, ALuint,buffer, ALenum,param, ALfloat*,values) +DECL_FUNC(AL_API, void, alGetBufferf, ALuint,buffer, ALenum,param, ALfloat*,value) +DECL_FUNC(AL_API, void, alGetBuffer3f, ALuint,buffer, ALenum,param, ALfloat*,value1, ALfloat*,value2, ALfloat*,value3) +DECL_FUNC(AL_API, void, alGetBufferfv, ALuint,buffer, ALenum,param, ALfloat*,values) -AL_API DECL_FUNC3(void, alGetBufferi, ALuint,buffer, ALenum,param, ALint*,value) -AL_API DECL_FUNC5(void, alGetBuffer3i, ALuint,buffer, ALenum,param, ALint*,value1, ALint*,value2, ALint*,value3) -AL_API DECL_FUNC3(void, alGetBufferiv, ALuint,buffer, ALenum,param, ALint*,values) +DECL_FUNC(AL_API, void, alGetBufferi, ALuint,buffer, ALenum,param, ALint*,value) +DECL_FUNC(AL_API, void, alGetBuffer3i, ALuint,buffer, ALenum,param, ALint*,value1, ALint*,value2, ALint*,value3) +DECL_FUNC(AL_API, void, alGetBufferiv, ALuint,buffer, ALenum,param, ALint*,values) -AL_API DECL_FUNCEXT3(void, alGetBufferPtr,SOFT, ALuint,buffer, ALenum,param, ALvoid**,value) -AL_API DECL_FUNCEXT5(void, alGetBuffer3Ptr,SOFT, ALuint,buffer, ALenum,param, ALvoid**,value1, ALvoid**,value2, ALvoid**,value3) -AL_API DECL_FUNCEXT3(void, alGetBufferPtrv,SOFT, ALuint,buffer, ALenum,param, ALvoid**,values) +DECL_FUNCEXT(AL_API, void, alGetBufferPtr,SOFT, ALuint,buffer, ALenum,param, ALvoid**,value) +DECL_FUNCEXT(AL_API, void, alGetBuffer3Ptr,SOFT, ALuint,buffer, ALenum,param, ALvoid**,value1, ALvoid**,value2, ALvoid**,value3) +DECL_FUNCEXT(AL_API, void, alGetBufferPtrv,SOFT, ALuint,buffer, ALenum,param, ALvoid**,values) #if ALSOFT_EAX -FORCE_ALIGN DECL_FUNC3(ALboolean, EAXSetBufferMode, ALsizei,n, const ALuint*,buffers, ALint,value) -FORCE_ALIGN DECL_FUNC2(ALenum, EAXGetBufferMode, ALuint,buffer, ALint*,pReserved) +DECL_FUNC(FORCE_ALIGN, ALboolean, EAXSetBufferMode, ALsizei,n, const ALuint*,buffers, ALint,value) +DECL_FUNC(FORCE_ALIGN, ALenum, EAXGetBufferMode, ALuint,buffer, ALint*,pReserved) #endif // ALSOFT_EAX diff --git a/3rdparty/openal/al/buffer.h b/3rdparty/openal/al/buffer.h index 3915a8977b3b..41eeb4a914a5 100644 --- a/3rdparty/openal/al/buffer.h +++ b/3rdparty/openal/al/buffer.h @@ -5,16 +5,14 @@ #include #include -#include #include -#include #include #include "AL/al.h" #include "alc/inprogext.h" #include "almalloc.h" -#include "alnumeric.h" +#include "altypes.hpp" #include "core/buffer_storage.h" #include "gsl/gsl" #include "intrusive_ptr.h" diff --git a/3rdparty/openal/al/debug.cpp b/3rdparty/openal/al/debug.cpp index 5c5927a485d1..8ba811ecae71 100644 --- a/3rdparty/openal/al/debug.cpp +++ b/3rdparty/openal/al/debug.cpp @@ -21,22 +21,30 @@ #include "AL/al.h" #include "AL/alext.h" -#include "alc/context.h" #include "alc/device.h" -#include "alformat.hpp" #include "alnumeric.h" #include "auxeffectslot.h" #include "buffer.h" #include "core/except.h" -#include "core/logging.h" #include "core/voice.h" #include "direct_defs.h" #include "effect.h" #include "filter.h" -#include "gsl/gsl" #include "opthelpers.h" #include "source.h" +#if HAVE_CXXMODULES +import alc.context; +import format.types; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "alformattypes.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { @@ -185,7 +193,7 @@ constexpr auto GetDebugSeverityName(DebugSeverity severity) noexcept -> std::str } -void alDebugMessageCallbackEXT(gsl::not_null context, ALDEBUGPROCEXT callback, +void alDebugMessageCallbackEXT_(gsl::not_null context, ALDEBUGPROCEXT callback, void *userParam) noexcept { auto debuglock = std::lock_guard{context->mDebugCbLock}; @@ -194,7 +202,7 @@ void alDebugMessageCallbackEXT(gsl::not_null context, ALDEBUGPROCE } -void alDebugMessageInsertEXT(gsl::not_null context, ALenum source, ALenum type, +void alDebugMessageInsertEXT_(gsl::not_null context, ALenum source, ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message) noexcept try { if(!context->mContextFlags.test(ContextFlags::DebugBit)) @@ -204,7 +212,7 @@ try { context->throw_error(AL_INVALID_VALUE, "Null message pointer"); const auto msgview = (length < 0) ? std::string_view{message} - : std::string_view{message, gsl::narrow_cast(length)}; + : std::string_view{message, gsl::narrow(length)}; if(msgview.size() >= MaxDebugMessageLength) context->throw_error(AL_INVALID_VALUE, "Debug message too long ({} >= {})", msgview.size(), MaxDebugMessageLength); @@ -234,7 +242,7 @@ catch(std::exception &e) { } -void alDebugMessageControlEXT(gsl::not_null context, ALenum source, ALenum type, +void alDebugMessageControlEXT_(gsl::not_null context, ALenum source, ALenum type, ALenum severity, ALsizei count, const ALuint *ids, ALboolean enable) noexcept try { if(count > 0) @@ -336,7 +344,7 @@ catch(std::exception &e) { } -void alPushDebugGroupEXT(gsl::not_null context, ALenum source, ALuint id, +void alPushDebugGroupEXT_(gsl::not_null context, ALenum source, ALuint id, ALsizei length, const ALchar *message) noexcept try { if(length < 0) @@ -363,7 +371,7 @@ try { context->throw_error(AL_STACK_OVERFLOW_EXT, "Pushing too many debug groups"); context->mDebugGroups.emplace_back(*dsource, id, - std::string_view{message, gsl::narrow_cast(length)}); + std::string_view{message, gsl::narrow(length)}); auto &oldback = *(context->mDebugGroups.end()-2); auto &newback = context->mDebugGroups.back(); @@ -380,7 +388,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alPopDebugGroupEXT(gsl::not_null context) noexcept +void alPopDebugGroupEXT_(gsl::not_null context) noexcept try { auto debuglock = std::unique_lock{context->mDebugCbLock}; if(context->mDebugGroups.size() <= 1) @@ -403,9 +411,9 @@ catch(std::exception &e) { } -auto alGetDebugMessageLogEXT(gsl::not_null context, ALuint count, ALsizei logBufSize, - ALenum *sources, ALenum *types, ALuint *ids, ALenum *severities, ALsizei *lengths, - ALchar *logBuf) noexcept -> ALuint +auto alGetDebugMessageLogEXT_(gsl::not_null context, ALuint count, + ALsizei logBufSize, ALenum *sources, ALenum *types, ALuint *ids, ALenum *severities, + ALsizei *lengths, ALchar *logBuf) noexcept -> ALuint try { if(logBuf && logBufSize < 0) context->throw_error(AL_INVALID_VALUE, "Negative debug log buffer size"); @@ -495,14 +503,14 @@ catch(std::exception &e) { } -void alObjectLabelEXT(gsl::not_null context, ALenum identifier, ALuint name, +void alObjectLabelEXT_(gsl::not_null context, ALenum identifier, ALuint name, ALsizei length, const ALchar *label) noexcept try { if(!label && length != 0) context->throw_error(AL_INVALID_VALUE, "Null label pointer"); auto objname = (length < 0) ? std::string_view{label} - : std::string_view{label, gsl::narrow_cast(length)}; + : std::string_view{label, gsl::narrow(length)}; if(objname.size() >= MaxObjectLabelLength) context->throw_error(AL_INVALID_VALUE, "Object label length too long ({} >= {})", objname.size(), MaxObjectLabelLength); @@ -525,7 +533,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetObjectLabelEXT(gsl::not_null context, ALenum identifier, ALuint name, +void alGetObjectLabelEXT_(gsl::not_null context, ALenum identifier, ALuint name, ALsizei bufSize, ALsizei *length, ALchar *label) noexcept try { if(bufSize < 0) @@ -654,16 +662,16 @@ void al::Context::sendDebugMessage(std::unique_lock &debuglock, Debu } -FORCE_ALIGN DECL_FUNCEXT2(void, alDebugMessageCallback,EXT, ALDEBUGPROCEXT,callback, void*,userParam) +DECL_FUNCEXT(FORCE_ALIGN, void, alDebugMessageCallback,EXT, ALDEBUGPROCEXT,callback, void*,userParam) -FORCE_ALIGN DECL_FUNCEXT6(void, alDebugMessageInsert,EXT, ALenum,source, ALenum,type, ALuint,id, ALenum,severity, ALsizei,length, const ALchar*,message) +DECL_FUNCEXT(FORCE_ALIGN, void, alDebugMessageInsert,EXT, ALenum,source, ALenum,type, ALuint,id, ALenum,severity, ALsizei,length, const ALchar*,message) -FORCE_ALIGN DECL_FUNCEXT6(void, alDebugMessageControl,EXT, ALenum,source, ALenum,type, ALenum,severity, ALsizei,count, const ALuint*,ids, ALboolean,enable) +DECL_FUNCEXT(FORCE_ALIGN, void, alDebugMessageControl,EXT, ALenum,source, ALenum,type, ALenum,severity, ALsizei,count, const ALuint*,ids, ALboolean,enable) -FORCE_ALIGN DECL_FUNCEXT4(void, alPushDebugGroup,EXT, ALenum,source, ALuint,id, ALsizei,length, const ALchar*,message) -FORCE_ALIGN DECL_FUNCEXT(void, alPopDebugGroup,EXT) +DECL_FUNCEXT(FORCE_ALIGN, void, alPushDebugGroup,EXT, ALenum,source, ALuint,id, ALsizei,length, const ALchar*,message) +DECL_FUNCEXT(FORCE_ALIGN, void, alPopDebugGroup,EXT) -FORCE_ALIGN DECL_FUNCEXT8(ALuint, alGetDebugMessageLog,EXT, ALuint,count, ALsizei,logBufSize, ALenum*,sources, ALenum*,types, ALuint*,ids, ALenum*,severities, ALsizei*,lengths, ALchar*,logBuf) +DECL_FUNCEXT(FORCE_ALIGN, ALuint, alGetDebugMessageLog,EXT, ALuint,count, ALsizei,logBufSize, ALenum*,sources, ALenum*,types, ALuint*,ids, ALenum*,severities, ALsizei*,lengths, ALchar*,logBuf) -FORCE_ALIGN DECL_FUNCEXT4(void, alObjectLabel,EXT, ALenum,identifier, ALuint,name, ALsizei,length, const ALchar*,label) -FORCE_ALIGN DECL_FUNCEXT5(void, alGetObjectLabel,EXT, ALenum,identifier, ALuint,name, ALsizei,bufSize, ALsizei*,length, ALchar*,label) +DECL_FUNCEXT(FORCE_ALIGN, void, alObjectLabel,EXT, ALenum,identifier, ALuint,name, ALsizei,length, const ALchar*,label) +DECL_FUNCEXT(FORCE_ALIGN, void, alGetObjectLabel,EXT, ALenum,identifier, ALuint,name, ALsizei,bufSize, ALsizei*,length, ALchar*,label) diff --git a/3rdparty/openal/al/debug.h b/3rdparty/openal/al/debug.h index b4b438f5666d..c49848822ccb 100644 --- a/3rdparty/openal/al/debug.h +++ b/3rdparty/openal/al/debug.h @@ -7,7 +7,7 @@ #include "AL/al.h" -#include "alnumeric.h" +#include "altypes.hpp" #include "opthelpers.h" diff --git a/3rdparty/openal/al/direct_defs.h b/3rdparty/openal/al/direct_defs.h index 76f4fe7dd591..94a866345ceb 100644 --- a/3rdparty/openal/al/direct_defs.h +++ b/3rdparty/openal/al/direct_defs.h @@ -1,220 +1,245 @@ #ifndef AL_DIRECT_DEFS_H #define AL_DIRECT_DEFS_H -#include "alc/context.h" -#include "gsl/gsl" +#include "opthelpers.h" -namespace al { - -inline auto verify_context(ALCcontext *context) -> gsl::not_null -{ - /* TODO: A debug/non-optimized build should essentially do - * al::get_not_null(VerifyContext(context)) to ensure the ALCcontext handle - * is valid, not just non-null. - */ - /* NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast) */ - return gsl::make_not_null(static_cast(context)); -} - -} - namespace detail_ { template -constexpr T DefaultVal() noexcept { return T{}; } - -template<> -constexpr void DefaultVal() noexcept { } +constexpr auto DefaultVal() noexcept -> T +{ + if constexpr(std::same_as) + return; + else + return T{}; +} } // namespace detail_ -#define DECL_FUNC(R, Name) \ -auto AL_APIENTRY Name() noexcept -> R \ -{ \ - auto const context = GetContextRef(); \ - if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name(gsl::make_not_null(context.get())); \ -} \ -FORCE_ALIGN auto AL_APIENTRY Name##Direct(ALCcontext *context) noexcept -> R \ -{ \ - return Name(al::verify_context(context)); \ -} +#if defined(__linux__) && !defined(AL_LIBTYPE_STATIC) && HAS_ATTRIBUTE(gnu::alias) +#define DefineFuncAlias(Name) extern "C" DECL_HIDDEN [[gnu::alias(#Name)]] decltype(Name) Name##_; +#else +#define DefineFuncAlias(Name) +#endif -#define DECL_FUNC1(R, Name, T1,n1) \ -auto AL_APIENTRY Name(T1 n1) noexcept -> R \ +#define DECL_FUNC1(ATTR, R, Name, T1,n1) \ +ATTR auto AL_APIENTRY Name(T1 n1) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name(gsl::make_not_null(context.get()), n1); \ + return Name##_(gsl::make_not_null(context.get()), n1); \ } \ +DefineFuncAlias(Name) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct(ALCcontext *context, T1 n1) noexcept\ -> R \ { \ - return Name(al::verify_context(context), n1); \ -} + return Name##_(al::verify_context(context), n1); \ +} \ +DefineFuncAlias(Name##Direct) -#define DECL_FUNC2(R, Name, T1,n1, T2,n2) \ -auto AL_APIENTRY Name(T1 n1, T2 n2) noexcept -> R \ +#define DECL_FUNC2(ATTR, R, Name, T1,n1, T2,n2) \ +ATTR auto AL_APIENTRY Name(T1 n1, T2 n2) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name(gsl::make_not_null(context.get()), n1, n2); \ + return Name##_(gsl::make_not_null(context.get()), n1, n2); \ } \ +DefineFuncAlias(Name) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct(ALCcontext *context, T1 n1, T2 n2) \ noexcept -> R \ { \ - return Name(al::verify_context(context), n1, n2); \ -} + return Name##_(al::verify_context(context), n1, n2); \ +} \ +DefineFuncAlias(Name##Direct) -#define DECL_FUNC3(R, Name, T1,n1, T2,n2, T3,n3) \ -auto AL_APIENTRY Name(T1 n1, T2 n2, T3 n3) noexcept -> R \ +#define DECL_FUNC3(ATTR, R, Name, T1,n1, T2,n2, T3,n3) \ +ATTR auto AL_APIENTRY Name(T1 n1, T2 n2, T3 n3) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name(gsl::make_not_null(context.get()), n1, n2, n3); \ + return Name##_(gsl::make_not_null(context.get()), n1, n2, n3); \ } \ +DefineFuncAlias(Name) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct(ALCcontext *context, T1 n1, T2 n2, \ T3 n3) noexcept -> R \ { \ - return Name(al::verify_context(context), n1, n2, n3); \ -} + return Name##_(al::verify_context(context), n1, n2, n3); \ +} \ +DefineFuncAlias(Name##Direct) -#define DECL_FUNC4(R, Name, T1,n1, T2,n2, T3,n3, T4,n4) \ -auto AL_APIENTRY Name(T1 n1, T2 n2, T3 n3, T4 n4) noexcept -> R \ +#define DECL_FUNC4(ATTR, R, Name, T1,n1, T2,n2, T3,n3, T4,n4) \ +ATTR auto AL_APIENTRY Name(T1 n1, T2 n2, T3 n3, T4 n4) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name(gsl::make_not_null(context.get()), n1, n2, n3, n4); \ + return Name##_(gsl::make_not_null(context.get()), n1, n2, n3, n4); \ } \ +DefineFuncAlias(Name) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct(ALCcontext *context, T1 n1, T2 n2, \ T3 n3, T4 n4) noexcept -> R \ { \ - return Name(al::verify_context(context), n1, n2, n3, n4); \ -} + return Name##_(al::verify_context(context), n1, n2, n3, n4); \ +} \ +DefineFuncAlias(Name##Direct) -#define DECL_FUNC5(R, Name, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5) \ -auto AL_APIENTRY Name(T1 n1, T2 n2, T3 n3, T4 n4, T5 n5) noexcept -> R \ +#define DECL_FUNC5(ATTR, R, Name, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5) \ +ATTR auto AL_APIENTRY Name(T1 n1, T2 n2, T3 n3, T4 n4, T5 n5) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name(gsl::make_not_null(context.get()), n1, n2, n3, n4, n5); \ + return Name##_(gsl::make_not_null(context.get()), n1, n2, n3, n4, n5); \ } \ +DefineFuncAlias(Name) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct(ALCcontext *context, T1 n1, T2 n2, \ T3 n3, T4 n4, T5 n5) noexcept -> R \ { \ - return Name(al::verify_context(context), n1, n2, n3, n4, n5); \ -} + return Name##_(al::verify_context(context), n1, n2, n3, n4, n5); \ +} \ +DefineFuncAlias(Name##Direct) +#define DECL_FUNC_SELECTOR(ATTR, R, Name, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5, NAME, ...) NAME +#define DECL_PASS(...) __VA_ARGS__ +#define DECL_FUNC(...) DECL_PASS(DECL_PASS(DECL_FUNC_SELECTOR)(__VA_ARGS__, \ + DECL_FUNC5, Misdefined, DECL_FUNC4, Misdefined, DECL_FUNC3, Misdefined, \ + DECL_FUNC2, Misdefined, DECL_FUNC1, Misdefined, DECL_FUNC0)(__VA_ARGS__)) -#define DECL_FUNCEXT(R, Name,Ext) \ -auto AL_APIENTRY Name##Ext() noexcept -> R \ +#define DECL_FUNCEXT0(ATTR, R, Name,Ext) \ +ATTR auto AL_APIENTRY Name##Ext() noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name##Ext(gsl::make_not_null(context.get())); \ + return Name##Ext##_(gsl::make_not_null(context.get())); \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context) noexcept \ -> R \ { \ - return Name##Ext(al::verify_context(context)); \ -} + return Name##Ext##_(al::verify_context(context)); \ +} \ +DefineFuncAlias(Name##Direct##Ext) -#define DECL_FUNCEXT1(R, Name,Ext, T1,n1) \ -auto AL_APIENTRY Name##Ext(T1 n1) noexcept -> R \ +#define DECL_FUNCEXT1(ATTR, R, Name,Ext, T1,n1) \ +ATTR auto AL_APIENTRY Name##Ext(T1 n1) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name##Ext(gsl::make_not_null(context.get()), n1); \ + return Name##Ext##_(gsl::make_not_null(context.get()), n1); \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, T1 n1) \ noexcept -> R \ { \ - return Name##Ext(al::verify_context(context), n1); \ -} + return Name##Ext##_(al::verify_context(context), n1); \ +} \ +DefineFuncAlias(Name##Direct##Ext) -#define DECL_FUNCEXT2(R, Name,Ext, T1,n1, T2,n2) \ -auto AL_APIENTRY Name##Ext(T1 n1, T2 n2) noexcept -> R \ +#define DECL_FUNCEXT2(ATTR, R, Name,Ext, T1,n1, T2,n2) \ +ATTR auto AL_APIENTRY Name##Ext(T1 n1, T2 n2) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name##Ext(gsl::make_not_null(context.get()), n1, n2); \ + return Name##Ext##_(gsl::make_not_null(context.get()), n1, n2); \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, T1 n1, \ T2 n2) noexcept -> R \ { \ - return Name##Ext(al::verify_context(context), n1, n2); \ -} + return Name##Ext##_(al::verify_context(context), n1, n2); \ +} \ +DefineFuncAlias(Name##Direct##Ext) -#define DECL_FUNCEXT3(R, Name,Ext, T1,n1, T2,n2, T3,n3) \ -auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3) noexcept -> R \ +#define DECL_FUNCEXT3(ATTR, R, Name,Ext, T1,n1, T2,n2, T3,n3) \ +ATTR auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name##Ext(gsl::make_not_null(context.get()), n1, n2, n3); \ + return Name##Ext##_(gsl::make_not_null(context.get()), n1, n2, n3); \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, T1 n1, \ T2 n2, T3 n3) noexcept -> R \ { \ - return Name##Ext(al::verify_context(context), n1, n2, n3); \ -} + return Name##Ext##_(al::verify_context(context), n1, n2, n3); \ +} \ +DefineFuncAlias(Name##Direct##Ext) -#define DECL_FUNCEXT4(R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4) \ -auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3, T4 n4) noexcept -> R \ +#define DECL_FUNCEXT4(ATTR, R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4) \ +ATTR auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3, T4 n4) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name##Ext(gsl::make_not_null(context.get()), n1, n2, n3, n4); \ + return Name##Ext##_(gsl::make_not_null(context.get()), n1, n2, n3, n4); \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, T1 n1, \ T2 n2, T3 n3, T4 n4) noexcept -> R \ { \ - return Name##Ext(al::verify_context(context), n1, n2, n3, n4); \ -} + return Name##Ext##_(al::verify_context(context), n1, n2, n3, n4); \ +} \ +DefineFuncAlias(Name##Direct##Ext) -#define DECL_FUNCEXT5(R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5) \ -auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3, T4 n4, T5 n5) noexcept -> R \ +#define DECL_FUNCEXT5(ATTR, R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5) \ +ATTR auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3, T4 n4, T5 n5) noexcept \ + -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name##Ext(gsl::make_not_null(context.get()), n1, n2, n3, n4, n5); \ + return Name##Ext##_(gsl::make_not_null(context.get()), n1, n2, n3, n4, \ + n5); \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, T1 n1, \ T2 n2, T3 n3, T4 n4, T5 n5) noexcept -> R \ { \ - return Name##Ext(al::verify_context(context), n1, n2, n3, n4, n5); \ -} + return Name##Ext##_(al::verify_context(context), n1, n2, n3, n4, n5); \ +} \ +DefineFuncAlias(Name##Direct##Ext) -#define DECL_FUNCEXT6(R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5, T6,n6) \ -auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3, T4 n4, T5 n5, T6 n6) noexcept \ - -> R \ +#define DECL_FUNCEXT6(ATTR, R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5, \ + T6,n6) \ +ATTR auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3, T4 n4, T5 n5, T6 n6) \ + noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name##Ext(gsl::make_not_null(context.get()), n1, n2, n3, n4, n5, \ + return Name##Ext##_(gsl::make_not_null(context.get()), n1, n2, n3, n4, n5,\ n6); \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, T1 n1, \ T2 n2, T3 n3, T4 n4, T5 n5, T6 n6) noexcept -> R \ { \ - return Name##Ext(al::verify_context(context), n1, n2, n3, n4, n5, n6); \ -} + return Name##Ext##_(al::verify_context(context), n1, n2, n3, n4, n5, n6); \ +} \ +DefineFuncAlias(Name##Direct##Ext) -#define DECL_FUNCEXT8(R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5, T6,n6, \ - T7,n7, T8,n8) \ -auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3, T4 n4, T5 n5, T6 n6, T7 n7, \ - T8 n8) noexcept -> R \ +#define DECL_FUNCEXT8(ATTR, R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4, T5,n5, \ + T6,n6, T7,n7, T8,n8) \ +ATTR auto AL_APIENTRY Name##Ext(T1 n1, T2 n2, T3 n3, T4 n4, T5 n5, T6 n6, \ + T7 n7, T8 n8) noexcept -> R \ { \ auto const context = GetContextRef(); \ if(!context) [[unlikely]] return detail_::DefaultVal(); \ - return Name##Ext(gsl::make_not_null(context.get()), n1, n2, n3, n4, n5, \ + return Name##Ext##_(gsl::make_not_null(context.get()), n1, n2, n3, n4, n5,\ n6, n7, n8); \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, T1 n1, \ T2 n2, T3 n3, T4 n4, T5 n5, T6 n6, T7 n7, T8 n8) noexcept -> R \ { \ - return Name##Ext(al::verify_context(context), n1, n2, n3, n4, n5, n6, n7, \ - n8); \ -} + return Name##Ext##_(al::verify_context(context), n1, n2, n3, n4, n5, n6, \ + n7, n8); \ +} \ +DefineFuncAlias(Name##Direct##Ext) + +#define DECL_FUNCEXT_SELECTOR(ATTR, R, Name,Ext, T1,n1, T2,n2, T3,n3, T4,n4, \ + T5,n5, T6,n6, T7,n7, T8,n8, NAME, ...) NAME +#define DECL_FUNCEXT(...) DECL_PASS(DECL_PASS(DECL_FUNCEXT_SELECTOR) \ + (__VA_ARGS__, DECL_FUNCEXT8, Misdefined, DECL_FUNCEXT7, Misdefined, \ + DECL_FUNCEXT6, Misdefined, DECL_FUNCEXT5, Misdefined, \ + DECL_FUNCEXT4, Misdefined, DECL_FUNCEXT3, Misdefined, \ + DECL_FUNCEXT2, Misdefined, DECL_FUNCEXT1, Misdefined, \ + DECL_FUNCEXT0)(__VA_ARGS__)) #endif /* AL_DIRECT_DEFS_H */ diff --git a/3rdparty/openal/al/eax.cpp b/3rdparty/openal/al/eax.cpp index 2f92c7802efb..64c7aea3ab29 100644 --- a/3rdparty/openal/al/eax.cpp +++ b/3rdparty/openal/al/eax.cpp @@ -1,21 +1,33 @@ #include "config.h" +#include + #include "AL/al.h" +#include "AL/alc.h" +#include "AL/alext.h" -#include "alc/context.h" #include "direct_defs.h" +#include "eax/api.h" #include "eax/utils.h" + +#if HAVE_CXXMODULES +import alc.context; +import gsl; +#else +#include "alc/context.hpp" #include "gsl/gsl" +#endif namespace { -auto EAXSet(gsl::not_null context, const GUID *property_set_id, +auto EAXSet_(gsl::not_null context, _GUID const *property_set_id, ALuint property_id, ALuint source_id, ALvoid *value, ALuint value_size) noexcept -> ALenum try { const auto proplock = std::lock_guard{context->mPropLock}; - return context->eax_eax_set(property_set_id, property_id, source_id, value, value_size); + return context->eax_eax_set(std::launder(reinterpret_cast(property_set_id)), + property_id, source_id, value, value_size); } catch(...) { context->eaxSetLastError(); @@ -23,11 +35,12 @@ catch(...) { return AL_INVALID_OPERATION; } -auto EAXGet(gsl::not_null context, const GUID *property_set_id, +auto EAXGet_(gsl::not_null context, _GUID const *property_set_id, ALuint property_id, ALuint source_id, ALvoid *value, ALuint value_size) noexcept -> ALenum try { const auto proplock = std::lock_guard{context->mPropLock}; - return context->eax_eax_get(property_set_id, property_id, source_id, value, value_size); + return context->eax_eax_get(std::launder(reinterpret_cast(property_set_id)), + property_id, source_id, value, value_size); } catch(...) { context->eaxSetLastError(); @@ -37,7 +50,7 @@ catch(...) { } // namespace -FORCE_ALIGN DECL_FUNC5(ALenum, EAXSet, const GUID*,property_set_id, ALuint,property_id, +DECL_FUNC(FORCE_ALIGN, ALenum, EAXSet, _GUID const*,property_set_id, ALuint,property_id, ALuint,source_id, ALvoid*,value, ALuint,value_size) -FORCE_ALIGN DECL_FUNC5(ALenum, EAXGet, const GUID*,property_set_id, ALuint,property_id, +DECL_FUNC(FORCE_ALIGN, ALenum, EAXGet, _GUID const*,property_set_id, ALuint,property_id, ALuint,source_id, ALvoid*,value, ALuint,value_size) diff --git a/3rdparty/openal/al/eax/api.cpp b/3rdparty/openal/al/eax/api.cpp index fd8b7010618a..f52842d7b6b7 100644 --- a/3rdparty/openal/al/eax/api.cpp +++ b/3rdparty/openal/al/eax/api.cpp @@ -15,7 +15,7 @@ static_assert(sizeof(EAXSOURCEOCCLUSIONSENDPROPERTIES) == 32); static_assert(sizeof(EAXSOURCEEXCLUSIONSENDPROPERTIES) == 24); static_assert(sizeof(EAXSOURCEALLSENDPROPERTIES) == 48); -const GUID DSPROPSETID_EAX_ReverbProperties = +const AL_GUID DSPROPSETID_EAX_ReverbProperties = { 0x4A4E6FC1, 0xC341, @@ -23,7 +23,7 @@ const GUID DSPROPSETID_EAX_ReverbProperties = {0xB7, 0x3A, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} }; -const GUID DSPROPSETID_EAXBUFFER_ReverbProperties = +const AL_GUID DSPROPSETID_EAXBUFFER_ReverbProperties = { 0x4A4E6FC0, 0xC341, @@ -31,7 +31,7 @@ const GUID DSPROPSETID_EAXBUFFER_ReverbProperties = {0xB7, 0x3A, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} }; -const GUID DSPROPSETID_EAX20_ListenerProperties = +const AL_GUID DSPROPSETID_EAX20_ListenerProperties = { 0x306A6A8, 0xB224, @@ -39,7 +39,7 @@ const GUID DSPROPSETID_EAX20_ListenerProperties = {0x99, 0xE5, 0x00, 0x00, 0xE8, 0xD8, 0xC7, 0x22} }; -const GUID DSPROPSETID_EAX20_BufferProperties = +const AL_GUID DSPROPSETID_EAX20_BufferProperties = { 0x306A6A7, 0xB224, @@ -47,7 +47,7 @@ const GUID DSPROPSETID_EAX20_BufferProperties = {0x99, 0xE5, 0x00, 0x00, 0xE8, 0xD8, 0xC7, 0x22} }; -const GUID DSPROPSETID_EAX30_ListenerProperties = +const AL_GUID DSPROPSETID_EAX30_ListenerProperties = { 0xA8FA6882, 0xB476, @@ -55,7 +55,7 @@ const GUID DSPROPSETID_EAX30_ListenerProperties = {0xBD, 0xB9, 0x00, 0xC0, 0xF0, 0x2D, 0xDF, 0x87} }; -const GUID DSPROPSETID_EAX30_BufferProperties = +const AL_GUID DSPROPSETID_EAX30_BufferProperties = { 0xA8FA6881, 0xB476, @@ -63,7 +63,7 @@ const GUID DSPROPSETID_EAX30_BufferProperties = {0xBD, 0xB9, 0x00, 0xC0, 0xF0, 0x2D, 0xDF, 0x87} }; -const GUID EAX_NULL_GUID = +const AL_GUID EAX_NULL_GUID = { 0x00000000, 0x0000, @@ -71,7 +71,7 @@ const GUID EAX_NULL_GUID = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -const GUID EAX_PrimaryFXSlotID = +const AL_GUID EAX_PrimaryFXSlotID = { 0xF317866D, 0x924C, @@ -79,7 +79,7 @@ const GUID EAX_PrimaryFXSlotID = {0x86, 0x1B, 0xE6, 0xDA, 0xA2, 0x5E, 0x7C, 0x20} }; -const GUID EAXPROPERTYID_EAX40_Context = +const AL_GUID EAXPROPERTYID_EAX40_Context = { 0x1D4870AD, 0xDEF, @@ -87,7 +87,7 @@ const GUID EAXPROPERTYID_EAX40_Context = {0xA4, 0xC, 0x52, 0x36, 0x32, 0x29, 0x63, 0x42} }; -const GUID EAXPROPERTYID_EAX50_Context = +const AL_GUID EAXPROPERTYID_EAX50_Context = { 0x57E13437, 0xB932, @@ -95,7 +95,7 @@ const GUID EAXPROPERTYID_EAX50_Context = {0xB8, 0xBD, 0x52, 0x66, 0xC1, 0xA8, 0x87, 0xEE} }; -const GUID EAXPROPERTYID_EAX40_FXSlot0 = +const AL_GUID EAXPROPERTYID_EAX40_FXSlot0 = { 0xC4D79F1E, 0xF1AC, @@ -103,7 +103,7 @@ const GUID EAXPROPERTYID_EAX40_FXSlot0 = {0xA8, 0x1D, 0xA7, 0x38, 0xE7, 0x04, 0x54, 0x69} }; -const GUID EAXPROPERTYID_EAX50_FXSlot0 = +const AL_GUID EAXPROPERTYID_EAX50_FXSlot0 = { 0x91F9590F, 0xC388, @@ -111,7 +111,7 @@ const GUID EAXPROPERTYID_EAX50_FXSlot0 = {0x84, 0xB0, 0x1B, 0xAE, 0xE, 0xF7, 0x1A, 0xBC} }; -const GUID EAXPROPERTYID_EAX40_FXSlot1 = +const AL_GUID EAXPROPERTYID_EAX40_FXSlot1 = { 0x8C00E96, 0x74BE, @@ -119,7 +119,7 @@ const GUID EAXPROPERTYID_EAX40_FXSlot1 = {0x93, 0xAA, 0xE8, 0xAD, 0x35, 0xA4, 0x91, 0x17} }; -const GUID EAXPROPERTYID_EAX50_FXSlot1 = +const AL_GUID EAXPROPERTYID_EAX50_FXSlot1 = { 0x8F5F7ACA, 0x9608, @@ -127,7 +127,7 @@ const GUID EAXPROPERTYID_EAX50_FXSlot1 = {0x81, 0x37, 0x82, 0x13, 0xC7, 0xB9, 0xD9, 0xDE} }; -const GUID EAXPROPERTYID_EAX40_FXSlot2 = +const AL_GUID EAXPROPERTYID_EAX40_FXSlot2 = { 0x1D433B88, 0xF0F6, @@ -135,7 +135,7 @@ const GUID EAXPROPERTYID_EAX40_FXSlot2 = {0x91, 0x9F, 0x60, 0xE7, 0xE0, 0x6B, 0x5E, 0xDD} }; -const GUID EAXPROPERTYID_EAX50_FXSlot2 = +const AL_GUID EAXPROPERTYID_EAX50_FXSlot2 = { 0x3C0F5252, 0x9834, @@ -143,7 +143,7 @@ const GUID EAXPROPERTYID_EAX50_FXSlot2 = {0xA1, 0xD8, 0x5B, 0x95, 0xC4, 0xA0, 0xA, 0x30} }; -const GUID EAXPROPERTYID_EAX40_FXSlot3 = +const AL_GUID EAXPROPERTYID_EAX40_FXSlot3 = { 0xEFFF08EA, 0xC7D8, @@ -151,7 +151,7 @@ const GUID EAXPROPERTYID_EAX40_FXSlot3 = {0x93, 0xAD, 0x6D, 0xBD, 0x5F, 0x91, 0x00, 0x64} }; -const GUID EAXPROPERTYID_EAX50_FXSlot3 = +const AL_GUID EAXPROPERTYID_EAX50_FXSlot3 = { 0xE2EB0EAA, 0xE806, @@ -159,7 +159,7 @@ const GUID EAXPROPERTYID_EAX50_FXSlot3 = {0x9F, 0x86, 0x06, 0xC1, 0x57, 0x1A, 0x6F, 0xA3} }; -const GUID EAXPROPERTYID_EAX40_Source = +const AL_GUID EAXPROPERTYID_EAX40_Source = { 0x1B86B823, 0x22DF, @@ -167,7 +167,7 @@ const GUID EAXPROPERTYID_EAX40_Source = {0x8B, 0x3C, 0x12, 0x78, 0xCE, 0x54, 0x42, 0x27} }; -const GUID EAXPROPERTYID_EAX50_Source = +const AL_GUID EAXPROPERTYID_EAX50_Source = { 0x5EDF82F0, 0x24A7, @@ -175,7 +175,7 @@ const GUID EAXPROPERTYID_EAX50_Source = {0x8E, 0x64, 0x2F, 0x09, 0xCA, 0x05, 0xDE, 0xE1} }; -const GUID EAX_REVERB_EFFECT = +const AL_GUID EAX_REVERB_EFFECT = { 0xCF95C8F, 0xA3CC, @@ -183,7 +183,7 @@ const GUID EAX_REVERB_EFFECT = {0xB0, 0xB6, 0x83, 0x2E, 0xCC, 0x18, 0x22, 0xDF} }; -const GUID EAX_AGCCOMPRESSOR_EFFECT = +const AL_GUID EAX_AGCCOMPRESSOR_EFFECT = { 0xBFB7A01E, 0x7825, @@ -191,7 +191,7 @@ const GUID EAX_AGCCOMPRESSOR_EFFECT = {0x92, 0x7F, 0x03, 0xAA, 0xBD, 0xA0, 0xC5, 0x60} }; -const GUID EAX_AUTOWAH_EFFECT = +const AL_GUID EAX_AUTOWAH_EFFECT = { 0xEC3130C0, 0xAC7A, @@ -199,7 +199,7 @@ const GUID EAX_AUTOWAH_EFFECT = {0x88, 0xDD, 0x00, 0xA0, 0x24, 0xD1, 0x3C, 0xE1} }; -const GUID EAX_CHORUS_EFFECT = +const AL_GUID EAX_CHORUS_EFFECT = { 0xDE6D6FE0, 0xAC79, @@ -207,7 +207,7 @@ const GUID EAX_CHORUS_EFFECT = {0x88, 0xDD, 0x00, 0xA0, 0x24, 0xD1, 0x3C, 0xE1} }; -const GUID EAX_DISTORTION_EFFECT = +const AL_GUID EAX_DISTORTION_EFFECT = { 0x975A4CE0, 0xAC7E, @@ -215,7 +215,7 @@ const GUID EAX_DISTORTION_EFFECT = {0x88, 0xDD, 0x00, 0xA0, 0x24, 0xD1, 0x3C, 0xE1} }; -const GUID EAX_ECHO_EFFECT = +const AL_GUID EAX_ECHO_EFFECT = { 0xE9F1BC0, 0xAC82, @@ -223,7 +223,7 @@ const GUID EAX_ECHO_EFFECT = {0x88, 0xDD, 0x00, 0xA0, 0x24, 0xD1, 0x3C, 0xE1} }; -const GUID EAX_EQUALIZER_EFFECT = +const AL_GUID EAX_EQUALIZER_EFFECT = { 0x65F94CE0, 0x9793, @@ -231,7 +231,7 @@ const GUID EAX_EQUALIZER_EFFECT = {0x93, 0x9D, 0x00, 0xC0, 0xF0, 0x2D, 0xD6, 0xF0} }; -const GUID EAX_FLANGER_EFFECT = +const AL_GUID EAX_FLANGER_EFFECT = { 0xA70007C0, 0x7D2, @@ -239,7 +239,7 @@ const GUID EAX_FLANGER_EFFECT = {0x9B, 0x1E, 0x00, 0xA0, 0x24, 0xD1, 0x3C, 0xE1} }; -const GUID EAX_FREQUENCYSHIFTER_EFFECT = +const AL_GUID EAX_FREQUENCYSHIFTER_EFFECT = { 0xDC3E1880, 0x9212, @@ -247,7 +247,7 @@ const GUID EAX_FREQUENCYSHIFTER_EFFECT = {0x93, 0x9D, 0x00, 0xC0, 0xF0, 0x2D, 0xD6, 0xF0} }; -const GUID EAX_VOCALMORPHER_EFFECT = +const AL_GUID EAX_VOCALMORPHER_EFFECT = { 0xE41CF10C, 0x3383, @@ -255,7 +255,7 @@ const GUID EAX_VOCALMORPHER_EFFECT = {0x88, 0xDD, 0x00, 0xA0, 0x24, 0xD1, 0x3C, 0xE1} }; -const GUID EAX_PITCHSHIFTER_EFFECT = +const AL_GUID EAX_PITCHSHIFTER_EFFECT = { 0xE7905100, 0xAFB2, @@ -263,7 +263,7 @@ const GUID EAX_PITCHSHIFTER_EFFECT = {0x88, 0xDD, 0x00, 0xA0, 0x24, 0xD1, 0x3C, 0xE1} }; -const GUID EAX_RINGMODULATOR_EFFECT = +const AL_GUID EAX_RINGMODULATOR_EFFECT = { 0xB89FE60, 0xAFB5, @@ -272,8 +272,8 @@ const GUID EAX_RINGMODULATOR_EFFECT = }; -const GUID EAX40CONTEXT_DEFAULTPRIMARYFXSLOTID = EAXPROPERTYID_EAX40_FXSlot0; -const GUID EAX50CONTEXT_DEFAULTPRIMARYFXSLOTID = EAXPROPERTYID_EAX50_FXSlot0; +const AL_GUID EAX40CONTEXT_DEFAULTPRIMARYFXSLOTID = EAXPROPERTYID_EAX40_FXSlot0; +const AL_GUID EAX50CONTEXT_DEFAULTPRIMARYFXSLOTID = EAXPROPERTYID_EAX50_FXSlot0; const EAX40ACTIVEFXSLOTS EAX40SOURCE_DEFAULTACTIVEFXSLOTID = EAX40ACTIVEFXSLOTS {{ diff --git a/3rdparty/openal/al/eax/api.h b/3rdparty/openal/al/eax/api.h index c7a2956433c7..fa7c789ff7b8 100644 --- a/3rdparty/openal/al/eax/api.h +++ b/3rdparty/openal/al/eax/api.h @@ -13,13 +13,9 @@ #include #include #include +#include #include #include -#ifdef _WIN32 -#include -#else -#include -#endif #include "AL/al.h" @@ -35,23 +31,21 @@ consteval auto operator ""_eax_ulong(unsigned long long const x) { return gsl::narrow(x); } -#ifndef _WIN32 -using GUID = struct _GUID { /* NOLINT(*-reserved-identifier) */ +struct AL_GUID { std::uint32_t Data1; std::uint16_t Data2; std::uint16_t Data3; std::array Data4; }; -inline bool operator==(const GUID& lhs, const GUID& rhs) noexcept -{ return std::memcmp(&lhs, &rhs, sizeof(GUID)) == 0; } +inline bool operator==(AL_GUID const& lhs, AL_GUID const& rhs) noexcept +{ return std::memcmp(&lhs, &rhs, sizeof(AL_GUID)) == 0; } -inline bool operator!=(const GUID& lhs, const GUID& rhs) noexcept +inline bool operator!=(AL_GUID const& lhs, AL_GUID const& rhs) noexcept { return !(lhs == rhs); } -#endif // _WIN32 -DECL_HIDDEN extern const GUID DSPROPSETID_EAX_ReverbProperties; +DECL_HIDDEN extern const AL_GUID DSPROPSETID_EAX_ReverbProperties; enum DSPROPERTY_EAX_REVERBPROPERTY : unsigned { DSPROPERTY_EAX_ALL, @@ -69,7 +63,7 @@ struct EAX_REVERBPROPERTIES { }; // EAX_REVERBPROPERTIES -DECL_HIDDEN extern const GUID DSPROPSETID_EAXBUFFER_ReverbProperties; +DECL_HIDDEN extern const AL_GUID DSPROPSETID_EAXBUFFER_ReverbProperties; enum DSPROPERTY_EAXBUFFER_REVERBPROPERTY : unsigned { DSPROPERTY_EAXBUFFER_ALL, @@ -80,12 +74,12 @@ struct EAXBUFFER_REVERBPROPERTIES { float fMix; }; -constexpr auto EAX_BUFFER_MINREVERBMIX = 0.0F; -constexpr auto EAX_BUFFER_MAXREVERBMIX = 1.0F; -constexpr auto EAX_REVERBMIX_USEDISTANCE = -1.0F; +inline constexpr auto EAX_BUFFER_MINREVERBMIX = 0.0F; +inline constexpr auto EAX_BUFFER_MAXREVERBMIX = 1.0F; +inline constexpr auto EAX_REVERBMIX_USEDISTANCE = -1.0F; -DECL_HIDDEN extern const GUID DSPROPSETID_EAX20_ListenerProperties; +DECL_HIDDEN extern const AL_GUID DSPROPSETID_EAX20_ListenerProperties; enum DSPROPERTY_EAX20_LISTENERPROPERTY : unsigned { DSPROPERTY_EAX20LISTENER_NONE, @@ -154,67 +148,67 @@ enum : eax_ulong { EAX2_ENVIRONMENT_COUNT, }; -constexpr auto EAX2LISTENERFLAGS_DECAYTIMESCALE = 0x00000001_eax_ulong; -constexpr auto EAX2LISTENERFLAGS_REFLECTIONSSCALE = 0x00000002_eax_ulong; -constexpr auto EAX2LISTENERFLAGS_REFLECTIONSDELAYSCALE = 0x00000004_eax_ulong; -constexpr auto EAX2LISTENERFLAGS_REVERBSCALE = 0x00000008_eax_ulong; -constexpr auto EAX2LISTENERFLAGS_REVERBDELAYSCALE = 0x00000010_eax_ulong; -constexpr auto EAX2LISTENERFLAGS_DECAYHFLIMIT = 0x00000020_eax_ulong; -constexpr auto EAX2LISTENERFLAGS_RESERVED = 0xFFFFFFC0_eax_ulong; +inline constexpr auto EAX2LISTENERFLAGS_DECAYTIMESCALE = 0x00000001_eax_ulong; +inline constexpr auto EAX2LISTENERFLAGS_REFLECTIONSSCALE = 0x00000002_eax_ulong; +inline constexpr auto EAX2LISTENERFLAGS_REFLECTIONSDELAYSCALE = 0x00000004_eax_ulong; +inline constexpr auto EAX2LISTENERFLAGS_REVERBSCALE = 0x00000008_eax_ulong; +inline constexpr auto EAX2LISTENERFLAGS_REVERBDELAYSCALE = 0x00000010_eax_ulong; +inline constexpr auto EAX2LISTENERFLAGS_DECAYHFLIMIT = 0x00000020_eax_ulong; +inline constexpr auto EAX2LISTENERFLAGS_RESERVED = 0xFFFFFFC0_eax_ulong; -constexpr auto EAX2LISTENER_MINROOM = -10'000_eax_long; -constexpr auto EAX2LISTENER_MAXROOM = 0_eax_long; -constexpr auto EAX2LISTENER_DEFAULTROOM = -1'000_eax_long; +inline constexpr auto EAX2LISTENER_MINROOM = -10'000_eax_long; +inline constexpr auto EAX2LISTENER_MAXROOM = 0_eax_long; +inline constexpr auto EAX2LISTENER_DEFAULTROOM = -1'000_eax_long; -constexpr auto EAX2LISTENER_MINROOMHF = -10'000_eax_long; -constexpr auto EAX2LISTENER_MAXROOMHF = 0_eax_long; -constexpr auto EAX2LISTENER_DEFAULTROOMHF = -100_eax_long; +inline constexpr auto EAX2LISTENER_MINROOMHF = -10'000_eax_long; +inline constexpr auto EAX2LISTENER_MAXROOMHF = 0_eax_long; +inline constexpr auto EAX2LISTENER_DEFAULTROOMHF = -100_eax_long; -constexpr auto EAX2LISTENER_MINROOMROLLOFFFACTOR = 0.0F; -constexpr auto EAX2LISTENER_MAXROOMROLLOFFFACTOR = 10.0F; -constexpr auto EAX2LISTENER_DEFAULTROOMROLLOFFFACTOR = 0.0F; +inline constexpr auto EAX2LISTENER_MINROOMROLLOFFFACTOR = 0.0F; +inline constexpr auto EAX2LISTENER_MAXROOMROLLOFFFACTOR = 10.0F; +inline constexpr auto EAX2LISTENER_DEFAULTROOMROLLOFFFACTOR = 0.0F; -constexpr auto EAX2LISTENER_MINDECAYTIME = 0.1F; -constexpr auto EAX2LISTENER_MAXDECAYTIME = 20.0F; -constexpr auto EAX2LISTENER_DEFAULTDECAYTIME = 1.49F; +inline constexpr auto EAX2LISTENER_MINDECAYTIME = 0.1F; +inline constexpr auto EAX2LISTENER_MAXDECAYTIME = 20.0F; +inline constexpr auto EAX2LISTENER_DEFAULTDECAYTIME = 1.49F; -constexpr auto EAX2LISTENER_MINDECAYHFRATIO = 0.1F; -constexpr auto EAX2LISTENER_MAXDECAYHFRATIO = 2.0F; -constexpr auto EAX2LISTENER_DEFAULTDECAYHFRATIO = 0.83F; +inline constexpr auto EAX2LISTENER_MINDECAYHFRATIO = 0.1F; +inline constexpr auto EAX2LISTENER_MAXDECAYHFRATIO = 2.0F; +inline constexpr auto EAX2LISTENER_DEFAULTDECAYHFRATIO = 0.83F; -constexpr auto EAX2LISTENER_MINREFLECTIONS = -10'000_eax_long; -constexpr auto EAX2LISTENER_MAXREFLECTIONS = 1'000_eax_long; -constexpr auto EAX2LISTENER_DEFAULTREFLECTIONS = -2'602_eax_long; +inline constexpr auto EAX2LISTENER_MINREFLECTIONS = -10'000_eax_long; +inline constexpr auto EAX2LISTENER_MAXREFLECTIONS = 1'000_eax_long; +inline constexpr auto EAX2LISTENER_DEFAULTREFLECTIONS = -2'602_eax_long; -constexpr auto EAX2LISTENER_MINREFLECTIONSDELAY = 0.0F; -constexpr auto EAX2LISTENER_MAXREFLECTIONSDELAY = 0.3F; -constexpr auto EAX2LISTENER_DEFAULTREFLECTIONSDELAY = 0.007F; +inline constexpr auto EAX2LISTENER_MINREFLECTIONSDELAY = 0.0F; +inline constexpr auto EAX2LISTENER_MAXREFLECTIONSDELAY = 0.3F; +inline constexpr auto EAX2LISTENER_DEFAULTREFLECTIONSDELAY = 0.007F; -constexpr auto EAX2LISTENER_MINREVERB = -10'000_eax_long; -constexpr auto EAX2LISTENER_MAXREVERB = 2'000_eax_long; -constexpr auto EAX2LISTENER_DEFAULTREVERB = 200_eax_long; +inline constexpr auto EAX2LISTENER_MINREVERB = -10'000_eax_long; +inline constexpr auto EAX2LISTENER_MAXREVERB = 2'000_eax_long; +inline constexpr auto EAX2LISTENER_DEFAULTREVERB = 200_eax_long; -constexpr auto EAX2LISTENER_MINREVERBDELAY = 0.0F; -constexpr auto EAX2LISTENER_MAXREVERBDELAY = 0.1F; -constexpr auto EAX2LISTENER_DEFAULTREVERBDELAY = 0.011F; +inline constexpr auto EAX2LISTENER_MINREVERBDELAY = 0.0F; +inline constexpr auto EAX2LISTENER_MAXREVERBDELAY = 0.1F; +inline constexpr auto EAX2LISTENER_DEFAULTREVERBDELAY = 0.011F; -constexpr auto EAX2LISTENER_MINENVIRONMENT = 0_eax_ulong; -constexpr auto EAX2LISTENER_MAXENVIRONMENT = EAX2_ENVIRONMENT_COUNT - 1; -constexpr auto EAX2LISTENER_DEFAULTENVIRONMENT = EAX2_ENVIRONMENT_GENERIC; +inline constexpr auto EAX2LISTENER_MINENVIRONMENT = 0_eax_ulong; +inline constexpr auto EAX2LISTENER_MAXENVIRONMENT = EAX2_ENVIRONMENT_COUNT - 1; +inline constexpr auto EAX2LISTENER_DEFAULTENVIRONMENT = EAX2_ENVIRONMENT_GENERIC; -constexpr auto EAX2LISTENER_MINENVIRONMENTSIZE = 1.0F; -constexpr auto EAX2LISTENER_MAXENVIRONMENTSIZE = 100.0F; -constexpr auto EAX2LISTENER_DEFAULTENVIRONMENTSIZE = 7.5F; +inline constexpr auto EAX2LISTENER_MINENVIRONMENTSIZE = 1.0F; +inline constexpr auto EAX2LISTENER_MAXENVIRONMENTSIZE = 100.0F; +inline constexpr auto EAX2LISTENER_DEFAULTENVIRONMENTSIZE = 7.5F; -constexpr auto EAX2LISTENER_MINENVIRONMENTDIFFUSION = 0.0F; -constexpr auto EAX2LISTENER_MAXENVIRONMENTDIFFUSION = 1.0F; -constexpr auto EAX2LISTENER_DEFAULTENVIRONMENTDIFFUSION = 1.0F; +inline constexpr auto EAX2LISTENER_MINENVIRONMENTDIFFUSION = 0.0F; +inline constexpr auto EAX2LISTENER_MAXENVIRONMENTDIFFUSION = 1.0F; +inline constexpr auto EAX2LISTENER_DEFAULTENVIRONMENTDIFFUSION = 1.0F; -constexpr auto EAX2LISTENER_MINAIRABSORPTIONHF = -100.0F; -constexpr auto EAX2LISTENER_MAXAIRABSORPTIONHF = 0.0F; -constexpr auto EAX2LISTENER_DEFAULTAIRABSORPTIONHF = -5.0F; +inline constexpr auto EAX2LISTENER_MINAIRABSORPTIONHF = -100.0F; +inline constexpr auto EAX2LISTENER_MAXAIRABSORPTIONHF = 0.0F; +inline constexpr auto EAX2LISTENER_DEFAULTAIRABSORPTIONHF = -5.0F; -constexpr auto EAX2LISTENER_DEFAULTFLAGS = +inline constexpr auto EAX2LISTENER_DEFAULTFLAGS = EAX2LISTENERFLAGS_DECAYTIMESCALE | EAX2LISTENERFLAGS_REFLECTIONSSCALE | EAX2LISTENERFLAGS_REFLECTIONSDELAYSCALE | @@ -223,7 +217,7 @@ constexpr auto EAX2LISTENER_DEFAULTFLAGS = EAX2LISTENERFLAGS_DECAYHFLIMIT; -DECL_HIDDEN extern const GUID DSPROPSETID_EAX20_BufferProperties; +DECL_HIDDEN extern const AL_GUID DSPROPSETID_EAX20_BufferProperties; enum DSPROPERTY_EAX20_BUFFERPROPERTY : unsigned { DSPROPERTY_EAX20BUFFER_NONE, @@ -259,29 +253,29 @@ struct EAX20BUFFERPROPERTIES { eax_ulong dwFlags; // modifies the behavior of properties }; // EAX20BUFFERPROPERTIES -DECL_HIDDEN extern const GUID DSPROPSETID_EAX30_ListenerProperties; +DECL_HIDDEN extern const AL_GUID DSPROPSETID_EAX30_ListenerProperties; -DECL_HIDDEN extern const GUID DSPROPSETID_EAX30_BufferProperties; +DECL_HIDDEN extern const AL_GUID DSPROPSETID_EAX30_BufferProperties; -constexpr auto EAX_MAX_FXSLOTS = 4; +inline constexpr auto EAX_MAX_FXSLOTS = 4; -constexpr auto EAX40_MAX_ACTIVE_FXSLOTS = 2; -constexpr auto EAX50_MAX_ACTIVE_FXSLOTS = 4; +inline constexpr auto EAX40_MAX_ACTIVE_FXSLOTS = 2; +inline constexpr auto EAX50_MAX_ACTIVE_FXSLOTS = 4; -constexpr auto EAX_OK = 0_eax_long; -constexpr auto EAXERR_INVALID_OPERATION = -1_eax_long; -constexpr auto EAXERR_INVALID_VALUE = -2_eax_long; -constexpr auto EAXERR_NO_EFFECT_LOADED = -3_eax_long; -constexpr auto EAXERR_UNKNOWN_EFFECT = -4_eax_long; -constexpr auto EAXERR_INCOMPATIBLE_SOURCE_TYPE = -5_eax_long; -constexpr auto EAXERR_INCOMPATIBLE_EAX_VERSION = -6_eax_long; +inline constexpr auto EAX_OK = 0_eax_long; +inline constexpr auto EAXERR_INVALID_OPERATION = -1_eax_long; +inline constexpr auto EAXERR_INVALID_VALUE = -2_eax_long; +inline constexpr auto EAXERR_NO_EFFECT_LOADED = -3_eax_long; +inline constexpr auto EAXERR_UNKNOWN_EFFECT = -4_eax_long; +inline constexpr auto EAXERR_INCOMPATIBLE_SOURCE_TYPE = -5_eax_long; +inline constexpr auto EAXERR_INCOMPATIBLE_EAX_VERSION = -6_eax_long; -DECL_HIDDEN extern const GUID EAX_NULL_GUID; +DECL_HIDDEN extern const AL_GUID EAX_NULL_GUID; -DECL_HIDDEN extern const GUID EAX_PrimaryFXSlotID; +DECL_HIDDEN extern const AL_GUID EAX_PrimaryFXSlotID; struct EAXVECTOR { @@ -296,32 +290,32 @@ struct EAXVECTOR { -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX40_Context; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX40_Context; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX50_Context; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX50_Context; // EAX50 -constexpr auto HEADPHONES = 0_eax_ulong; -constexpr auto SPEAKERS_2 = 1_eax_ulong; -constexpr auto SPEAKERS_4 = 2_eax_ulong; -constexpr auto SPEAKERS_5 = 3_eax_ulong; // 5.1 speakers -constexpr auto SPEAKERS_6 = 4_eax_ulong; // 6.1 speakers -constexpr auto SPEAKERS_7 = 5_eax_ulong; // 7.1 speakers +inline constexpr auto HEADPHONES = 0_eax_ulong; +inline constexpr auto SPEAKERS_2 = 1_eax_ulong; +inline constexpr auto SPEAKERS_4 = 2_eax_ulong; +inline constexpr auto SPEAKERS_5 = 3_eax_ulong; // 5.1 speakers +inline constexpr auto SPEAKERS_6 = 4_eax_ulong; // 6.1 speakers +inline constexpr auto SPEAKERS_7 = 5_eax_ulong; // 7.1 speakers -constexpr auto EAXCONTEXT_MINSPEAKERCONFIG = HEADPHONES; -constexpr auto EAXCONTEXT_MAXSPEAKERCONFIG = SPEAKERS_7; +inline constexpr auto EAXCONTEXT_MINSPEAKERCONFIG = HEADPHONES; +inline constexpr auto EAXCONTEXT_MAXSPEAKERCONFIG = SPEAKERS_7; // EAX50 -constexpr auto EAX_40 = 5_eax_ulong; // EAX 4.0 -constexpr auto EAX_50 = 6_eax_ulong; // EAX 5.0 +inline constexpr auto EAX_40 = 5_eax_ulong; // EAX 4.0 +inline constexpr auto EAX_50 = 6_eax_ulong; // EAX 5.0 -constexpr auto EAXCONTEXT_MINEAXSESSION = EAX_40; -constexpr auto EAXCONTEXT_MAXEAXSESSION = EAX_50; -constexpr auto EAXCONTEXT_DEFAULTEAXSESSION = EAX_40; +inline constexpr auto EAXCONTEXT_MINEAXSESSION = EAX_40; +inline constexpr auto EAXCONTEXT_MAXEAXSESSION = EAX_50; +inline constexpr auto EAXCONTEXT_DEFAULTEAXSESSION = EAX_40; -constexpr auto EAXCONTEXT_MINMAXACTIVESENDS = 2_eax_ulong; -constexpr auto EAXCONTEXT_MAXMAXACTIVESENDS = 4_eax_ulong; -constexpr auto EAXCONTEXT_DEFAULTMAXACTIVESENDS = 2_eax_ulong; +inline constexpr auto EAXCONTEXT_MINMAXACTIVESENDS = 2_eax_ulong; +inline constexpr auto EAXCONTEXT_MAXMAXACTIVESENDS = 4_eax_ulong; +inline constexpr auto EAXCONTEXT_DEFAULTMAXACTIVESENDS = 2_eax_ulong; // EAX50 struct EAXSESSIONPROPERTIES { @@ -345,7 +339,7 @@ enum EAXCONTEXT_PROPERTY : unsigned { }; // EAXCONTEXT_PROPERTY struct EAX40CONTEXTPROPERTIES { - GUID guidPrimaryFXSlotID; + AL_GUID guidPrimaryFXSlotID; float flDistanceFactor; float flAirAbsorptionHF; float flHFReference; @@ -356,35 +350,35 @@ struct EAX50CONTEXTPROPERTIES : public EAX40CONTEXTPROPERTIES { }; // EAX50CONTEXTPROPERTIES -constexpr auto EAXCONTEXT_MINDISTANCEFACTOR = FLT_MIN; -constexpr auto EAXCONTEXT_MAXDISTANCEFACTOR = FLT_MAX; -constexpr auto EAXCONTEXT_DEFAULTDISTANCEFACTOR = 1.0F; +inline constexpr auto EAXCONTEXT_MINDISTANCEFACTOR = FLT_MIN; +inline constexpr auto EAXCONTEXT_MAXDISTANCEFACTOR = FLT_MAX; +inline constexpr auto EAXCONTEXT_DEFAULTDISTANCEFACTOR = 1.0F; -constexpr auto EAXCONTEXT_MINAIRABSORPTIONHF = -100.0F; -constexpr auto EAXCONTEXT_MAXAIRABSORPTIONHF = 0.0F; -constexpr auto EAXCONTEXT_DEFAULTAIRABSORPTIONHF = -5.0F; +inline constexpr auto EAXCONTEXT_MINAIRABSORPTIONHF = -100.0F; +inline constexpr auto EAXCONTEXT_MAXAIRABSORPTIONHF = 0.0F; +inline constexpr auto EAXCONTEXT_DEFAULTAIRABSORPTIONHF = -5.0F; -constexpr auto EAXCONTEXT_MINHFREFERENCE = 1000.0F; -constexpr auto EAXCONTEXT_MAXHFREFERENCE = 20000.0F; -constexpr auto EAXCONTEXT_DEFAULTHFREFERENCE = 5000.0F; +inline constexpr auto EAXCONTEXT_MINHFREFERENCE = 1000.0F; +inline constexpr auto EAXCONTEXT_MAXHFREFERENCE = 20000.0F; +inline constexpr auto EAXCONTEXT_DEFAULTHFREFERENCE = 5000.0F; -constexpr auto EAXCONTEXT_MINMACROFXFACTOR = 0.0F; -constexpr auto EAXCONTEXT_MAXMACROFXFACTOR = 1.0F; -constexpr auto EAXCONTEXT_DEFAULTMACROFXFACTOR = 0.0F; +inline constexpr auto EAXCONTEXT_MINMACROFXFACTOR = 0.0F; +inline constexpr auto EAXCONTEXT_MAXMACROFXFACTOR = 1.0F; +inline constexpr auto EAXCONTEXT_DEFAULTMACROFXFACTOR = 0.0F; -constexpr auto EAXCONTEXT_DEFAULTLASTERROR = EAX_OK; +inline constexpr auto EAXCONTEXT_DEFAULTLASTERROR = EAX_OK; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX40_FXSlot0; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX50_FXSlot0; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX40_FXSlot1; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX50_FXSlot1; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX40_FXSlot2; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX50_FXSlot2; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX40_FXSlot3; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX50_FXSlot3; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX40_FXSlot0; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX50_FXSlot0; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX40_FXSlot1; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX50_FXSlot1; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX40_FXSlot2; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX50_FXSlot2; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX40_FXSlot3; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX50_FXSlot3; -DECL_HIDDEN extern const GUID EAX40CONTEXT_DEFAULTPRIMARYFXSLOTID; -DECL_HIDDEN extern const GUID EAX50CONTEXT_DEFAULTPRIMARYFXSLOTID; +DECL_HIDDEN extern const AL_GUID EAX40CONTEXT_DEFAULTPRIMARYFXSLOTID; +DECL_HIDDEN extern const AL_GUID EAX50CONTEXT_DEFAULTPRIMARYFXSLOTID; enum EAXFXSLOT_PROPERTY : unsigned { EAXFXSLOT_PARAMETER = 0, @@ -401,42 +395,42 @@ enum EAXFXSLOT_PROPERTY : unsigned { EAXFXSLOT_OCCLUSIONLFRATIO, }; // EAXFXSLOT_PROPERTY -constexpr auto EAXFXSLOTFLAGS_ENVIRONMENT = 0x00000001_eax_ulong; +inline constexpr auto EAXFXSLOTFLAGS_ENVIRONMENT = 0x00000001_eax_ulong; // EAX50 -constexpr auto EAXFXSLOTFLAGS_UPMIX = 0x00000002_eax_ulong; +inline constexpr auto EAXFXSLOTFLAGS_UPMIX = 0x00000002_eax_ulong; -constexpr auto EAX40FXSLOTFLAGS_RESERVED = 0xFFFFFFFE_eax_ulong; // reserved future use -constexpr auto EAX50FXSLOTFLAGS_RESERVED = 0xFFFFFFFC_eax_ulong; // reserved future use +inline constexpr auto EAX40FXSLOTFLAGS_RESERVED = 0xFFFFFFFE_eax_ulong; // reserved future use +inline constexpr auto EAX50FXSLOTFLAGS_RESERVED = 0xFFFFFFFC_eax_ulong; // reserved future use -constexpr auto EAXFXSLOT_MINVOLUME = -10'000_eax_long; -constexpr auto EAXFXSLOT_MAXVOLUME = 0_eax_long; -constexpr auto EAXFXSLOT_DEFAULTVOLUME = 0_eax_long; +inline constexpr auto EAXFXSLOT_MINVOLUME = -10'000_eax_long; +inline constexpr auto EAXFXSLOT_MAXVOLUME = 0_eax_long; +inline constexpr auto EAXFXSLOT_DEFAULTVOLUME = 0_eax_long; -constexpr auto EAXFXSLOT_MINLOCK = 0_eax_long; -constexpr auto EAXFXSLOT_MAXLOCK = 1_eax_long; +inline constexpr auto EAXFXSLOT_MINLOCK = 0_eax_long; +inline constexpr auto EAXFXSLOT_MAXLOCK = 1_eax_long; enum : eax_long { EAXFXSLOT_UNLOCKED = 0, EAXFXSLOT_LOCKED = 1 }; -constexpr auto EAXFXSLOT_MINOCCLUSION = -10'000_eax_long; -constexpr auto EAXFXSLOT_MAXOCCLUSION = 0_eax_long; -constexpr auto EAXFXSLOT_DEFAULTOCCLUSION = 0_eax_long; +inline constexpr auto EAXFXSLOT_MINOCCLUSION = -10'000_eax_long; +inline constexpr auto EAXFXSLOT_MAXOCCLUSION = 0_eax_long; +inline constexpr auto EAXFXSLOT_DEFAULTOCCLUSION = 0_eax_long; -constexpr auto EAXFXSLOT_MINOCCLUSIONLFRATIO = 0.0F; -constexpr auto EAXFXSLOT_MAXOCCLUSIONLFRATIO = 1.0F; -constexpr auto EAXFXSLOT_DEFAULTOCCLUSIONLFRATIO = 0.25F; +inline constexpr auto EAXFXSLOT_MINOCCLUSIONLFRATIO = 0.0F; +inline constexpr auto EAXFXSLOT_MAXOCCLUSIONLFRATIO = 1.0F; +inline constexpr auto EAXFXSLOT_DEFAULTOCCLUSIONLFRATIO = 0.25F; -constexpr auto EAX40FXSLOT_DEFAULTFLAGS = EAXFXSLOTFLAGS_ENVIRONMENT; +inline constexpr auto EAX40FXSLOT_DEFAULTFLAGS = EAXFXSLOTFLAGS_ENVIRONMENT; -constexpr auto EAX50FXSLOT_DEFAULTFLAGS = +inline constexpr auto EAX50FXSLOT_DEFAULTFLAGS = EAXFXSLOTFLAGS_ENVIRONMENT | EAXFXSLOTFLAGS_UPMIX; // ignored for reverb; struct EAX40FXSLOTPROPERTIES { - GUID guidLoadEffect; + AL_GUID guidLoadEffect; eax_long lVolume; eax_long lLock; eax_ulong ulFlags; @@ -447,8 +441,8 @@ struct EAX50FXSLOTPROPERTIES : EAX40FXSLOTPROPERTIES { float flOcclusionLFRatio; }; // EAX50FXSLOTPROPERTIES -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX40_Source; -DECL_HIDDEN extern const GUID EAXPROPERTYID_EAX50_Source; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX40_Source; +DECL_HIDDEN extern const AL_GUID EAXPROPERTYID_EAX50_Source; // Source object properties enum EAXSOURCE_PROPERTY : unsigned { @@ -491,105 +485,105 @@ enum EAXSOURCE_PROPERTY : unsigned { }; // EAXSOURCE_PROPERTY -constexpr auto EAXSOURCEFLAGS_DIRECTHFAUTO = 0x00000001_eax_ulong; // relates to EAXSOURCE_DIRECTHF -constexpr auto EAXSOURCEFLAGS_ROOMAUTO = 0x00000002_eax_ulong; // relates to EAXSOURCE_ROOM -constexpr auto EAXSOURCEFLAGS_ROOMHFAUTO = 0x00000004_eax_ulong; // relates to EAXSOURCE_ROOMHF +inline constexpr auto EAXSOURCEFLAGS_DIRECTHFAUTO = 0x00000001_eax_ulong; // relates to EAXSOURCE_DIRECTHF +inline constexpr auto EAXSOURCEFLAGS_ROOMAUTO = 0x00000002_eax_ulong; // relates to EAXSOURCE_ROOM +inline constexpr auto EAXSOURCEFLAGS_ROOMHFAUTO = 0x00000004_eax_ulong; // relates to EAXSOURCE_ROOMHF // EAX50 -constexpr auto EAXSOURCEFLAGS_3DELEVATIONFILTER = 0x00000008_eax_ulong; -constexpr auto EAXSOURCEFLAGS_UPMIX = 0x00000010_eax_ulong; -constexpr auto EAXSOURCEFLAGS_APPLYSPEAKERLEVELS = 0x00000020_eax_ulong; +inline constexpr auto EAXSOURCEFLAGS_3DELEVATIONFILTER = 0x00000008_eax_ulong; +inline constexpr auto EAXSOURCEFLAGS_UPMIX = 0x00000010_eax_ulong; +inline constexpr auto EAXSOURCEFLAGS_APPLYSPEAKERLEVELS = 0x00000020_eax_ulong; -constexpr auto EAX20SOURCEFLAGS_RESERVED = 0xFFFFFFF8_eax_ulong; // reserved future use -constexpr auto EAX50SOURCEFLAGS_RESERVED = 0xFFFFFFC0_eax_ulong; // reserved future use +inline constexpr auto EAX20SOURCEFLAGS_RESERVED = 0xFFFFFFF8_eax_ulong; // reserved future use +inline constexpr auto EAX50SOURCEFLAGS_RESERVED = 0xFFFFFFC0_eax_ulong; // reserved future use -constexpr auto EAXSOURCE_MINSEND = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXSEND = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTSEND = 0_eax_long; +inline constexpr auto EAXSOURCE_MINSEND = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXSEND = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTSEND = 0_eax_long; -constexpr auto EAXSOURCE_MINSENDHF = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXSENDHF = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTSENDHF = 0_eax_long; +inline constexpr auto EAXSOURCE_MINSENDHF = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXSENDHF = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTSENDHF = 0_eax_long; -constexpr auto EAXSOURCE_MINDIRECT = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXDIRECT = 1'000_eax_long; -constexpr auto EAXSOURCE_DEFAULTDIRECT = 0_eax_long; +inline constexpr auto EAXSOURCE_MINDIRECT = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXDIRECT = 1'000_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTDIRECT = 0_eax_long; -constexpr auto EAXSOURCE_MINDIRECTHF = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXDIRECTHF = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTDIRECTHF = 0_eax_long; +inline constexpr auto EAXSOURCE_MINDIRECTHF = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXDIRECTHF = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTDIRECTHF = 0_eax_long; -constexpr auto EAXSOURCE_MINROOM = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXROOM = 1'000_eax_long; -constexpr auto EAXSOURCE_DEFAULTROOM = 0_eax_long; +inline constexpr auto EAXSOURCE_MINROOM = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXROOM = 1'000_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTROOM = 0_eax_long; -constexpr auto EAXSOURCE_MINROOMHF = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXROOMHF = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTROOMHF = 0_eax_long; +inline constexpr auto EAXSOURCE_MINROOMHF = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXROOMHF = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTROOMHF = 0_eax_long; -constexpr auto EAXSOURCE_MINOBSTRUCTION = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXOBSTRUCTION = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTOBSTRUCTION = 0_eax_long; +inline constexpr auto EAXSOURCE_MINOBSTRUCTION = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXOBSTRUCTION = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTOBSTRUCTION = 0_eax_long; -constexpr auto EAXSOURCE_MINOBSTRUCTIONLFRATIO = 0.0F; -constexpr auto EAXSOURCE_MAXOBSTRUCTIONLFRATIO = 1.0F; -constexpr auto EAXSOURCE_DEFAULTOBSTRUCTIONLFRATIO = 0.0F; +inline constexpr auto EAXSOURCE_MINOBSTRUCTIONLFRATIO = 0.0F; +inline constexpr auto EAXSOURCE_MAXOBSTRUCTIONLFRATIO = 1.0F; +inline constexpr auto EAXSOURCE_DEFAULTOBSTRUCTIONLFRATIO = 0.0F; -constexpr auto EAXSOURCE_MINOCCLUSION = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXOCCLUSION = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTOCCLUSION = 0_eax_long; +inline constexpr auto EAXSOURCE_MINOCCLUSION = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXOCCLUSION = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTOCCLUSION = 0_eax_long; -constexpr auto EAXSOURCE_MINOCCLUSIONLFRATIO = 0.0F; -constexpr auto EAXSOURCE_MAXOCCLUSIONLFRATIO = 1.0F; -constexpr auto EAXSOURCE_DEFAULTOCCLUSIONLFRATIO = 0.25F; +inline constexpr auto EAXSOURCE_MINOCCLUSIONLFRATIO = 0.0F; +inline constexpr auto EAXSOURCE_MAXOCCLUSIONLFRATIO = 1.0F; +inline constexpr auto EAXSOURCE_DEFAULTOCCLUSIONLFRATIO = 0.25F; -constexpr auto EAXSOURCE_MINOCCLUSIONROOMRATIO = 0.0F; -constexpr auto EAXSOURCE_MAXOCCLUSIONROOMRATIO = 10.0F; -constexpr auto EAXSOURCE_DEFAULTOCCLUSIONROOMRATIO = 1.5F; +inline constexpr auto EAXSOURCE_MINOCCLUSIONROOMRATIO = 0.0F; +inline constexpr auto EAXSOURCE_MAXOCCLUSIONROOMRATIO = 10.0F; +inline constexpr auto EAXSOURCE_DEFAULTOCCLUSIONROOMRATIO = 1.5F; -constexpr auto EAXSOURCE_MINOCCLUSIONDIRECTRATIO = 0.0F; -constexpr auto EAXSOURCE_MAXOCCLUSIONDIRECTRATIO = 10.0F; -constexpr auto EAXSOURCE_DEFAULTOCCLUSIONDIRECTRATIO = 1.0F; +inline constexpr auto EAXSOURCE_MINOCCLUSIONDIRECTRATIO = 0.0F; +inline constexpr auto EAXSOURCE_MAXOCCLUSIONDIRECTRATIO = 10.0F; +inline constexpr auto EAXSOURCE_DEFAULTOCCLUSIONDIRECTRATIO = 1.0F; -constexpr auto EAXSOURCE_MINEXCLUSION = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXEXCLUSION = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTEXCLUSION = 0_eax_long; +inline constexpr auto EAXSOURCE_MINEXCLUSION = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXEXCLUSION = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTEXCLUSION = 0_eax_long; -constexpr auto EAXSOURCE_MINEXCLUSIONLFRATIO = 0.0F; -constexpr auto EAXSOURCE_MAXEXCLUSIONLFRATIO = 1.0F; -constexpr auto EAXSOURCE_DEFAULTEXCLUSIONLFRATIO = 1.0F; +inline constexpr auto EAXSOURCE_MINEXCLUSIONLFRATIO = 0.0F; +inline constexpr auto EAXSOURCE_MAXEXCLUSIONLFRATIO = 1.0F; +inline constexpr auto EAXSOURCE_DEFAULTEXCLUSIONLFRATIO = 1.0F; -constexpr auto EAXSOURCE_MINOUTSIDEVOLUMEHF = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXOUTSIDEVOLUMEHF = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTOUTSIDEVOLUMEHF = 0_eax_long; +inline constexpr auto EAXSOURCE_MINOUTSIDEVOLUMEHF = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXOUTSIDEVOLUMEHF = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTOUTSIDEVOLUMEHF = 0_eax_long; -constexpr auto EAXSOURCE_MINDOPPLERFACTOR = 0.0F; -constexpr auto EAXSOURCE_MAXDOPPLERFACTOR = 10.0F; -constexpr auto EAXSOURCE_DEFAULTDOPPLERFACTOR = 1.0F; +inline constexpr auto EAXSOURCE_MINDOPPLERFACTOR = 0.0F; +inline constexpr auto EAXSOURCE_MAXDOPPLERFACTOR = 10.0F; +inline constexpr auto EAXSOURCE_DEFAULTDOPPLERFACTOR = 1.0F; -constexpr auto EAXSOURCE_MINROLLOFFFACTOR = 0.0F; -constexpr auto EAXSOURCE_MAXROLLOFFFACTOR = 10.0F; -constexpr auto EAXSOURCE_DEFAULTROLLOFFFACTOR = 0.0F; +inline constexpr auto EAXSOURCE_MINROLLOFFFACTOR = 0.0F; +inline constexpr auto EAXSOURCE_MAXROLLOFFFACTOR = 10.0F; +inline constexpr auto EAXSOURCE_DEFAULTROLLOFFFACTOR = 0.0F; -constexpr auto EAXSOURCE_MINROOMROLLOFFFACTOR = 0.0F; -constexpr auto EAXSOURCE_MAXROOMROLLOFFFACTOR = 10.0F; -constexpr auto EAXSOURCE_DEFAULTROOMROLLOFFFACTOR = 0.0F; +inline constexpr auto EAXSOURCE_MINROOMROLLOFFFACTOR = 0.0F; +inline constexpr auto EAXSOURCE_MAXROOMROLLOFFFACTOR = 10.0F; +inline constexpr auto EAXSOURCE_DEFAULTROOMROLLOFFFACTOR = 0.0F; -constexpr auto EAXSOURCE_MINAIRABSORPTIONFACTOR = 0.0F; -constexpr auto EAXSOURCE_MAXAIRABSORPTIONFACTOR = 10.0F; -constexpr auto EAXSOURCE_DEFAULTAIRABSORPTIONFACTOR = 0.0F; +inline constexpr auto EAXSOURCE_MINAIRABSORPTIONFACTOR = 0.0F; +inline constexpr auto EAXSOURCE_MAXAIRABSORPTIONFACTOR = 10.0F; +inline constexpr auto EAXSOURCE_DEFAULTAIRABSORPTIONFACTOR = 0.0F; // EAX50 -constexpr auto EAXSOURCE_MINMACROFXFACTOR = 0.0F; -constexpr auto EAXSOURCE_MAXMACROFXFACTOR = 1.0F; -constexpr auto EAXSOURCE_DEFAULTMACROFXFACTOR = 1.0F; +inline constexpr auto EAXSOURCE_MINMACROFXFACTOR = 0.0F; +inline constexpr auto EAXSOURCE_MAXMACROFXFACTOR = 1.0F; +inline constexpr auto EAXSOURCE_DEFAULTMACROFXFACTOR = 1.0F; -constexpr auto EAXSOURCE_MINSPEAKERLEVEL = -10'000_eax_long; -constexpr auto EAXSOURCE_MAXSPEAKERLEVEL = 0_eax_long; -constexpr auto EAXSOURCE_DEFAULTSPEAKERLEVEL = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MINSPEAKERLEVEL = -10'000_eax_long; +inline constexpr auto EAXSOURCE_MAXSPEAKERLEVEL = 0_eax_long; +inline constexpr auto EAXSOURCE_DEFAULTSPEAKERLEVEL = -10'000_eax_long; -constexpr auto EAXSOURCE_DEFAULTFLAGS = +inline constexpr auto EAXSOURCE_DEFAULTFLAGS = EAXSOURCEFLAGS_DIRECTHFAUTO | EAXSOURCEFLAGS_ROOMAUTO | EAXSOURCEFLAGS_ROOMHFAUTO; @@ -608,7 +602,7 @@ enum : eax_long { // EAXSOURCEFLAGS_DIRECTHFAUTO, EAXSOURCEFLAGS_ROOMAUTO and EAXSOURCEFLAGS_ROOMHFAUTO are ignored for 2D sources // EAXSOURCEFLAGS_UPMIX is ignored for 3D sources -constexpr auto EAX50SOURCE_DEFAULTFLAGS = +inline constexpr auto EAX50SOURCE_DEFAULTFLAGS = EAXSOURCEFLAGS_DIRECTHFAUTO | EAXSOURCEFLAGS_ROOMAUTO | EAXSOURCEFLAGS_ROOMHFAUTO | @@ -673,33 +667,33 @@ struct EAXSPEAKERLEVELPROPERTIES { }; struct EAX40ACTIVEFXSLOTS { - std::array guidActiveFXSlots; + std::array guidActiveFXSlots; }; struct EAX50ACTIVEFXSLOTS { - std::array guidActiveFXSlots; + std::array guidActiveFXSlots; }; // Use this structure for EAXSOURCE_SENDPARAMETERS properties. struct EAXSOURCESENDPROPERTIES { - GUID guidReceivingFXSlotID; + AL_GUID guidReceivingFXSlotID; EAXSENDPROPERTIES mSend; }; // Use this structure for EAXSOURCE_OCCLUSIONSENDPARAMETERS struct EAXSOURCEOCCLUSIONSENDPROPERTIES { - GUID guidReceivingFXSlotID; + AL_GUID guidReceivingFXSlotID; EAXOCCLUSIONPROPERTIES mOcclusion; }; // Use this structure for EAXSOURCE_EXCLUSIONSENDPARAMETERS struct EAXSOURCEEXCLUSIONSENDPROPERTIES { - GUID guidReceivingFXSlotID; + AL_GUID guidReceivingFXSlotID; EAXEXCLUSIONPROPERTIES mExclusion; }; struct EAXSOURCEALLSENDPROPERTIES { - GUID guidReceivingFXSlotID; + AL_GUID guidReceivingFXSlotID; EAXSENDPROPERTIES mSend; EAXOCCLUSIONPROPERTIES mOcclusion; EAXEXCLUSIONPROPERTIES mExclusion; @@ -714,7 +708,7 @@ DECL_HIDDEN extern const EAX50ACTIVEFXSLOTS EAX50SOURCE_2DDEFAULTACTIVEFXSLOTID; // EAX Reverb Effect -DECL_HIDDEN extern const GUID EAX_REVERB_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_REVERB_EFFECT; // Reverb effect properties enum EAXREVERB_PROPERTY : unsigned { @@ -785,32 +779,32 @@ enum : eax_ulong { // reverberation decay time -constexpr auto EAXREVERBFLAGS_DECAYTIMESCALE = 0x00000001_eax_ulong; +inline constexpr auto EAXREVERBFLAGS_DECAYTIMESCALE = 0x00000001_eax_ulong; // reflection level -constexpr auto EAXREVERBFLAGS_REFLECTIONSSCALE = 0x00000002_eax_ulong; +inline constexpr auto EAXREVERBFLAGS_REFLECTIONSSCALE = 0x00000002_eax_ulong; // initial reflection delay time -constexpr auto EAXREVERBFLAGS_REFLECTIONSDELAYSCALE = 0x00000004_eax_ulong; +inline constexpr auto EAXREVERBFLAGS_REFLECTIONSDELAYSCALE = 0x00000004_eax_ulong; // reflections level -constexpr auto EAXREVERBFLAGS_REVERBSCALE = 0x00000008_eax_ulong; +inline constexpr auto EAXREVERBFLAGS_REVERBSCALE = 0x00000008_eax_ulong; // late reverberation delay time -constexpr auto EAXREVERBFLAGS_REVERBDELAYSCALE = 0x00000010_eax_ulong; +inline constexpr auto EAXREVERBFLAGS_REVERBDELAYSCALE = 0x00000010_eax_ulong; // echo time // EAX30+ -constexpr auto EAXREVERBFLAGS_ECHOTIMESCALE = 0x00000040_eax_ulong; +inline constexpr auto EAXREVERBFLAGS_ECHOTIMESCALE = 0x00000040_eax_ulong; // modulation time // EAX30+ -constexpr auto EAXREVERBFLAGS_MODULATIONTIMESCALE = 0x00000080_eax_ulong; +inline constexpr auto EAXREVERBFLAGS_MODULATIONTIMESCALE = 0x00000080_eax_ulong; // This flag limits high-frequency decay time according to air absorption. -constexpr auto EAXREVERBFLAGS_DECAYHFLIMIT = 0x00000020_eax_ulong; +inline constexpr auto EAXREVERBFLAGS_DECAYHFLIMIT = 0x00000020_eax_ulong; -constexpr auto EAXREVERBFLAGS_RESERVED = 0xFFFFFF00_eax_ulong; // reserved future use +inline constexpr auto EAXREVERBFLAGS_RESERVED = 0xFFFFFF00_eax_ulong; // reserved future use struct EAXREVERBPROPERTIES { @@ -845,102 +839,102 @@ struct EAXREVERBPROPERTIES { }; // EAXREVERBPROPERTIES -constexpr auto EAXREVERB_MINENVIRONMENT = eax_ulong{EAX_ENVIRONMENT_GENERIC}; -constexpr auto EAX1REVERB_MAXENVIRONMENT = eax_ulong{EAX_ENVIRONMENT_PSYCHOTIC}; -constexpr auto EAX30REVERB_MAXENVIRONMENT = eax_ulong{EAX_ENVIRONMENT_UNDEFINED}; -constexpr auto EAXREVERB_DEFAULTENVIRONMENT = eax_ulong{EAX_ENVIRONMENT_GENERIC}; +inline constexpr auto EAXREVERB_MINENVIRONMENT = eax_ulong{EAX_ENVIRONMENT_GENERIC}; +inline constexpr auto EAX1REVERB_MAXENVIRONMENT = eax_ulong{EAX_ENVIRONMENT_PSYCHOTIC}; +inline constexpr auto EAX30REVERB_MAXENVIRONMENT = eax_ulong{EAX_ENVIRONMENT_UNDEFINED}; +inline constexpr auto EAXREVERB_DEFAULTENVIRONMENT = eax_ulong{EAX_ENVIRONMENT_GENERIC}; -constexpr auto EAXREVERB_MINENVIRONMENTSIZE = 1.0F; -constexpr auto EAXREVERB_MAXENVIRONMENTSIZE = 100.0F; -constexpr auto EAXREVERB_DEFAULTENVIRONMENTSIZE = 7.5F; +inline constexpr auto EAXREVERB_MINENVIRONMENTSIZE = 1.0F; +inline constexpr auto EAXREVERB_MAXENVIRONMENTSIZE = 100.0F; +inline constexpr auto EAXREVERB_DEFAULTENVIRONMENTSIZE = 7.5F; -constexpr auto EAXREVERB_MINENVIRONMENTDIFFUSION = 0.0F; -constexpr auto EAXREVERB_MAXENVIRONMENTDIFFUSION = 1.0F; -constexpr auto EAXREVERB_DEFAULTENVIRONMENTDIFFUSION = 1.0F; +inline constexpr auto EAXREVERB_MINENVIRONMENTDIFFUSION = 0.0F; +inline constexpr auto EAXREVERB_MAXENVIRONMENTDIFFUSION = 1.0F; +inline constexpr auto EAXREVERB_DEFAULTENVIRONMENTDIFFUSION = 1.0F; -constexpr auto EAXREVERB_MINROOM = -10'000_eax_long; -constexpr auto EAXREVERB_MAXROOM = 0_eax_long; -constexpr auto EAXREVERB_DEFAULTROOM = -1'000_eax_long; +inline constexpr auto EAXREVERB_MINROOM = -10'000_eax_long; +inline constexpr auto EAXREVERB_MAXROOM = 0_eax_long; +inline constexpr auto EAXREVERB_DEFAULTROOM = -1'000_eax_long; -constexpr auto EAXREVERB_MINROOMHF = -10'000_eax_long; -constexpr auto EAXREVERB_MAXROOMHF = 0_eax_long; -constexpr auto EAXREVERB_DEFAULTROOMHF = -100_eax_long; +inline constexpr auto EAXREVERB_MINROOMHF = -10'000_eax_long; +inline constexpr auto EAXREVERB_MAXROOMHF = 0_eax_long; +inline constexpr auto EAXREVERB_DEFAULTROOMHF = -100_eax_long; -constexpr auto EAXREVERB_MINROOMLF = -10'000_eax_long; -constexpr auto EAXREVERB_MAXROOMLF = 0_eax_long; -constexpr auto EAXREVERB_DEFAULTROOMLF = 0_eax_long; +inline constexpr auto EAXREVERB_MINROOMLF = -10'000_eax_long; +inline constexpr auto EAXREVERB_MAXROOMLF = 0_eax_long; +inline constexpr auto EAXREVERB_DEFAULTROOMLF = 0_eax_long; -constexpr auto EAXREVERB_MINDECAYTIME = 0.1F; -constexpr auto EAXREVERB_MAXDECAYTIME = 20.0F; -constexpr auto EAXREVERB_DEFAULTDECAYTIME = 1.49F; +inline constexpr auto EAXREVERB_MINDECAYTIME = 0.1F; +inline constexpr auto EAXREVERB_MAXDECAYTIME = 20.0F; +inline constexpr auto EAXREVERB_DEFAULTDECAYTIME = 1.49F; -constexpr auto EAXREVERB_MINDECAYHFRATIO = 0.1F; -constexpr auto EAXREVERB_MAXDECAYHFRATIO = 2.0F; -constexpr auto EAXREVERB_DEFAULTDECAYHFRATIO = 0.83F; +inline constexpr auto EAXREVERB_MINDECAYHFRATIO = 0.1F; +inline constexpr auto EAXREVERB_MAXDECAYHFRATIO = 2.0F; +inline constexpr auto EAXREVERB_DEFAULTDECAYHFRATIO = 0.83F; -constexpr auto EAXREVERB_MINDECAYLFRATIO = 0.1F; -constexpr auto EAXREVERB_MAXDECAYLFRATIO = 2.0F; -constexpr auto EAXREVERB_DEFAULTDECAYLFRATIO = 1.0F; +inline constexpr auto EAXREVERB_MINDECAYLFRATIO = 0.1F; +inline constexpr auto EAXREVERB_MAXDECAYLFRATIO = 2.0F; +inline constexpr auto EAXREVERB_DEFAULTDECAYLFRATIO = 1.0F; -constexpr auto EAXREVERB_MINREFLECTIONS = -10'000_eax_long; -constexpr auto EAXREVERB_MAXREFLECTIONS = 1'000_eax_long; -constexpr auto EAXREVERB_DEFAULTREFLECTIONS = -2'602_eax_long; +inline constexpr auto EAXREVERB_MINREFLECTIONS = -10'000_eax_long; +inline constexpr auto EAXREVERB_MAXREFLECTIONS = 1'000_eax_long; +inline constexpr auto EAXREVERB_DEFAULTREFLECTIONS = -2'602_eax_long; -constexpr auto EAXREVERB_MINREFLECTIONSDELAY = 0.0F; -constexpr auto EAXREVERB_MAXREFLECTIONSDELAY = 0.3F; -constexpr auto EAXREVERB_DEFAULTREFLECTIONSDELAY = 0.007F; +inline constexpr auto EAXREVERB_MINREFLECTIONSDELAY = 0.0F; +inline constexpr auto EAXREVERB_MAXREFLECTIONSDELAY = 0.3F; +inline constexpr auto EAXREVERB_DEFAULTREFLECTIONSDELAY = 0.007F; -constexpr auto EAXREVERB_DEFAULTREFLECTIONSPAN = EAXVECTOR{0.0F, 0.0F, 0.0F}; +inline constexpr auto EAXREVERB_DEFAULTREFLECTIONSPAN = EAXVECTOR{0.0F, 0.0F, 0.0F}; -constexpr auto EAXREVERB_MINREVERB = -10'000_eax_long; -constexpr auto EAXREVERB_MAXREVERB = 2'000_eax_long; -constexpr auto EAXREVERB_DEFAULTREVERB = 200_eax_long; +inline constexpr auto EAXREVERB_MINREVERB = -10'000_eax_long; +inline constexpr auto EAXREVERB_MAXREVERB = 2'000_eax_long; +inline constexpr auto EAXREVERB_DEFAULTREVERB = 200_eax_long; -constexpr auto EAXREVERB_MINREVERBDELAY = 0.0F; -constexpr auto EAXREVERB_MAXREVERBDELAY = 0.1F; -constexpr auto EAXREVERB_DEFAULTREVERBDELAY = 0.011F; +inline constexpr auto EAXREVERB_MINREVERBDELAY = 0.0F; +inline constexpr auto EAXREVERB_MAXREVERBDELAY = 0.1F; +inline constexpr auto EAXREVERB_DEFAULTREVERBDELAY = 0.011F; -constexpr auto EAXREVERB_DEFAULTREVERBPAN = EAXVECTOR{0.0F, 0.0F, 0.0F}; +inline constexpr auto EAXREVERB_DEFAULTREVERBPAN = EAXVECTOR{0.0F, 0.0F, 0.0F}; -constexpr auto EAXREVERB_MINECHOTIME = 0.075F; -constexpr auto EAXREVERB_MAXECHOTIME = 0.25F; -constexpr auto EAXREVERB_DEFAULTECHOTIME = 0.25F; +inline constexpr auto EAXREVERB_MINECHOTIME = 0.075F; +inline constexpr auto EAXREVERB_MAXECHOTIME = 0.25F; +inline constexpr auto EAXREVERB_DEFAULTECHOTIME = 0.25F; -constexpr auto EAXREVERB_MINECHODEPTH = 0.0F; -constexpr auto EAXREVERB_MAXECHODEPTH = 1.0F; -constexpr auto EAXREVERB_DEFAULTECHODEPTH = 0.0F; +inline constexpr auto EAXREVERB_MINECHODEPTH = 0.0F; +inline constexpr auto EAXREVERB_MAXECHODEPTH = 1.0F; +inline constexpr auto EAXREVERB_DEFAULTECHODEPTH = 0.0F; -constexpr auto EAXREVERB_MINMODULATIONTIME = 0.04F; -constexpr auto EAXREVERB_MAXMODULATIONTIME = 4.0F; -constexpr auto EAXREVERB_DEFAULTMODULATIONTIME = 0.25F; +inline constexpr auto EAXREVERB_MINMODULATIONTIME = 0.04F; +inline constexpr auto EAXREVERB_MAXMODULATIONTIME = 4.0F; +inline constexpr auto EAXREVERB_DEFAULTMODULATIONTIME = 0.25F; -constexpr auto EAXREVERB_MINMODULATIONDEPTH = 0.0F; -constexpr auto EAXREVERB_MAXMODULATIONDEPTH = 1.0F; -constexpr auto EAXREVERB_DEFAULTMODULATIONDEPTH = 0.0F; +inline constexpr auto EAXREVERB_MINMODULATIONDEPTH = 0.0F; +inline constexpr auto EAXREVERB_MAXMODULATIONDEPTH = 1.0F; +inline constexpr auto EAXREVERB_DEFAULTMODULATIONDEPTH = 0.0F; -constexpr auto EAXREVERB_MINAIRABSORPTIONHF = -100.0F; -constexpr auto EAXREVERB_MAXAIRABSORPTIONHF = 0.0F; -constexpr auto EAXREVERB_DEFAULTAIRABSORPTIONHF = -5.0F; +inline constexpr auto EAXREVERB_MINAIRABSORPTIONHF = -100.0F; +inline constexpr auto EAXREVERB_MAXAIRABSORPTIONHF = 0.0F; +inline constexpr auto EAXREVERB_DEFAULTAIRABSORPTIONHF = -5.0F; -constexpr auto EAXREVERB_MINHFREFERENCE = 1'000.0F; -constexpr auto EAXREVERB_MAXHFREFERENCE = 20'000.0F; -constexpr auto EAXREVERB_DEFAULTHFREFERENCE = 5'000.0F; +inline constexpr auto EAXREVERB_MINHFREFERENCE = 1'000.0F; +inline constexpr auto EAXREVERB_MAXHFREFERENCE = 20'000.0F; +inline constexpr auto EAXREVERB_DEFAULTHFREFERENCE = 5'000.0F; -constexpr auto EAXREVERB_MINLFREFERENCE = 20.0F; -constexpr auto EAXREVERB_MAXLFREFERENCE = 1'000.0F; -constexpr auto EAXREVERB_DEFAULTLFREFERENCE = 250.0F; +inline constexpr auto EAXREVERB_MINLFREFERENCE = 20.0F; +inline constexpr auto EAXREVERB_MAXLFREFERENCE = 1'000.0F; +inline constexpr auto EAXREVERB_DEFAULTLFREFERENCE = 250.0F; -constexpr auto EAXREVERB_MINROOMROLLOFFFACTOR = 0.0F; -constexpr auto EAXREVERB_MAXROOMROLLOFFFACTOR = 10.0F; -constexpr auto EAXREVERB_DEFAULTROOMROLLOFFFACTOR = 0.0F; +inline constexpr auto EAXREVERB_MINROOMROLLOFFFACTOR = 0.0F; +inline constexpr auto EAXREVERB_MAXROOMROLLOFFFACTOR = 10.0F; +inline constexpr auto EAXREVERB_DEFAULTROOMROLLOFFFACTOR = 0.0F; -constexpr auto EAX1REVERB_MINVOLUME = 0.0F; -constexpr auto EAX1REVERB_MAXVOLUME = 1.0F; +inline constexpr auto EAX1REVERB_MINVOLUME = 0.0F; +inline constexpr auto EAX1REVERB_MAXVOLUME = 1.0F; -constexpr auto EAX1REVERB_MINDAMPING = 0.0F; -constexpr auto EAX1REVERB_MAXDAMPING = 2.0F; +inline constexpr auto EAX1REVERB_MINDAMPING = 0.0F; +inline constexpr auto EAX1REVERB_MAXDAMPING = 2.0F; -constexpr auto EAXREVERB_DEFAULTFLAGS = +inline constexpr auto EAXREVERB_DEFAULTFLAGS = EAXREVERBFLAGS_DECAYTIMESCALE | EAXREVERBFLAGS_REFLECTIONSSCALE | EAXREVERBFLAGS_REFLECTIONSDELAYSCALE | @@ -961,7 +955,7 @@ DECL_HIDDEN extern const EaxReverbPresets EAXREVERB_PRESETS; // AGC Compressor Effect -DECL_HIDDEN extern const GUID EAX_AGCCOMPRESSOR_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_AGCCOMPRESSOR_EFFECT; enum EAXAGCCOMPRESSOR_PROPERTY : unsigned { EAXAGCCOMPRESSOR_NONE, @@ -978,14 +972,14 @@ struct EAXAGCCOMPRESSORPROPERTIES { }; // EAXAGCCOMPRESSORPROPERTIES -constexpr auto EAXAGCCOMPRESSOR_MINONOFF = 0_eax_ulong; -constexpr auto EAXAGCCOMPRESSOR_MAXONOFF = 1_eax_ulong; -constexpr auto EAXAGCCOMPRESSOR_DEFAULTONOFF = EAXAGCCOMPRESSOR_MAXONOFF; +inline constexpr auto EAXAGCCOMPRESSOR_MINONOFF = 0_eax_ulong; +inline constexpr auto EAXAGCCOMPRESSOR_MAXONOFF = 1_eax_ulong; +inline constexpr auto EAXAGCCOMPRESSOR_DEFAULTONOFF = EAXAGCCOMPRESSOR_MAXONOFF; // Autowah Effect -DECL_HIDDEN extern const GUID EAX_AUTOWAH_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_AUTOWAH_EFFECT; enum EAXAUTOWAH_PROPERTY : unsigned { EAXAUTOWAH_NONE, @@ -1008,26 +1002,26 @@ struct EAXAUTOWAHPROPERTIES { }; // EAXAUTOWAHPROPERTIES -constexpr auto EAXAUTOWAH_MINATTACKTIME = 0.0001F; -constexpr auto EAXAUTOWAH_MAXATTACKTIME = 1.0F; -constexpr auto EAXAUTOWAH_DEFAULTATTACKTIME = 0.06F; +inline constexpr auto EAXAUTOWAH_MINATTACKTIME = 0.0001F; +inline constexpr auto EAXAUTOWAH_MAXATTACKTIME = 1.0F; +inline constexpr auto EAXAUTOWAH_DEFAULTATTACKTIME = 0.06F; -constexpr auto EAXAUTOWAH_MINRELEASETIME = 0.0001F; -constexpr auto EAXAUTOWAH_MAXRELEASETIME = 1.0F; -constexpr auto EAXAUTOWAH_DEFAULTRELEASETIME = 0.06F; +inline constexpr auto EAXAUTOWAH_MINRELEASETIME = 0.0001F; +inline constexpr auto EAXAUTOWAH_MAXRELEASETIME = 1.0F; +inline constexpr auto EAXAUTOWAH_DEFAULTRELEASETIME = 0.06F; -constexpr auto EAXAUTOWAH_MINRESONANCE = 600_eax_long; -constexpr auto EAXAUTOWAH_MAXRESONANCE = 6000_eax_long; -constexpr auto EAXAUTOWAH_DEFAULTRESONANCE = 6000_eax_long; +inline constexpr auto EAXAUTOWAH_MINRESONANCE = 600_eax_long; +inline constexpr auto EAXAUTOWAH_MAXRESONANCE = 6000_eax_long; +inline constexpr auto EAXAUTOWAH_DEFAULTRESONANCE = 6000_eax_long; -constexpr auto EAXAUTOWAH_MINPEAKLEVEL = -9000_eax_long; -constexpr auto EAXAUTOWAH_MAXPEAKLEVEL = 9000_eax_long; -constexpr auto EAXAUTOWAH_DEFAULTPEAKLEVEL = 2100_eax_long; +inline constexpr auto EAXAUTOWAH_MINPEAKLEVEL = -9000_eax_long; +inline constexpr auto EAXAUTOWAH_MAXPEAKLEVEL = 9000_eax_long; +inline constexpr auto EAXAUTOWAH_DEFAULTPEAKLEVEL = 2100_eax_long; // Chorus Effect -DECL_HIDDEN extern const GUID EAX_CHORUS_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_CHORUS_EFFECT; enum EAXCHORUS_PROPERTY : unsigned { EAXCHORUS_NONE, @@ -1059,34 +1053,34 @@ struct EAXCHORUSPROPERTIES { }; // EAXCHORUSPROPERTIES -constexpr auto EAXCHORUS_MINWAVEFORM = 0_eax_ulong; -constexpr auto EAXCHORUS_MAXWAVEFORM = 1_eax_ulong; -constexpr auto EAXCHORUS_DEFAULTWAVEFORM = 1_eax_ulong; +inline constexpr auto EAXCHORUS_MINWAVEFORM = 0_eax_ulong; +inline constexpr auto EAXCHORUS_MAXWAVEFORM = 1_eax_ulong; +inline constexpr auto EAXCHORUS_DEFAULTWAVEFORM = 1_eax_ulong; -constexpr auto EAXCHORUS_MINPHASE = -180_eax_long; -constexpr auto EAXCHORUS_MAXPHASE = 180_eax_long; -constexpr auto EAXCHORUS_DEFAULTPHASE = 90_eax_long; +inline constexpr auto EAXCHORUS_MINPHASE = -180_eax_long; +inline constexpr auto EAXCHORUS_MAXPHASE = 180_eax_long; +inline constexpr auto EAXCHORUS_DEFAULTPHASE = 90_eax_long; -constexpr auto EAXCHORUS_MINRATE = 0.0F; -constexpr auto EAXCHORUS_MAXRATE = 10.0F; -constexpr auto EAXCHORUS_DEFAULTRATE = 1.1F; +inline constexpr auto EAXCHORUS_MINRATE = 0.0F; +inline constexpr auto EAXCHORUS_MAXRATE = 10.0F; +inline constexpr auto EAXCHORUS_DEFAULTRATE = 1.1F; -constexpr auto EAXCHORUS_MINDEPTH = 0.0F; -constexpr auto EAXCHORUS_MAXDEPTH = 1.0F; -constexpr auto EAXCHORUS_DEFAULTDEPTH = 0.1F; +inline constexpr auto EAXCHORUS_MINDEPTH = 0.0F; +inline constexpr auto EAXCHORUS_MAXDEPTH = 1.0F; +inline constexpr auto EAXCHORUS_DEFAULTDEPTH = 0.1F; -constexpr auto EAXCHORUS_MINFEEDBACK = -1.0F; -constexpr auto EAXCHORUS_MAXFEEDBACK = 1.0F; -constexpr auto EAXCHORUS_DEFAULTFEEDBACK = 0.25F; +inline constexpr auto EAXCHORUS_MINFEEDBACK = -1.0F; +inline constexpr auto EAXCHORUS_MAXFEEDBACK = 1.0F; +inline constexpr auto EAXCHORUS_DEFAULTFEEDBACK = 0.25F; -constexpr auto EAXCHORUS_MINDELAY = 0.0002F; -constexpr auto EAXCHORUS_MAXDELAY = 0.016F; -constexpr auto EAXCHORUS_DEFAULTDELAY = 0.016F; +inline constexpr auto EAXCHORUS_MINDELAY = 0.0002F; +inline constexpr auto EAXCHORUS_MAXDELAY = 0.016F; +inline constexpr auto EAXCHORUS_DEFAULTDELAY = 0.016F; // Distortion Effect -DECL_HIDDEN extern const GUID EAX_DISTORTION_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_DISTORTION_EFFECT; enum EAXDISTORTION_PROPERTY : unsigned { EAXDISTORTION_NONE, @@ -1111,30 +1105,30 @@ struct EAXDISTORTIONPROPERTIES { }; // EAXDISTORTIONPROPERTIES -constexpr auto EAXDISTORTION_MINEDGE = 0.0F; -constexpr auto EAXDISTORTION_MAXEDGE = 1.0F; -constexpr auto EAXDISTORTION_DEFAULTEDGE = 0.2F; +inline constexpr auto EAXDISTORTION_MINEDGE = 0.0F; +inline constexpr auto EAXDISTORTION_MAXEDGE = 1.0F; +inline constexpr auto EAXDISTORTION_DEFAULTEDGE = 0.2F; -constexpr auto EAXDISTORTION_MINGAIN = -6000_eax_long; -constexpr auto EAXDISTORTION_MAXGAIN = 0_eax_long; -constexpr auto EAXDISTORTION_DEFAULTGAIN = -2600_eax_long; +inline constexpr auto EAXDISTORTION_MINGAIN = -6000_eax_long; +inline constexpr auto EAXDISTORTION_MAXGAIN = 0_eax_long; +inline constexpr auto EAXDISTORTION_DEFAULTGAIN = -2600_eax_long; -constexpr auto EAXDISTORTION_MINLOWPASSCUTOFF = 80.0F; -constexpr auto EAXDISTORTION_MAXLOWPASSCUTOFF = 24000.0F; -constexpr auto EAXDISTORTION_DEFAULTLOWPASSCUTOFF = 8000.0F; +inline constexpr auto EAXDISTORTION_MINLOWPASSCUTOFF = 80.0F; +inline constexpr auto EAXDISTORTION_MAXLOWPASSCUTOFF = 24000.0F; +inline constexpr auto EAXDISTORTION_DEFAULTLOWPASSCUTOFF = 8000.0F; -constexpr auto EAXDISTORTION_MINEQCENTER = 80.0F; -constexpr auto EAXDISTORTION_MAXEQCENTER = 24000.0F; -constexpr auto EAXDISTORTION_DEFAULTEQCENTER = 3600.0F; +inline constexpr auto EAXDISTORTION_MINEQCENTER = 80.0F; +inline constexpr auto EAXDISTORTION_MAXEQCENTER = 24000.0F; +inline constexpr auto EAXDISTORTION_DEFAULTEQCENTER = 3600.0F; -constexpr auto EAXDISTORTION_MINEQBANDWIDTH = 80.0F; -constexpr auto EAXDISTORTION_MAXEQBANDWIDTH = 24000.0F; -constexpr auto EAXDISTORTION_DEFAULTEQBANDWIDTH = 3600.0F; +inline constexpr auto EAXDISTORTION_MINEQBANDWIDTH = 80.0F; +inline constexpr auto EAXDISTORTION_MAXEQBANDWIDTH = 24000.0F; +inline constexpr auto EAXDISTORTION_DEFAULTEQBANDWIDTH = 3600.0F; // Echo Effect -DECL_HIDDEN extern const GUID EAX_ECHO_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_ECHO_EFFECT; enum EAXECHO_PROPERTY : unsigned { EAXECHO_NONE, @@ -1159,30 +1153,30 @@ struct EAXECHOPROPERTIES { }; // EAXECHOPROPERTIES -constexpr auto EAXECHO_MINDAMPING = 0.0F; -constexpr auto EAXECHO_MAXDAMPING = 0.99F; -constexpr auto EAXECHO_DEFAULTDAMPING = 0.5F; +inline constexpr auto EAXECHO_MINDAMPING = 0.0F; +inline constexpr auto EAXECHO_MAXDAMPING = 0.99F; +inline constexpr auto EAXECHO_DEFAULTDAMPING = 0.5F; -constexpr auto EAXECHO_MINDELAY = 0.002F; -constexpr auto EAXECHO_MAXDELAY = 0.207F; -constexpr auto EAXECHO_DEFAULTDELAY = 0.1F; +inline constexpr auto EAXECHO_MINDELAY = 0.002F; +inline constexpr auto EAXECHO_MAXDELAY = 0.207F; +inline constexpr auto EAXECHO_DEFAULTDELAY = 0.1F; -constexpr auto EAXECHO_MINLRDELAY = 0.0F; -constexpr auto EAXECHO_MAXLRDELAY = 0.404F; -constexpr auto EAXECHO_DEFAULTLRDELAY = 0.1F; +inline constexpr auto EAXECHO_MINLRDELAY = 0.0F; +inline constexpr auto EAXECHO_MAXLRDELAY = 0.404F; +inline constexpr auto EAXECHO_DEFAULTLRDELAY = 0.1F; -constexpr auto EAXECHO_MINFEEDBACK = 0.0F; -constexpr auto EAXECHO_MAXFEEDBACK = 1.0F; -constexpr auto EAXECHO_DEFAULTFEEDBACK = 0.5F; +inline constexpr auto EAXECHO_MINFEEDBACK = 0.0F; +inline constexpr auto EAXECHO_MAXFEEDBACK = 1.0F; +inline constexpr auto EAXECHO_DEFAULTFEEDBACK = 0.5F; -constexpr auto EAXECHO_MINSPREAD = -1.0F; -constexpr auto EAXECHO_MAXSPREAD = 1.0F; -constexpr auto EAXECHO_DEFAULTSPREAD = -1.0F; +inline constexpr auto EAXECHO_MINSPREAD = -1.0F; +inline constexpr auto EAXECHO_MAXSPREAD = 1.0F; +inline constexpr auto EAXECHO_DEFAULTSPREAD = -1.0F; // Equalizer Effect -DECL_HIDDEN extern const GUID EAX_EQUALIZER_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_EQUALIZER_EFFECT; enum EAXEQUALIZER_PROPERTY : unsigned { EAXEQUALIZER_NONE, @@ -1217,50 +1211,50 @@ struct EAXEQUALIZERPROPERTIES { }; // EAXEQUALIZERPROPERTIES -constexpr auto EAXEQUALIZER_MINLOWGAIN = -1800_eax_long; -constexpr auto EAXEQUALIZER_MAXLOWGAIN = 1800_eax_long; -constexpr auto EAXEQUALIZER_DEFAULTLOWGAIN = 0_eax_long; +inline constexpr auto EAXEQUALIZER_MINLOWGAIN = -1800_eax_long; +inline constexpr auto EAXEQUALIZER_MAXLOWGAIN = 1800_eax_long; +inline constexpr auto EAXEQUALIZER_DEFAULTLOWGAIN = 0_eax_long; -constexpr auto EAXEQUALIZER_MINLOWCUTOFF = 50.0F; -constexpr auto EAXEQUALIZER_MAXLOWCUTOFF = 800.0F; -constexpr auto EAXEQUALIZER_DEFAULTLOWCUTOFF = 200.0F; +inline constexpr auto EAXEQUALIZER_MINLOWCUTOFF = 50.0F; +inline constexpr auto EAXEQUALIZER_MAXLOWCUTOFF = 800.0F; +inline constexpr auto EAXEQUALIZER_DEFAULTLOWCUTOFF = 200.0F; -constexpr auto EAXEQUALIZER_MINMID1GAIN = -1800_eax_long; -constexpr auto EAXEQUALIZER_MAXMID1GAIN = 1800_eax_long; -constexpr auto EAXEQUALIZER_DEFAULTMID1GAIN = 0_eax_long; +inline constexpr auto EAXEQUALIZER_MINMID1GAIN = -1800_eax_long; +inline constexpr auto EAXEQUALIZER_MAXMID1GAIN = 1800_eax_long; +inline constexpr auto EAXEQUALIZER_DEFAULTMID1GAIN = 0_eax_long; -constexpr auto EAXEQUALIZER_MINMID1CENTER = 200.0F; -constexpr auto EAXEQUALIZER_MAXMID1CENTER = 3000.0F; -constexpr auto EAXEQUALIZER_DEFAULTMID1CENTER = 500.0F; +inline constexpr auto EAXEQUALIZER_MINMID1CENTER = 200.0F; +inline constexpr auto EAXEQUALIZER_MAXMID1CENTER = 3000.0F; +inline constexpr auto EAXEQUALIZER_DEFAULTMID1CENTER = 500.0F; -constexpr auto EAXEQUALIZER_MINMID1WIDTH = 0.01F; -constexpr auto EAXEQUALIZER_MAXMID1WIDTH = 1.0F; -constexpr auto EAXEQUALIZER_DEFAULTMID1WIDTH = 1.0F; +inline constexpr auto EAXEQUALIZER_MINMID1WIDTH = 0.01F; +inline constexpr auto EAXEQUALIZER_MAXMID1WIDTH = 1.0F; +inline constexpr auto EAXEQUALIZER_DEFAULTMID1WIDTH = 1.0F; -constexpr auto EAXEQUALIZER_MINMID2GAIN = -1800_eax_long; -constexpr auto EAXEQUALIZER_MAXMID2GAIN = 1800_eax_long; -constexpr auto EAXEQUALIZER_DEFAULTMID2GAIN = 0_eax_long; +inline constexpr auto EAXEQUALIZER_MINMID2GAIN = -1800_eax_long; +inline constexpr auto EAXEQUALIZER_MAXMID2GAIN = 1800_eax_long; +inline constexpr auto EAXEQUALIZER_DEFAULTMID2GAIN = 0_eax_long; -constexpr auto EAXEQUALIZER_MINMID2CENTER = 1000.0F; -constexpr auto EAXEQUALIZER_MAXMID2CENTER = 8000.0F; -constexpr auto EAXEQUALIZER_DEFAULTMID2CENTER = 3000.0F; +inline constexpr auto EAXEQUALIZER_MINMID2CENTER = 1000.0F; +inline constexpr auto EAXEQUALIZER_MAXMID2CENTER = 8000.0F; +inline constexpr auto EAXEQUALIZER_DEFAULTMID2CENTER = 3000.0F; -constexpr auto EAXEQUALIZER_MINMID2WIDTH = 0.01F; -constexpr auto EAXEQUALIZER_MAXMID2WIDTH = 1.0F; -constexpr auto EAXEQUALIZER_DEFAULTMID2WIDTH = 1.0F; +inline constexpr auto EAXEQUALIZER_MINMID2WIDTH = 0.01F; +inline constexpr auto EAXEQUALIZER_MAXMID2WIDTH = 1.0F; +inline constexpr auto EAXEQUALIZER_DEFAULTMID2WIDTH = 1.0F; -constexpr auto EAXEQUALIZER_MINHIGHGAIN = -1800_eax_long; -constexpr auto EAXEQUALIZER_MAXHIGHGAIN = 1800_eax_long; -constexpr auto EAXEQUALIZER_DEFAULTHIGHGAIN = 0_eax_long; +inline constexpr auto EAXEQUALIZER_MINHIGHGAIN = -1800_eax_long; +inline constexpr auto EAXEQUALIZER_MAXHIGHGAIN = 1800_eax_long; +inline constexpr auto EAXEQUALIZER_DEFAULTHIGHGAIN = 0_eax_long; -constexpr auto EAXEQUALIZER_MINHIGHCUTOFF = 4000.0F; -constexpr auto EAXEQUALIZER_MAXHIGHCUTOFF = 16000.0F; -constexpr auto EAXEQUALIZER_DEFAULTHIGHCUTOFF = 6000.0F; +inline constexpr auto EAXEQUALIZER_MINHIGHCUTOFF = 4000.0F; +inline constexpr auto EAXEQUALIZER_MAXHIGHCUTOFF = 16000.0F; +inline constexpr auto EAXEQUALIZER_DEFAULTHIGHCUTOFF = 6000.0F; // Flanger Effect -DECL_HIDDEN extern const GUID EAX_FLANGER_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_FLANGER_EFFECT; enum EAXFLANGER_PROPERTY : unsigned { EAXFLANGER_NONE, @@ -1292,34 +1286,34 @@ struct EAXFLANGERPROPERTIES { }; // EAXFLANGERPROPERTIES -constexpr auto EAXFLANGER_MINWAVEFORM = 0_eax_ulong; -constexpr auto EAXFLANGER_MAXWAVEFORM = 1_eax_ulong; -constexpr auto EAXFLANGER_DEFAULTWAVEFORM = 1_eax_ulong; +inline constexpr auto EAXFLANGER_MINWAVEFORM = 0_eax_ulong; +inline constexpr auto EAXFLANGER_MAXWAVEFORM = 1_eax_ulong; +inline constexpr auto EAXFLANGER_DEFAULTWAVEFORM = 1_eax_ulong; -constexpr auto EAXFLANGER_MINPHASE = -180_eax_long; -constexpr auto EAXFLANGER_MAXPHASE = 180_eax_long; -constexpr auto EAXFLANGER_DEFAULTPHASE = 0_eax_long; +inline constexpr auto EAXFLANGER_MINPHASE = -180_eax_long; +inline constexpr auto EAXFLANGER_MAXPHASE = 180_eax_long; +inline constexpr auto EAXFLANGER_DEFAULTPHASE = 0_eax_long; -constexpr auto EAXFLANGER_MINRATE = 0.0F; -constexpr auto EAXFLANGER_MAXRATE = 10.0F; -constexpr auto EAXFLANGER_DEFAULTRATE = 0.27F; +inline constexpr auto EAXFLANGER_MINRATE = 0.0F; +inline constexpr auto EAXFLANGER_MAXRATE = 10.0F; +inline constexpr auto EAXFLANGER_DEFAULTRATE = 0.27F; -constexpr auto EAXFLANGER_MINDEPTH = 0.0F; -constexpr auto EAXFLANGER_MAXDEPTH = 1.0F; -constexpr auto EAXFLANGER_DEFAULTDEPTH = 1.0F; +inline constexpr auto EAXFLANGER_MINDEPTH = 0.0F; +inline constexpr auto EAXFLANGER_MAXDEPTH = 1.0F; +inline constexpr auto EAXFLANGER_DEFAULTDEPTH = 1.0F; -constexpr auto EAXFLANGER_MINFEEDBACK = -1.0F; -constexpr auto EAXFLANGER_MAXFEEDBACK = 1.0F; -constexpr auto EAXFLANGER_DEFAULTFEEDBACK = -0.5F; +inline constexpr auto EAXFLANGER_MINFEEDBACK = -1.0F; +inline constexpr auto EAXFLANGER_MAXFEEDBACK = 1.0F; +inline constexpr auto EAXFLANGER_DEFAULTFEEDBACK = -0.5F; -constexpr auto EAXFLANGER_MINDELAY = 0.0002F; -constexpr auto EAXFLANGER_MAXDELAY = 0.004F; -constexpr auto EAXFLANGER_DEFAULTDELAY = 0.002F; +inline constexpr auto EAXFLANGER_MINDELAY = 0.0002F; +inline constexpr auto EAXFLANGER_MAXDELAY = 0.004F; +inline constexpr auto EAXFLANGER_DEFAULTDELAY = 0.002F; // Frequency Shifter Effect -DECL_HIDDEN extern const GUID EAX_FREQUENCYSHIFTER_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_FREQUENCYSHIFTER_EFFECT; enum EAXFREQUENCYSHIFTER_PROPERTY : unsigned { EAXFREQUENCYSHIFTER_NONE, @@ -1346,22 +1340,22 @@ struct EAXFREQUENCYSHIFTERPROPERTIES { }; // EAXFREQUENCYSHIFTERPROPERTIES -constexpr auto EAXFREQUENCYSHIFTER_MINFREQUENCY = 0.0F; -constexpr auto EAXFREQUENCYSHIFTER_MAXFREQUENCY = 24000.0F; -constexpr auto EAXFREQUENCYSHIFTER_DEFAULTFREQUENCY = EAXFREQUENCYSHIFTER_MINFREQUENCY; +inline constexpr auto EAXFREQUENCYSHIFTER_MINFREQUENCY = 0.0F; +inline constexpr auto EAXFREQUENCYSHIFTER_MAXFREQUENCY = 24000.0F; +inline constexpr auto EAXFREQUENCYSHIFTER_DEFAULTFREQUENCY = EAXFREQUENCYSHIFTER_MINFREQUENCY; -constexpr auto EAXFREQUENCYSHIFTER_MINLEFTDIRECTION = 0_eax_ulong; -constexpr auto EAXFREQUENCYSHIFTER_MAXLEFTDIRECTION = 2_eax_ulong; -constexpr auto EAXFREQUENCYSHIFTER_DEFAULTLEFTDIRECTION = EAXFREQUENCYSHIFTER_MINLEFTDIRECTION; +inline constexpr auto EAXFREQUENCYSHIFTER_MINLEFTDIRECTION = 0_eax_ulong; +inline constexpr auto EAXFREQUENCYSHIFTER_MAXLEFTDIRECTION = 2_eax_ulong; +inline constexpr auto EAXFREQUENCYSHIFTER_DEFAULTLEFTDIRECTION = EAXFREQUENCYSHIFTER_MINLEFTDIRECTION; -constexpr auto EAXFREQUENCYSHIFTER_MINRIGHTDIRECTION = 0_eax_ulong; -constexpr auto EAXFREQUENCYSHIFTER_MAXRIGHTDIRECTION = 2_eax_ulong; -constexpr auto EAXFREQUENCYSHIFTER_DEFAULTRIGHTDIRECTION = EAXFREQUENCYSHIFTER_MINRIGHTDIRECTION; +inline constexpr auto EAXFREQUENCYSHIFTER_MINRIGHTDIRECTION = 0_eax_ulong; +inline constexpr auto EAXFREQUENCYSHIFTER_MAXRIGHTDIRECTION = 2_eax_ulong; +inline constexpr auto EAXFREQUENCYSHIFTER_DEFAULTRIGHTDIRECTION = EAXFREQUENCYSHIFTER_MINRIGHTDIRECTION; // Vocal Morpher Effect -DECL_HIDDEN extern const GUID EAX_VOCALMORPHER_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_VOCALMORPHER_EFFECT; enum EAXVOCALMORPHER_PROPERTY : unsigned { EAXVOCALMORPHER_NONE, @@ -1428,34 +1422,34 @@ struct EAXVOCALMORPHERPROPERTIES { }; // EAXVOCALMORPHERPROPERTIES -constexpr auto EAXVOCALMORPHER_MINPHONEMEA = 0_eax_ulong; -constexpr auto EAXVOCALMORPHER_MAXPHONEMEA = 29_eax_ulong; -constexpr auto EAXVOCALMORPHER_DEFAULTPHONEMEA = EAXVOCALMORPHER_MINPHONEMEA; +inline constexpr auto EAXVOCALMORPHER_MINPHONEMEA = 0_eax_ulong; +inline constexpr auto EAXVOCALMORPHER_MAXPHONEMEA = 29_eax_ulong; +inline constexpr auto EAXVOCALMORPHER_DEFAULTPHONEMEA = EAXVOCALMORPHER_MINPHONEMEA; -constexpr auto EAXVOCALMORPHER_MINPHONEMEACOARSETUNING = -24_eax_long; -constexpr auto EAXVOCALMORPHER_MAXPHONEMEACOARSETUNING = 24_eax_long; -constexpr auto EAXVOCALMORPHER_DEFAULTPHONEMEACOARSETUNING = 0_eax_long; +inline constexpr auto EAXVOCALMORPHER_MINPHONEMEACOARSETUNING = -24_eax_long; +inline constexpr auto EAXVOCALMORPHER_MAXPHONEMEACOARSETUNING = 24_eax_long; +inline constexpr auto EAXVOCALMORPHER_DEFAULTPHONEMEACOARSETUNING = 0_eax_long; -constexpr auto EAXVOCALMORPHER_MINPHONEMEB = 0_eax_ulong; -constexpr auto EAXVOCALMORPHER_MAXPHONEMEB = 29_eax_ulong; -constexpr auto EAXVOCALMORPHER_DEFAULTPHONEMEB = 10_eax_ulong; +inline constexpr auto EAXVOCALMORPHER_MINPHONEMEB = 0_eax_ulong; +inline constexpr auto EAXVOCALMORPHER_MAXPHONEMEB = 29_eax_ulong; +inline constexpr auto EAXVOCALMORPHER_DEFAULTPHONEMEB = 10_eax_ulong; -constexpr auto EAXVOCALMORPHER_MINPHONEMEBCOARSETUNING = -24_eax_long; -constexpr auto EAXVOCALMORPHER_MAXPHONEMEBCOARSETUNING = 24_eax_long; -constexpr auto EAXVOCALMORPHER_DEFAULTPHONEMEBCOARSETUNING = 0_eax_long; +inline constexpr auto EAXVOCALMORPHER_MINPHONEMEBCOARSETUNING = -24_eax_long; +inline constexpr auto EAXVOCALMORPHER_MAXPHONEMEBCOARSETUNING = 24_eax_long; +inline constexpr auto EAXVOCALMORPHER_DEFAULTPHONEMEBCOARSETUNING = 0_eax_long; -constexpr auto EAXVOCALMORPHER_MINWAVEFORM = 0_eax_ulong; -constexpr auto EAXVOCALMORPHER_MAXWAVEFORM = 2_eax_ulong; -constexpr auto EAXVOCALMORPHER_DEFAULTWAVEFORM = EAXVOCALMORPHER_MINWAVEFORM; +inline constexpr auto EAXVOCALMORPHER_MINWAVEFORM = 0_eax_ulong; +inline constexpr auto EAXVOCALMORPHER_MAXWAVEFORM = 2_eax_ulong; +inline constexpr auto EAXVOCALMORPHER_DEFAULTWAVEFORM = EAXVOCALMORPHER_MINWAVEFORM; -constexpr auto EAXVOCALMORPHER_MINRATE = 0.0F; -constexpr auto EAXVOCALMORPHER_MAXRATE = 10.0F; -constexpr auto EAXVOCALMORPHER_DEFAULTRATE = 1.41F; +inline constexpr auto EAXVOCALMORPHER_MINRATE = 0.0F; +inline constexpr auto EAXVOCALMORPHER_MAXRATE = 10.0F; +inline constexpr auto EAXVOCALMORPHER_DEFAULTRATE = 1.41F; // Pitch Shifter Effect -DECL_HIDDEN extern const GUID EAX_PITCHSHIFTER_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_PITCHSHIFTER_EFFECT; enum EAXPITCHSHIFTER_PROPERTY : unsigned { EAXPITCHSHIFTER_NONE, @@ -1474,18 +1468,18 @@ struct EAXPITCHSHIFTERPROPERTIES { }; // EAXPITCHSHIFTERPROPERTIES -constexpr auto EAXPITCHSHIFTER_MINCOARSETUNE = -12_eax_long; -constexpr auto EAXPITCHSHIFTER_MAXCOARSETUNE = 12_eax_long; -constexpr auto EAXPITCHSHIFTER_DEFAULTCOARSETUNE = 12_eax_long; +inline constexpr auto EAXPITCHSHIFTER_MINCOARSETUNE = -12_eax_long; +inline constexpr auto EAXPITCHSHIFTER_MAXCOARSETUNE = 12_eax_long; +inline constexpr auto EAXPITCHSHIFTER_DEFAULTCOARSETUNE = 12_eax_long; -constexpr auto EAXPITCHSHIFTER_MINFINETUNE = -50_eax_long; -constexpr auto EAXPITCHSHIFTER_MAXFINETUNE = 50_eax_long; -constexpr auto EAXPITCHSHIFTER_DEFAULTFINETUNE = 0_eax_long; +inline constexpr auto EAXPITCHSHIFTER_MINFINETUNE = -50_eax_long; +inline constexpr auto EAXPITCHSHIFTER_MAXFINETUNE = 50_eax_long; +inline constexpr auto EAXPITCHSHIFTER_DEFAULTFINETUNE = 0_eax_long; // Ring Modulator Effect -DECL_HIDDEN extern const GUID EAX_RINGMODULATOR_EFFECT; +DECL_HIDDEN extern const AL_GUID EAX_RINGMODULATOR_EFFECT; enum EAXRINGMODULATOR_PROPERTY : unsigned { EAXRINGMODULATOR_NONE, @@ -1513,31 +1507,27 @@ struct EAXRINGMODULATORPROPERTIES { }; // EAXRINGMODULATORPROPERTIES -constexpr auto EAXRINGMODULATOR_MINFREQUENCY = 0.0F; -constexpr auto EAXRINGMODULATOR_MAXFREQUENCY = 8000.0F; -constexpr auto EAXRINGMODULATOR_DEFAULTFREQUENCY = 440.0F; +inline constexpr auto EAXRINGMODULATOR_MINFREQUENCY = 0.0F; +inline constexpr auto EAXRINGMODULATOR_MAXFREQUENCY = 8000.0F; +inline constexpr auto EAXRINGMODULATOR_DEFAULTFREQUENCY = 440.0F; + +inline constexpr auto EAXRINGMODULATOR_MINHIGHPASSCUTOFF = 0.0F; +inline constexpr auto EAXRINGMODULATOR_MAXHIGHPASSCUTOFF = 24000.0F; +inline constexpr auto EAXRINGMODULATOR_DEFAULTHIGHPASSCUTOFF = 800.0F; -constexpr auto EAXRINGMODULATOR_MINHIGHPASSCUTOFF = 0.0F; -constexpr auto EAXRINGMODULATOR_MAXHIGHPASSCUTOFF = 24000.0F; -constexpr auto EAXRINGMODULATOR_DEFAULTHIGHPASSCUTOFF = 800.0F; +inline constexpr auto EAXRINGMODULATOR_MINWAVEFORM = 0_eax_ulong; +inline constexpr auto EAXRINGMODULATOR_MAXWAVEFORM = 2_eax_ulong; +inline constexpr auto EAXRINGMODULATOR_DEFAULTWAVEFORM = EAXRINGMODULATOR_MINWAVEFORM; -constexpr auto EAXRINGMODULATOR_MINWAVEFORM = 0_eax_ulong; -constexpr auto EAXRINGMODULATOR_MAXWAVEFORM = 2_eax_ulong; -constexpr auto EAXRINGMODULATOR_DEFAULTWAVEFORM = EAXRINGMODULATOR_MINWAVEFORM; +struct _GUID; /* NOLINT(*-reserved-identifier) */ -using LPEAXSET = ALenum(AL_APIENTRY*)( - const GUID* property_set_id, - ALuint property_id, - ALuint property_source_id, - ALvoid* property_buffer, - ALuint property_size); +extern "C" auto AL_APIENTRY EAXSet(_GUID const *property_set_id, ALuint property_id, + ALuint source_id, ALvoid *value, ALuint value_size) noexcept -> ALenum; +extern "C" auto AL_APIENTRY EAXGet(_GUID const *property_set_id, ALuint property_id, + ALuint source_id, ALvoid *value, ALuint value_size) noexcept -> ALenum; -using LPEAXGET = ALenum(AL_APIENTRY*)( - const GUID* property_set_id, - ALuint property_id, - ALuint property_source_id, - ALvoid* property_buffer, - ALuint property_size); +using LPEAXSET = decltype(EAXSet)*; +using LPEAXGET = decltype(EAXGet)*; #endif // !EAX_API_INCLUDED diff --git a/3rdparty/openal/al/eax/call.cpp b/3rdparty/openal/al/eax/call.cpp index 79d25d1c9008..5c7e015aa258 100644 --- a/3rdparty/openal/al/eax/call.cpp +++ b/3rdparty/openal/al/eax/call.cpp @@ -19,7 +19,7 @@ class EaxCallException final : public EaxException { } // namespace -EaxCall::EaxCall(EaxCallType type, const GUID &property_set_guid, ALuint property_id, +EaxCall::EaxCall(EaxCallType type, AL_GUID const& property_set_guid, ALuint property_id, ALuint property_source_id, ALvoid *property_buffer, ALuint property_size) : mCallType{type}, mIsDeferred{(property_id & deferred_flag) != 0} , mPropertyId{property_id & ~deferred_flag}, mPropertySourceId{property_source_id} @@ -203,7 +203,7 @@ EaxCall::EaxCall(EaxCallType type, const GUID &property_set_guid, ALuint propert EaxCall create_eax_call( EaxCallType type, - const GUID* property_set_id, + AL_GUID const* property_set_id, ALuint property_id, ALuint property_source_id, ALvoid* property_buffer, diff --git a/3rdparty/openal/al/eax/call.h b/3rdparty/openal/al/eax/call.h index 0053bd9b3fbc..62791cc870b6 100644 --- a/3rdparty/openal/al/eax/call.h +++ b/3rdparty/openal/al/eax/call.h @@ -1,11 +1,11 @@ #ifndef EAX_EAX_CALL_INCLUDED #define EAX_EAX_CALL_INCLUDED +#include #include #include #include "AL/al.h" -#include "alnumeric.h" #include "api.h" #include "fx_slot_index.h" @@ -27,7 +27,7 @@ class EaxCall { public: EaxCall( EaxCallType type, - const GUID& property_set_guid, + AL_GUID const& property_set_guid, ALuint property_id, ALuint property_source_id, ALvoid* property_buffer, @@ -51,7 +51,8 @@ class EaxCall { } template - [[nodiscard]] auto as_span(size_t max_count=~0_uz) const -> std::span + [[nodiscard]] auto as_span(size_t const max_count=std::numeric_limits::max()) const + -> std::span { if(max_count == 0 || mPropertyBufferSize < sizeof(TValue)) fail_too_small(); @@ -84,7 +85,7 @@ class EaxCall { EaxCall create_eax_call( EaxCallType type, - const GUID* property_set_id, + AL_GUID const *property_set_id, ALuint property_id, ALuint property_source_id, ALvoid* property_buffer, diff --git a/3rdparty/openal/al/eax/fx_slot_index.cpp b/3rdparty/openal/al/eax/fx_slot_index.cpp index 7dddced3958b..1ec333f61a0c 100644 --- a/3rdparty/openal/al/eax/fx_slot_index.cpp +++ b/3rdparty/openal/al/eax/fx_slot_index.cpp @@ -27,7 +27,7 @@ void EaxFxSlotIndex::set(EaxFxSlotIndexValue index) emplace(index); } -void EaxFxSlotIndex::set(const GUID &guid) +void EaxFxSlotIndex::set(AL_GUID const& guid) { if(guid == EAX_NULL_GUID) reset(); diff --git a/3rdparty/openal/al/eax/fx_slot_index.h b/3rdparty/openal/al/eax/fx_slot_index.h index 934f36c1d29f..4b4beec242d3 100644 --- a/3rdparty/openal/al/eax/fx_slot_index.h +++ b/3rdparty/openal/al/eax/fx_slot_index.h @@ -16,14 +16,14 @@ class EaxFxSlotIndex : public std::optional { using std::optional::optional; EaxFxSlotIndex& operator=(const EaxFxSlotIndexValue &value) { set(value); return *this; } - EaxFxSlotIndex& operator=(const GUID &guid) { set(guid); return *this; } + EaxFxSlotIndex& operator=(AL_GUID const& guid) { set(guid); return *this; } void set(EaxFxSlotIndexValue index); - void set(const GUID& guid); + void set(AL_GUID const& guid); private: [[noreturn]] - static void fail(const std::string_view message); + static void fail(std::string_view message); }; // EaxFxSlotIndex inline bool operator==(const EaxFxSlotIndex& lhs, const EaxFxSlotIndex& rhs) noexcept diff --git a/3rdparty/openal/al/eax/utils.cpp b/3rdparty/openal/al/eax/utils.cpp index 670922ef7d1c..49394c144185 100644 --- a/3rdparty/openal/al/eax/utils.cpp +++ b/3rdparty/openal/al/eax/utils.cpp @@ -4,9 +4,14 @@ #include -#include "core/logging.h" #include "gsl/gsl" +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + void eax_log_exception(std::string_view message) noexcept { diff --git a/3rdparty/openal/al/eax/utils.h b/3rdparty/openal/al/eax/utils.h index d0d72ea16d71..ca90841853c9 100644 --- a/3rdparty/openal/al/eax/utils.h +++ b/3rdparty/openal/al/eax/utils.h @@ -6,11 +6,6 @@ #include "alformat.hpp" -struct EaxAlLowPassParam { - float gain; - float gain_hf; -}; - void eax_log_exception(std::string_view message) noexcept; template diff --git a/3rdparty/openal/al/eax/x_ram.h b/3rdparty/openal/al/eax/x_ram.h index 3616550d2018..916be673e36c 100644 --- a/3rdparty/openal/al/eax/x_ram.h +++ b/3rdparty/openal/al/eax/x_ram.h @@ -24,7 +24,8 @@ constexpr auto AL_STORAGE_AUTOMATIC_NAME = "AL_STORAGE_AUTOMATIC"; constexpr auto AL_STORAGE_HARDWARE_NAME = "AL_STORAGE_HARDWARE"; constexpr auto AL_STORAGE_ACCESSIBLE_NAME = "AL_STORAGE_ACCESSIBLE"; -ALboolean AL_APIENTRY EAXSetBufferMode(ALsizei n, const ALuint *buffers, ALint value) noexcept; -ALenum AL_APIENTRY EAXGetBufferMode(ALuint buffer, ALint *pReserved) noexcept; +extern "C" auto AL_APIENTRY EAXSetBufferMode(ALsizei n, const ALuint *buffers, ALint value) + noexcept -> ALboolean; +extern "C" auto AL_APIENTRY EAXGetBufferMode(ALuint buffer, ALint *pReserved) noexcept -> ALenum; #endif // !EAX_X_RAM_INCLUDED diff --git a/3rdparty/openal/al/effect.cpp b/3rdparty/openal/al/effect.cpp index 705546b371e0..8133c41f70fa 100644 --- a/3rdparty/openal/al/effect.cpp +++ b/3rdparty/openal/al/effect.cpp @@ -23,8 +23,6 @@ #include "effect.h" #include -#include -#include #include #include #include @@ -32,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -44,18 +41,25 @@ #include "AL/efx.h" #include "al/effects/effects.h" -#include "alc/context.h" #include "alc/device.h" #include "alc/inprogext.h" #include "almalloc.h" #include "alnumeric.h" #include "alstring.h" #include "core/except.h" -#include "core/logging.h" #include "direct_defs.h" -#include "gsl/gsl" #include "opthelpers.h" +#if HAVE_CXXMODULES +import alc.context; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + constinit const std::array gEffectList{{ { "eaxreverb", EAXREVERB_EFFECT, AL_EFFECT_EAXREVERB }, @@ -143,9 +147,9 @@ void InitEffectParams(al::Effect *const effect, ALenum const type) noexcept [[nodiscard]] auto EnsureEffects(gsl::not_null const device, usize const needed) noexcept -> bool try { - auto count = std::accumulate(device->EffectList.cbegin(), device->EffectList.cend(), 0_uz, + auto count = std::accumulate(device->EffectList.cbegin(), device->EffectList.cend(), 0_usize, [](usize const cur, const EffectSubList &sublist) noexcept -> usize - { return cur + sublist.mFreeMask.popcount().c_val; }); + { return cur + sublist.mFreeMask.popcount(); }); while(needed > count) { @@ -170,7 +174,7 @@ auto AllocEffect(gsl::not_null const device) noexcept -> gsl::not_n auto const sublist = std::ranges::find_if(device->EffectList, [](EffectSubList const &slist) { return slist.mFreeMask != 0; }); auto const lidx = gsl::narrow_cast(std::distance(device->EffectList.begin(), sublist)); - auto const slidx = gsl::narrow_cast(sublist->mFreeMask.countr_zero().c_val); + auto const slidx = sublist->mFreeMask.countr_zero().c_val; ASSUME(slidx < 64); auto effect = gsl::make_not_null(std::construct_at( @@ -223,7 +227,7 @@ auto LookupEffect(gsl::not_null const context, ALuint const id) } -void alGenEffects(gsl::not_null context, ALsizei n, ALuint *effects) noexcept +void alGenEffects_(gsl::not_null context, ALsizei n, ALuint *effects) noexcept try { if(n < 0) context->throw_error(AL_INVALID_VALUE, "Generating {} effects", n); @@ -245,7 +249,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alDeleteEffects(gsl::not_null context, ALsizei n, const ALuint *effects) +void alDeleteEffects_(gsl::not_null context, ALsizei n, const ALuint *effects) noexcept try { if(n < 0) @@ -273,7 +277,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -auto alIsEffect(gsl::not_null context, ALuint effect) noexcept -> ALboolean +auto alIsEffect_(gsl::not_null context, ALuint effect) noexcept -> ALboolean { auto const device = al::get_not_null(context->mALDevice); auto effectlock = std::lock_guard{device->EffectLock}; @@ -283,7 +287,7 @@ auto alIsEffect(gsl::not_null context, ALuint effect) noexcept -> } -void alEffecti(gsl::not_null context, ALuint effect, ALenum param, ALint value) +void alEffecti_(gsl::not_null context, ALuint effect, ALenum param, ALint value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -319,13 +323,13 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alEffectiv(gsl::not_null context, ALuint effect, ALenum param, +void alEffectiv_(gsl::not_null context, ALuint effect, ALenum param, const ALint *values) noexcept try { switch(param) { case AL_EFFECT_TYPE: - alEffecti(context, effect, param, *values); + alEffecti_(context, effect, param, *values); return; } @@ -347,7 +351,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alEffectf(gsl::not_null context, ALuint effect, ALenum param, ALfloat value) +void alEffectf_(gsl::not_null context, ALuint effect, ALenum param, ALfloat value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -368,7 +372,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alEffectfv(gsl::not_null context, ALuint effect, ALenum param, +void alEffectfv_(gsl::not_null context, ALuint effect, ALenum param, const ALfloat *values) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -389,7 +393,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetEffecti(gsl::not_null context, ALuint effect, ALenum param, ALint *value) +void alGetEffecti_(gsl::not_null context, ALuint effect, ALenum param, ALint *value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -414,13 +418,13 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetEffectiv(gsl::not_null context, ALuint effect, ALenum param, ALint *values) - noexcept +void alGetEffectiv_(gsl::not_null context, ALuint effect, ALenum param, + ALint *values) noexcept try { switch(param) { case AL_EFFECT_TYPE: - alGetEffecti(context, effect, param, values); + alGetEffecti_(context, effect, param, values); return; } @@ -442,8 +446,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetEffectf(gsl::not_null context, ALuint effect, ALenum param, ALfloat *value) - noexcept +void alGetEffectf_(gsl::not_null context, ALuint effect, ALenum param, + ALfloat *value) noexcept try { auto const device = al::get_not_null(context->mALDevice); auto effectlock = std::lock_guard{device->EffectLock}; @@ -463,7 +467,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetEffectfv(gsl::not_null context, ALuint effect, ALenum param, +void alGetEffectfv_(gsl::not_null context, ALuint effect, ALenum param, ALfloat *values) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -486,18 +490,18 @@ catch(std::exception &e) { } // namespace -AL_API DECL_FUNC2(void, alGenEffects, ALsizei,n, ALuint*,effects) -AL_API DECL_FUNC2(void, alDeleteEffects, ALsizei,n, const ALuint*,effects) -AL_API DECL_FUNC1(ALboolean, alIsEffect, ALuint,effect) - -AL_API DECL_FUNC3(void, alEffecti, ALuint,effect, ALenum,param, ALint,value) -AL_API DECL_FUNC3(void, alEffectiv, ALuint,effect, ALenum,param, const ALint*,values) -AL_API DECL_FUNC3(void, alEffectf, ALuint,effect, ALenum,param, ALfloat,value) -AL_API DECL_FUNC3(void, alEffectfv, ALuint,effect, ALenum,param, const ALfloat*,values) -AL_API DECL_FUNC3(void, alGetEffecti, ALuint,effect, ALenum,param, ALint*,value) -AL_API DECL_FUNC3(void, alGetEffectiv, ALuint,effect, ALenum,param, ALint*,values) -AL_API DECL_FUNC3(void, alGetEffectf, ALuint,effect, ALenum,param, ALfloat*,value) -AL_API DECL_FUNC3(void, alGetEffectfv, ALuint,effect, ALenum,param, ALfloat*,values) +DECL_FUNC(AL_API, void, alGenEffects, ALsizei,n, ALuint*,effects) +DECL_FUNC(AL_API, void, alDeleteEffects, ALsizei,n, const ALuint*,effects) +DECL_FUNC(AL_API, ALboolean, alIsEffect, ALuint,effect) + +DECL_FUNC(AL_API, void, alEffecti, ALuint,effect, ALenum,param, ALint,value) +DECL_FUNC(AL_API, void, alEffectiv, ALuint,effect, ALenum,param, const ALint*,values) +DECL_FUNC(AL_API, void, alEffectf, ALuint,effect, ALenum,param, ALfloat,value) +DECL_FUNC(AL_API, void, alEffectfv, ALuint,effect, ALenum,param, const ALfloat*,values) +DECL_FUNC(AL_API, void, alGetEffecti, ALuint,effect, ALenum,param, ALint*,value) +DECL_FUNC(AL_API, void, alGetEffectiv, ALuint,effect, ALenum,param, ALint*,values) +DECL_FUNC(AL_API, void, alGetEffectf, ALuint,effect, ALenum,param, ALfloat*,value) +DECL_FUNC(AL_API, void, alGetEffectfv, ALuint,effect, ALenum,param, ALfloat*,values) void InitEffect(al::Effect *const effect) diff --git a/3rdparty/openal/al/effect.h b/3rdparty/openal/al/effect.h index 7d1d06678637..ffdfd8701df9 100644 --- a/3rdparty/openal/al/effect.h +++ b/3rdparty/openal/al/effect.h @@ -11,7 +11,7 @@ #include "AL/efx.h" #include "almalloc.h" -#include "alnumeric.h" +#include "altypes.hpp" #include "core/effects/base.h" #include "effects/effects.h" #include "gsl/gsl" diff --git a/3rdparty/openal/al/effects/autowah.cpp b/3rdparty/openal/al/effects/autowah.cpp index 0194c08dcc6d..7c727773ca03 100644 --- a/3rdparty/openal/al/effects/autowah.cpp +++ b/3rdparty/openal/al/effects/autowah.cpp @@ -6,10 +6,8 @@ #include "AL/efx.h" -#include "alc/context.h" #include "alnumeric.h" #include "effects.h" -#include "gsl/gsl" #if ALSOFT_EAX #include "al/eax/effect.h" @@ -17,6 +15,14 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import gsl; +#else +#include "alc/context.hpp" +#include "gsl/gsl" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/chorus.cpp b/3rdparty/openal/al/effects/chorus.cpp index 01ed6cc7b29b..7aa183a096e7 100644 --- a/3rdparty/openal/al/effects/chorus.cpp +++ b/3rdparty/openal/al/effects/chorus.cpp @@ -7,12 +7,9 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alformat.hpp" #include "alnumeric.h" -#include "core/logging.h" #include "effects.h" -#include "gsl/gsl" #if ALSOFT_EAX #include "al/eax/effect.h" @@ -20,6 +17,16 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/compressor.cpp b/3rdparty/openal/al/effects/compressor.cpp index 0e328db79180..5f9e53db169f 100644 --- a/3rdparty/openal/al/effects/compressor.cpp +++ b/3rdparty/openal/al/effects/compressor.cpp @@ -4,7 +4,6 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alnumeric.h" #include "effects.h" @@ -14,6 +13,12 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/convolution.cpp b/3rdparty/openal/al/effects/convolution.cpp index 014f4f109f26..5ff95b8830c2 100644 --- a/3rdparty/openal/al/effects/convolution.cpp +++ b/3rdparty/openal/al/effects/convolution.cpp @@ -8,11 +8,17 @@ #include "AL/al.h" -#include "alc/context.h" #include "alc/inprogext.h" #include "alnumeric.h" +#include "altypes.hpp" #include "effects.h" +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/dedicated.cpp b/3rdparty/openal/al/effects/dedicated.cpp index 35f0f589bbfa..88c8abb6acb3 100644 --- a/3rdparty/openal/al/effects/dedicated.cpp +++ b/3rdparty/openal/al/effects/dedicated.cpp @@ -6,10 +6,14 @@ #include "AL/al.h" #include "AL/alext.h" -#include "alc/context.h" #include "alnumeric.h" #include "effects.h" +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif namespace { diff --git a/3rdparty/openal/al/effects/distortion.cpp b/3rdparty/openal/al/effects/distortion.cpp index 5c9813bb87dc..9cbbb5b9b2e8 100644 --- a/3rdparty/openal/al/effects/distortion.cpp +++ b/3rdparty/openal/al/effects/distortion.cpp @@ -4,7 +4,6 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alnumeric.h" #include "effects.h" #include "gsl/gsl" @@ -15,6 +14,12 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/echo.cpp b/3rdparty/openal/al/effects/echo.cpp index dc01e443c1f7..a43538b3ed19 100644 --- a/3rdparty/openal/al/effects/echo.cpp +++ b/3rdparty/openal/al/effects/echo.cpp @@ -4,7 +4,6 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alnumeric.h" #include "effects.h" @@ -14,6 +13,12 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/equalizer.cpp b/3rdparty/openal/al/effects/equalizer.cpp index 4c34f834dc23..8ba049607f1e 100644 --- a/3rdparty/openal/al/effects/equalizer.cpp +++ b/3rdparty/openal/al/effects/equalizer.cpp @@ -4,7 +4,6 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alnumeric.h" #include "effects.h" #include "gsl/gsl" @@ -15,6 +14,12 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/fshifter.cpp b/3rdparty/openal/al/effects/fshifter.cpp index 367f04acf11a..3e67c8d972f6 100644 --- a/3rdparty/openal/al/effects/fshifter.cpp +++ b/3rdparty/openal/al/effects/fshifter.cpp @@ -7,7 +7,6 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alformat.hpp" #include "alnumeric.h" #include "effects.h" @@ -18,6 +17,12 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/modulator.cpp b/3rdparty/openal/al/effects/modulator.cpp index 58b0bc1dd154..56b6410d4710 100644 --- a/3rdparty/openal/al/effects/modulator.cpp +++ b/3rdparty/openal/al/effects/modulator.cpp @@ -7,11 +7,9 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alformat.hpp" #include "alnumeric.h" #include "effects.h" -#include "gsl/gsl" #if ALSOFT_EAX #include "al/eax/effect.h" @@ -19,6 +17,14 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import gsl; +#else +#include "alc/context.hpp" +#include "gsl/gsl" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/null.cpp b/3rdparty/openal/al/effects/null.cpp index d08761cffdc3..54e1267bdbde 100644 --- a/3rdparty/openal/al/effects/null.cpp +++ b/3rdparty/openal/al/effects/null.cpp @@ -4,7 +4,6 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alnumeric.h" #include "effects.h" @@ -13,6 +12,12 @@ #include "al/eax/exception.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/pshifter.cpp b/3rdparty/openal/al/effects/pshifter.cpp index 0f83b9226008..12b2b02b1a0a 100644 --- a/3rdparty/openal/al/effects/pshifter.cpp +++ b/3rdparty/openal/al/effects/pshifter.cpp @@ -4,10 +4,8 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alnumeric.h" #include "effects.h" -#include "gsl/gsl" #if ALSOFT_EAX #include "al/eax/effect.h" @@ -15,6 +13,14 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import gsl; +#else +#include "alc/context.hpp" +#include "gsl/gsl" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/reverb.cpp b/3rdparty/openal/al/effects/reverb.cpp index e26cee133f33..44c5653bb337 100644 --- a/3rdparty/openal/al/effects/reverb.cpp +++ b/3rdparty/openal/al/effects/reverb.cpp @@ -10,11 +10,9 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alnumeric.h" -#include "core/logging.h" +#include "altypes.hpp" #include "effects.h" -#include "gsl/gsl" #if ALSOFT_EAX #include "al/eax/api.h" @@ -24,6 +22,16 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import logging; +import gsl; +#else +#include "alc/context.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { diff --git a/3rdparty/openal/al/effects/vmorpher.cpp b/3rdparty/openal/al/effects/vmorpher.cpp index 004cb8bed53f..c64a9fcf2896 100644 --- a/3rdparty/openal/al/effects/vmorpher.cpp +++ b/3rdparty/openal/al/effects/vmorpher.cpp @@ -7,11 +7,9 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alformat.hpp" #include "alnumeric.h" #include "effects.h" -#include "gsl/gsl" #if ALSOFT_EAX #include "al/eax/effect.h" @@ -19,6 +17,14 @@ #include "al/eax/utils.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import gsl; +#else +#include "alc/context.hpp" +#include "gsl/gsl" +#endif + namespace { diff --git a/3rdparty/openal/al/error.cpp b/3rdparty/openal/al/error.cpp index 92c420951918..6c5ada9ad6bd 100644 --- a/3rdparty/openal/al/error.cpp +++ b/3rdparty/openal/al/error.cpp @@ -26,31 +26,37 @@ #include #include -#include #include -#include #include #include #include #include "AL/al.h" #include "AL/alc.h" +#include "AL/alext.h" #include "al/debug.h" #include "alc/alconfig.h" -#include "alc/context.h" #include "alformat.hpp" #include "alnumeric.h" #include "core/except.h" -#include "core/logging.h" #include "direct_defs.h" -#include "gsl/gsl" #include "strutils.hpp" +#if HAVE_CXXMODULES +import alc.context; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { -auto alGetError(gsl::not_null context) noexcept -> ALenum +auto alGetError_(gsl::not_null context) noexcept -> ALenum { auto ret = context->mLastThreadError.get(); if(ret != AL_NO_ERROR) [[unlikely]] @@ -99,7 +105,7 @@ void al::Context::throw_error_impl(ALenum const errorCode, al::string_view const AL_API auto AL_APIENTRY alGetError() noexcept -> ALenum { if(auto context = GetContextRef()) [[likely]] - return alGetError(gsl::make_not_null(context.get())); + return alGetError_(gsl::make_not_null(context.get())); static constexpr auto get_value = [](gsl::czstring envname, std::string_view optname) -> ALenum { @@ -133,8 +139,10 @@ AL_API auto AL_APIENTRY alGetError() noexcept -> ALenum } return deferror; } +DefineFuncAlias(alGetError) FORCE_ALIGN auto AL_APIENTRY alGetErrorDirect(ALCcontext *context) noexcept -> ALenum { - return alGetError(al::verify_context(context)); + return alGetError_(al::verify_context(context)); } +DefineFuncAlias(alGetErrorDirect) diff --git a/3rdparty/openal/al/event.cpp b/3rdparty/openal/al/event.cpp index a7015b260521..d1e0181d1f53 100644 --- a/3rdparty/openal/al/event.cpp +++ b/3rdparty/openal/al/event.cpp @@ -4,7 +4,6 @@ #include "event.h" #include -#include #include #include #include @@ -19,20 +18,26 @@ #include "AL/al.h" #include "AL/alext.h" -#include "alc/context.h" #include "alformat.hpp" #include "alnumeric.h" #include "core/async_event.h" -#include "core/context.h" #include "core/effects/base.h" +#include "core/context.h" #include "core/except.h" -#include "core/logging.h" #include "direct_defs.h" -#include "gsl/gsl" #include "intrusive_ptr.h" -#include "opthelpers.h" #include "ringbuffer.h" +#if HAVE_CXXMODULES +import alc.context; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { @@ -73,8 +78,7 @@ auto EventThread(gsl::not_null const context) -> void }, [context,enabledevts](AsyncSourceStateEvent const &evt) { - if(!context->mEventCb - || !enabledevts.test(al::to_underlying(AsyncEnableBits::SourceState))) + if(!context->mEventCb || !enabledevts.test(AsyncEnableBits::SourceState)) return; auto state = ALuint{}; @@ -106,8 +110,7 @@ auto EventThread(gsl::not_null const context) -> void }, [context,enabledevts](AsyncBufferCompleteEvent const &evt) { - if(!context->mEventCb - || !enabledevts.test(al::to_underlying(AsyncEnableBits::BufferCompleted))) + if(!context->mEventCb || !enabledevts.test(AsyncEnableBits::BufferCompleted)) return; const auto msg = al::format("{} buffer{} completed", evt.mCount, @@ -117,8 +120,7 @@ auto EventThread(gsl::not_null const context) -> void }, [context,enabledevts](AsyncDisconnectEvent const &evt) { - if(!context->mEventCb - || !enabledevts.test(al::to_underlying(AsyncEnableBits::Disconnected))) + if(!context->mEventCb || !enabledevts.test(AsyncEnableBits::Disconnected)) return; context->mEventCb(AL_EVENT_TYPE_DISCONNECTED_SOFT, 0, 0, @@ -144,7 +146,7 @@ constexpr auto GetEventType(ALenum const etype) noexcept -> std::optional const context, ALsizei const count, +void alEventControlSOFT_(gsl::not_null const context, ALsizei const count, ALenum const *const types, ALboolean const enable) noexcept try { if(count < 0) @@ -161,7 +163,7 @@ try { if(!etype) context->throw_error(AL_INVALID_ENUM, "Invalid event type {:#04x}", as_unsigned(evttype)); - flags.set(al::to_underlying(*etype)); + flags.set(*etype); }); if(enable) @@ -194,8 +196,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alEventCallbackSOFT(gsl::not_null const context, ALEVENTPROCSOFT const callback, - void *const userParam) noexcept +void alEventCallbackSOFT_(gsl::not_null const context, + ALEVENTPROCSOFT const callback, void *const userParam) noexcept try { auto const eventlock = std::lock_guard{context->mEventCbLock}; context->mEventCb = callback; @@ -245,5 +247,5 @@ void StopEventThrd(al::Context *ctx) ctx->mEventThread.join(); } -AL_API DECL_FUNCEXT3(void, alEventControl,SOFT, ALsizei,count, const ALenum*,types, ALboolean,enable) -AL_API DECL_FUNCEXT2(void, alEventCallback,SOFT, ALEVENTPROCSOFT,callback, void*,userParam) +DECL_FUNCEXT(AL_API, void, alEventControl,SOFT, ALsizei,count, const ALenum*,types, ALboolean,enable) +DECL_FUNCEXT(AL_API, void, alEventCallback,SOFT, ALEVENTPROCSOFT,callback, void*,userParam) diff --git a/3rdparty/openal/al/extension.cpp b/3rdparty/openal/al/extension.cpp index 4d418291545d..b2f66314a690 100644 --- a/3rdparty/openal/al/extension.cpp +++ b/3rdparty/openal/al/extension.cpp @@ -24,15 +24,21 @@ #include "AL/al.h" #include "AL/alc.h" +#include "AL/alext.h" -#include "alc/context.h" #include "alstring.h" #include "direct_defs.h" +#if HAVE_CXXMODULES +import alc.context; +#else +#include "alc/context.hpp" +#endif + namespace { -auto alIsExtensionPresent(gsl::not_null context, const ALchar *extName) noexcept +auto alIsExtensionPresent_(gsl::not_null context, const ALchar *extName) noexcept -> ALboolean { if(!extName) [[unlikely]] @@ -49,13 +55,14 @@ auto alIsExtensionPresent(gsl::not_null context, const ALchar *ext } // namespace -AL_API DECL_FUNC1(ALboolean, alIsExtensionPresent, const ALchar*,extName) +DECL_FUNC(AL_API, ALboolean, alIsExtensionPresent, const ALchar*,extName) AL_API auto AL_APIENTRY alGetProcAddress(const ALchar *funcName) noexcept -> ALvoid* { if(!funcName) return nullptr; return alcGetProcAddress(nullptr, funcName); } +DefineFuncAlias(alGetProcAddress) FORCE_ALIGN auto AL_APIENTRY alGetProcAddressDirect(ALCcontext*, const ALchar *funcName) noexcept -> ALvoid* @@ -63,12 +70,14 @@ FORCE_ALIGN auto AL_APIENTRY alGetProcAddressDirect(ALCcontext*, const ALchar *f if(!funcName) return nullptr; return alcGetProcAddress(nullptr, funcName); } +DefineFuncAlias(alGetProcAddressDirect) AL_API auto AL_APIENTRY alGetEnumValue(const ALchar *enumName) noexcept -> ALenum { if(!enumName) return ALenum{0}; return alcGetEnumValue(nullptr, enumName); } +DefineFuncAlias(alGetEnumValue) FORCE_ALIGN auto AL_APIENTRY alGetEnumValueDirect(ALCcontext*, const ALchar *enumName) noexcept -> ALenum @@ -76,3 +85,4 @@ FORCE_ALIGN auto AL_APIENTRY alGetEnumValueDirect(ALCcontext*, const ALchar *enu if(!enumName) return ALenum{0}; return alcGetEnumValue(nullptr, enumName); } +DefineFuncAlias(alGetEnumValueDirect) diff --git a/3rdparty/openal/al/filter.cpp b/3rdparty/openal/al/filter.cpp index 2a4a20f1553f..a469113abd7e 100644 --- a/3rdparty/openal/al/filter.cpp +++ b/3rdparty/openal/al/filter.cpp @@ -23,9 +23,6 @@ #include "filter.h" #include -#include -#include -#include #include #include #include @@ -38,16 +35,23 @@ #include "AL/al.h" #include "AL/efx.h" -#include "alc/context.h" #include "alc/device.h" #include "almalloc.h" #include "alnumeric.h" #include "core/except.h" -#include "core/logging.h" #include "direct_defs.h" -#include "gsl/gsl" #include "opthelpers.h" +#if HAVE_CXXMODULES +import alc.context; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + /* Null filter parameter handlers */ template<> @@ -285,9 +289,9 @@ void InitFilterParams(gsl::not_null const filter, ALenum const type [[nodiscard]] auto EnsureFilters(gsl::not_null const device, usize const needed) noexcept -> bool try { - auto count = std::accumulate(device->FilterList.cbegin(), device->FilterList.cend(), 0_uz, + auto count = std::accumulate(device->FilterList.cbegin(), device->FilterList.cend(), 0_usize, [](usize const cur, const FilterSubList &sublist) noexcept -> usize - { return cur + sublist.mFreeMask.popcount().c_val; }); + { return cur + sublist.mFreeMask.popcount(); }); while(needed > count) { @@ -313,7 +317,7 @@ auto AllocFilter(gsl::not_null const device) noexcept -> gsl::not_n auto const sublist = std::ranges::find_if(device->FilterList, [](FilterSubList const &slist) { return slist.mFreeMask != 0; }); auto const lidx = gsl::narrow_cast(std::distance(device->FilterList.begin(), sublist)); - auto const slidx = gsl::narrow_cast(sublist->mFreeMask.countr_zero().c_val); + auto const slidx = sublist->mFreeMask.countr_zero().c_val; ASSUME(slidx < 64); auto filter = gsl::make_not_null(std::construct_at( @@ -366,7 +370,7 @@ auto LookupFilter(gsl::not_null const context, ALuint const id) } -void alGenFilters(gsl::not_null context, ALsizei n, ALuint *filters) noexcept +void alGenFilters_(gsl::not_null context, ALsizei n, ALuint *filters) noexcept try { if(n < 0) context->throw_error(AL_INVALID_VALUE, "Generating {} filters", n); @@ -388,7 +392,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alDeleteFilters(gsl::not_null context, ALsizei n, const ALuint *filters) +void alDeleteFilters_(gsl::not_null context, ALsizei n, const ALuint *filters) noexcept try { if(n < 0) @@ -416,7 +420,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -auto alIsFilter(gsl::not_null context, ALuint filter) noexcept -> ALboolean +auto alIsFilter_(gsl::not_null context, ALuint filter) noexcept -> ALboolean { auto const device = al::get_not_null(context->mALDevice); auto filterlock = std::lock_guard{device->FilterLock}; @@ -426,7 +430,7 @@ auto alIsFilter(gsl::not_null context, ALuint filter) noexcept -> } -void alFilteri(gsl::not_null context, ALuint filter, ALenum param, ALint value) +void alFilteri_(gsl::not_null context, ALuint filter, ALenum param, ALint value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -454,13 +458,13 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alFilteriv(gsl::not_null context, ALuint filter, ALenum param, +void alFilteriv_(gsl::not_null context, ALuint filter, ALenum param, const ALint *values) noexcept try { switch(param) { case AL_FILTER_TYPE: - alFilteri(context, filter, param, *values); + alFilteri_(context, filter, param, *values); return; } @@ -479,7 +483,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alFilterf(gsl::not_null context, ALuint filter, ALenum param, ALfloat value) +void alFilterf_(gsl::not_null context, ALuint filter, ALenum param, ALfloat value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -497,7 +501,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alFilterfv(gsl::not_null context, ALuint filter, ALenum param, +void alFilterfv_(gsl::not_null context, ALuint filter, ALenum param, const ALfloat *values) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -515,7 +519,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetFilteri(gsl::not_null context, ALuint filter, ALenum param, ALint *value) +void alGetFilteri_(gsl::not_null context, ALuint filter, ALenum param, ALint *value) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -538,13 +542,13 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetFilteriv(gsl::not_null context, ALuint filter, ALenum param, ALint *values) - noexcept +void alGetFilteriv_(gsl::not_null context, ALuint filter, ALenum param, + ALint *values) noexcept try { switch(param) { case AL_FILTER_TYPE: - alGetFilteri(context, filter, param, values); + alGetFilteri_(context, filter, param, values); return; } @@ -563,8 +567,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetFilterf(gsl::not_null context, ALuint filter, ALenum param, ALfloat *value) - noexcept +void alGetFilterf_(gsl::not_null context, ALuint filter, ALenum param, + ALfloat *value) noexcept try { auto const device = al::get_not_null(context->mALDevice); auto filterlock = std::lock_guard{device->FilterLock}; @@ -581,7 +585,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetFilterfv(gsl::not_null context, ALuint filter, ALenum param, +void alGetFilterfv_(gsl::not_null context, ALuint filter, ALenum param, ALfloat *values) noexcept try { auto const device = al::get_not_null(context->mALDevice); @@ -601,18 +605,18 @@ catch(std::exception &e) { } // namespace -AL_API DECL_FUNC2(void, alGenFilters, ALsizei,n, ALuint*,filters) -AL_API DECL_FUNC2(void, alDeleteFilters, ALsizei,n, const ALuint*,filters) -AL_API DECL_FUNC1(ALboolean, alIsFilter, ALuint,filter) - -AL_API DECL_FUNC3(void, alFilteri, ALuint,filter, ALenum,param, ALint,value) -AL_API DECL_FUNC3(void, alFilteriv, ALuint,filter, ALenum,param, const ALint*,values) -AL_API DECL_FUNC3(void, alFilterf, ALuint,filter, ALenum,param, ALfloat,value) -AL_API DECL_FUNC3(void, alFilterfv, ALuint,filter, ALenum,param, const ALfloat*,values) -AL_API DECL_FUNC3(void, alGetFilteri, ALuint,filter, ALenum,param, ALint*,value) -AL_API DECL_FUNC3(void, alGetFilteriv, ALuint,filter, ALenum,param, ALint*,values) -AL_API DECL_FUNC3(void, alGetFilterf, ALuint,filter, ALenum,param, ALfloat*,value) -AL_API DECL_FUNC3(void, alGetFilterfv, ALuint,filter, ALenum,param, ALfloat*,values) +DECL_FUNC(AL_API, void, alGenFilters, ALsizei,n, ALuint*,filters) +DECL_FUNC(AL_API, void, alDeleteFilters, ALsizei,n, const ALuint*,filters) +DECL_FUNC(AL_API, ALboolean, alIsFilter, ALuint,filter) + +DECL_FUNC(AL_API, void, alFilteri, ALuint,filter, ALenum,param, ALint,value) +DECL_FUNC(AL_API, void, alFilteriv, ALuint,filter, ALenum,param, const ALint*,values) +DECL_FUNC(AL_API, void, alFilterf, ALuint,filter, ALenum,param, ALfloat,value) +DECL_FUNC(AL_API, void, alFilterfv, ALuint,filter, ALenum,param, const ALfloat*,values) +DECL_FUNC(AL_API, void, alGetFilteri, ALuint,filter, ALenum,param, ALint*,value) +DECL_FUNC(AL_API, void, alGetFilteriv, ALuint,filter, ALenum,param, ALint*,values) +DECL_FUNC(AL_API, void, alGetFilterf, ALuint,filter, ALenum,param, ALfloat*,value) +DECL_FUNC(AL_API, void, alGetFilterfv, ALuint,filter, ALenum,param, ALfloat*,values) void al::Filter::SetName(gsl::not_null const context, ALuint const id, diff --git a/3rdparty/openal/al/filter.h b/3rdparty/openal/al/filter.h index 64870fa0a38f..f287f095ad39 100644 --- a/3rdparty/openal/al/filter.h +++ b/3rdparty/openal/al/filter.h @@ -4,14 +4,13 @@ #include #include #include -#include #include #include "AL/al.h" #include "AL/efx.h" #include "almalloc.h" -#include "alnumeric.h" +#include "altypes.hpp" #include "gsl/gsl" namespace al { diff --git a/3rdparty/openal/al/listener.cpp b/3rdparty/openal/al/listener.cpp index f639cb2075ab..7ef7723dec8a 100644 --- a/3rdparty/openal/al/listener.cpp +++ b/3rdparty/openal/al/listener.cpp @@ -29,14 +29,22 @@ #include #include "AL/al.h" -#include "AL/efx.h" +#include "AL/alext.h" -#include "alc/context.h" #include "alnumeric.h" +#include "altypes.hpp" #include "core/except.h" -#include "core/logging.h" #include "direct_defs.h" + +#if HAVE_CXXMODULES +import alc.context; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "core/logging.h" #include "gsl/gsl" +#endif namespace { @@ -70,7 +78,7 @@ inline void CommitAndUpdateProps(gsl::not_null context) } -void alListenerf(gsl::not_null context, ALenum param, ALfloat value) noexcept +void alListenerf_(gsl::not_null context, ALenum param, ALfloat value) noexcept try { const auto proplock = std::lock_guard{context->mPropLock}; auto &listener = context->mListener; @@ -100,7 +108,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alListener3f(gsl::not_null context, ALenum param, ALfloat value1, +void alListener3f_(gsl::not_null context, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) noexcept try { auto &listener = context->mListener; @@ -134,7 +142,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alListenerfv(gsl::not_null context, ALenum param, const ALfloat *values) +void alListenerfv_(gsl::not_null context, ALenum param, const ALfloat *values) noexcept try { if(!values) @@ -144,13 +152,13 @@ try { { case AL_GAIN: case AL_METERS_PER_UNIT: - alListenerf(context, param, *values); + alListenerf_(context, param, *values); return; case AL_POSITION: case AL_VELOCITY: const auto vals = std::span{values, 3_uz}; - alListener3f(context, param, vals[0], vals[1], vals[2]); + alListener3f_(context, param, vals[0], vals[1], vals[2]); return; } @@ -178,7 +186,7 @@ catch(std::exception &e) { } -void alListeneri(gsl::not_null context, ALenum param, ALint value) noexcept +void alListeneri_(gsl::not_null context, ALenum param, ALint value) noexcept try { const auto proplock = std::lock_guard{context->mPropLock}; auto &listener = context->mListener; @@ -208,14 +216,14 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alListener3i(gsl::not_null context, ALenum param, ALint value1, ALint value2, +void alListener3i_(gsl::not_null context, ALenum param, ALint value1, ALint value2, ALint value3) noexcept try { switch(param) { case AL_POSITION: case AL_VELOCITY: - alListener3f(context, param, gsl::narrow_cast(value1), + alListener3f_(context, param, gsl::narrow_cast(value1), gsl::narrow_cast(value2), gsl::narrow_cast(value3)); return; } @@ -230,7 +238,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alListeneriv(gsl::not_null context, ALenum param, const ALint *values) noexcept +void alListeneriv_(gsl::not_null context, ALenum param, const ALint *values) noexcept try { if(!values) context->throw_error(AL_INVALID_VALUE, "NULL pointer"); @@ -240,13 +248,13 @@ try { { case AL_GAIN: case AL_METERS_PER_UNIT: - alListeneri(context, param, *values); + alListeneri_(context, param, *values); return; case AL_POSITION: case AL_VELOCITY: vals = {values, 3_uz}; - alListener3f(context, param, gsl::narrow_cast(vals[0]), + alListener3f_(context, param, gsl::narrow_cast(vals[0]), gsl::narrow_cast(vals[1]), gsl::narrow_cast(vals[2])); return; @@ -257,7 +265,7 @@ try { gsl::narrow_cast(vals[3]), gsl::narrow_cast(vals[4]), gsl::narrow_cast(vals[5]), }; - alListenerfv(context, param, fvals.data()); + alListenerfv_(context, param, fvals.data()); return; } @@ -272,7 +280,7 @@ catch(std::exception &e) { } -void alGetListenerf(gsl::not_null context, ALenum param, ALfloat *value) noexcept +void alGetListenerf_(gsl::not_null context, ALenum param, ALfloat *value) noexcept try { if(!value) context->throw_error(AL_INVALID_VALUE, "NULL pointer"); @@ -293,7 +301,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetListener3f(gsl::not_null context, ALenum param, ALfloat *value1, +void alGetListener3f_(gsl::not_null context, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) noexcept try { if(!value1 || !value2 || !value3) @@ -324,7 +332,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetListenerfv(gsl::not_null context, ALenum param, ALfloat *values) noexcept +void alGetListenerfv_(gsl::not_null context, ALenum param, ALfloat *values) noexcept try { if(!values) context->throw_error(AL_INVALID_VALUE, "NULL pointer"); @@ -333,13 +341,13 @@ try { { case AL_GAIN: case AL_METERS_PER_UNIT: - alGetListenerf(context, param, values); + alGetListenerf_(context, param, values); return; case AL_POSITION: case AL_VELOCITY: const auto vals = std::span{values, 3_uz}; - alGetListener3f(context, param, &vals[0], &vals[1], &vals[2]); + alGetListener3f_(context, param, &vals[0], &vals[1], &vals[2]); return; } @@ -364,7 +372,7 @@ catch(std::exception &e) { } -void alGetListeneri(gsl::not_null context, ALenum param, ALint *value) noexcept +void alGetListeneri_(gsl::not_null context, ALenum param, ALint *value) noexcept try { /* The largest float value that can fit in an int. */ static constexpr auto float_int_max = 2147483520.0f; @@ -392,7 +400,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetListener3i(gsl::not_null context, ALenum param, ALint *value1, +void alGetListener3i_(gsl::not_null context, ALenum param, ALint *value1, ALint *value2, ALint *value3) noexcept try { if(!value1 || !value2 || !value3) @@ -423,7 +431,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetListeneriv(gsl::not_null context, ALenum param, ALint *values) noexcept +void alGetListeneriv_(gsl::not_null context, ALenum param, ALint *values) noexcept try { if(!values) context->throw_error(AL_INVALID_VALUE, "NULL pointer"); @@ -432,13 +440,13 @@ try { { case AL_GAIN: case AL_METERS_PER_UNIT: - alGetListeneri(context, param, values); + alGetListeneri_(context, param, values); return; case AL_POSITION: case AL_VELOCITY: const auto vals = std::span{values, 3_uz}; - alGetListener3i(context, param, &vals[0], &vals[1], &vals[2]); + alGetListener3i_(context, param, &vals[0], &vals[1], &vals[2]); return; } @@ -466,18 +474,18 @@ catch(std::exception &e) { } // namespace -AL_API DECL_FUNC2(void, alListenerf, ALenum,param, ALfloat,value) -AL_API DECL_FUNC4(void, alListener3f, ALenum,param, ALfloat,value1, ALfloat,value2, ALfloat,value3) -AL_API DECL_FUNC2(void, alListenerfv, ALenum,param, const ALfloat*,values) +DECL_FUNC(AL_API, void, alListenerf, ALenum,param, ALfloat,value) +DECL_FUNC(AL_API, void, alListener3f, ALenum,param, ALfloat,value1, ALfloat,value2, ALfloat,value3) +DECL_FUNC(AL_API, void, alListenerfv, ALenum,param, const ALfloat*,values) -AL_API DECL_FUNC2(void, alListeneri, ALenum,param, ALint,value) -AL_API DECL_FUNC4(void, alListener3i, ALenum,param, ALint,value1, ALint,value2, ALint,value3) -AL_API DECL_FUNC2(void, alListeneriv, ALenum,param, const ALint*,values) +DECL_FUNC(AL_API, void, alListeneri, ALenum,param, ALint,value) +DECL_FUNC(AL_API, void, alListener3i, ALenum,param, ALint,value1, ALint,value2, ALint,value3) +DECL_FUNC(AL_API, void, alListeneriv, ALenum,param, const ALint*,values) -AL_API DECL_FUNC2(void, alGetListenerf, ALenum,param, ALfloat*,value) -AL_API DECL_FUNC4(void, alGetListener3f, ALenum,param, ALfloat*,value1, ALfloat*,value2, ALfloat*,value3) -AL_API DECL_FUNC2(void, alGetListenerfv, ALenum,param, ALfloat*,values) +DECL_FUNC(AL_API, void, alGetListenerf, ALenum,param, ALfloat*,value) +DECL_FUNC(AL_API, void, alGetListener3f, ALenum,param, ALfloat*,value1, ALfloat*,value2, ALfloat*,value3) +DECL_FUNC(AL_API, void, alGetListenerfv, ALenum,param, ALfloat*,values) -AL_API DECL_FUNC2(void, alGetListeneri, ALenum,param, ALint*,value) -AL_API DECL_FUNC4(void, alGetListener3i, ALenum,param, ALint*,value1, ALint*,value2, ALint*,value3) -AL_API DECL_FUNC2(void, alGetListeneriv, ALenum,param, ALint*,values) +DECL_FUNC(AL_API, void, alGetListeneri, ALenum,param, ALint*,value) +DECL_FUNC(AL_API, void, alGetListener3i, ALenum,param, ALint*,value1, ALint*,value2, ALint*,value3) +DECL_FUNC(AL_API, void, alGetListeneriv, ALenum,param, ALint*,values) diff --git a/3rdparty/openal/al/source.cpp b/3rdparty/openal/al/source.cpp index 5760c529acc8..16cc99784caa 100644 --- a/3rdparty/openal/al/source.cpp +++ b/3rdparty/openal/al/source.cpp @@ -25,12 +25,11 @@ #include #include #include -#include #include #include #include #include -#include +#include #include #include #include @@ -54,10 +53,8 @@ #include "AL/efx.h" #include "alc/backends/base.h" -#include "alc/context.h" #include "alc/device.h" #include "alc/inprogext.h" -#include "alformat.hpp" #include "almalloc.h" #include "alnumeric.h" #include "atomic.h" @@ -65,13 +62,11 @@ #include "buffer.h" #include "core/buffer_storage.h" #include "core/except.h" -#include "core/logging.h" #include "core/mixer/defs.h" #include "core/voice_change.h" #include "direct_defs.h" #include "filter.h" #include "flexarray.h" -#include "gsl/gsl" #include "intrusive_ptr.h" #include "opthelpers.h" @@ -82,6 +77,18 @@ #include "eax/utils.h" #endif +#if HAVE_CXXMODULES +import alc.context; +import format.types; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "alformattypes.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { @@ -91,6 +98,91 @@ using seconds_d = std::chrono::duration; using namespace std::string_view_literals; +enum class SourceProp : ALenum { + Pitch = AL_PITCH, + Gain = AL_GAIN, + MinGain = AL_MIN_GAIN, + MaxGain = AL_MAX_GAIN, + MaxDistance = AL_MAX_DISTANCE, + RolloffFactor = AL_ROLLOFF_FACTOR, + DopplerFactor = AL_DOPPLER_FACTOR, + ConeOuterGain = AL_CONE_OUTER_GAIN, + SecOffset = AL_SEC_OFFSET, + SampleOffset = AL_SAMPLE_OFFSET, + ByteOffset = AL_BYTE_OFFSET, + ConeInnerAngle = AL_CONE_INNER_ANGLE, + ConeOuterAngle = AL_CONE_OUTER_ANGLE, + RefDistance = AL_REFERENCE_DISTANCE, + + Position = AL_POSITION, + Velocity = AL_VELOCITY, + Direction = AL_DIRECTION, + + SourceRelative = AL_SOURCE_RELATIVE, + Looping = AL_LOOPING, + Buffer = AL_BUFFER, + SourceState = AL_SOURCE_STATE, + BuffersQueued = AL_BUFFERS_QUEUED, + BuffersProcessed = AL_BUFFERS_PROCESSED, + SourceType = AL_SOURCE_TYPE, + + /* ALC_EXT_EFX */ + ConeOuterGainHF = AL_CONE_OUTER_GAINHF, + AirAbsorptionFactor = AL_AIR_ABSORPTION_FACTOR, + RoomRolloffFactor = AL_ROOM_ROLLOFF_FACTOR, + DirectFilterGainHFAuto = AL_DIRECT_FILTER_GAINHF_AUTO, + AuxSendFilterGainAuto = AL_AUXILIARY_SEND_FILTER_GAIN_AUTO, + AuxSendFilterGainHFAuto = AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO, + DirectFilter = AL_DIRECT_FILTER, + AuxSendFilter = AL_AUXILIARY_SEND_FILTER, + + /* AL_SOFT_direct_channels */ + DirectChannelsSOFT = AL_DIRECT_CHANNELS_SOFT, + + /* AL_EXT_source_distance_model */ + DistanceModel = AL_DISTANCE_MODEL, + + /* AL_SOFT_source_latency */ + SampleOffsetLatencySOFT = AL_SAMPLE_OFFSET_LATENCY_SOFT, + SecOffsetLatencySOFT = AL_SEC_OFFSET_LATENCY_SOFT, + + /* AL_EXT_STEREO_ANGLES */ + StereoAngles = AL_STEREO_ANGLES, + + /* AL_EXT_SOURCE_RADIUS */ + Radius = AL_SOURCE_RADIUS, + + /* AL_EXT_BFORMAT */ + Orientation = AL_ORIENTATION, + + /* AL_SOFT_source_length */ + ByteLength = AL_BYTE_LENGTH_SOFT, + SampleLength = AL_SAMPLE_LENGTH_SOFT, + SecLength = AL_SEC_LENGTH_SOFT, + + /* AL_SOFT_source_resampler */ + Resampler = AL_SOURCE_RESAMPLER_SOFT, + + /* AL_SOFT_source_spatialize */ + Spatialize = AL_SOURCE_SPATIALIZE_SOFT, + + /* ALC_SOFT_device_clock */ + SampleOffsetClockSOFT = AL_SAMPLE_OFFSET_CLOCK_SOFT, + SecOffsetClockSOFT = AL_SEC_OFFSET_CLOCK_SOFT, + + /* AL_SOFT_UHJ */ + StereoMode = AL_STEREO_MODE_SOFT, + SuperStereoWidth = AL_SUPER_STEREO_WIDTH_SOFT, + + /* AL_SOFT_buffer_sub_data */ + ByteRWOffsetsSOFT = AL_BYTE_RW_OFFSETS_SOFT, + SampleRWOffsetsSOFT = AL_SAMPLE_RW_OFFSETS_SOFT, + + /* AL_SOFT_source_panning */ + PanningEnabledSOFT = AL_PANNING_ENABLED_SOFT, + PanSOFT = AL_PAN_SOFT, +}; + constexpr auto HasBuffer(al::BufferQueueItem const &item) noexcept -> bool { return bool{item.mBuffer}; } @@ -298,8 +390,8 @@ auto GetSourceSecOffset(gsl::not_null const Source, * (Bytes, Samples or Seconds). The offset is relative to the start of the * queue (not the start of the current buffer). */ -template -NOINLINE auto GetSourceOffset(gsl::not_null const Source, ALenum const name, +template NOINLINE +auto GetSourceOffset(gsl::not_null const Source, SourceProp const name, gsl::not_null const context) -> T { auto const device = al::get_not_null(context->mALDevice); @@ -338,7 +430,7 @@ NOINLINE auto GetSourceOffset(gsl::not_null const Source, ALenum co switch(name) { - case AL_SEC_OFFSET: + case SourceProp::SecOffset: if constexpr(std::floating_point) { const auto offset = gsl::narrow_cast(readPos.c_val) @@ -348,28 +440,35 @@ NOINLINE auto GetSourceOffset(gsl::not_null const Source, ALenum co else return al::saturate_cast(readPos.c_val / BufferFmt->mSampleRate); - case AL_SAMPLE_OFFSET: + case SourceProp::SampleOffset: if constexpr(std::floating_point) return gsl::narrow_cast(readPos.c_val) + gsl::narrow_cast(readPosFrac.c_val)/T{MixerFracOne}; else return al::saturate_cast(readPos.c_val); - case AL_BYTE_OFFSET: - /* Round down to the block boundary. */ - const auto BlockSize = BufferFmt->blockSizeFromFmt(); - readPos = readPos / i64{BufferFmt->mBlockAlign} * i64{BlockSize}; - - if constexpr(std::floating_point) - return gsl::narrow_cast(readPos.c_val); - else + case SourceProp::ByteOffset: { - if(readPos > std::numeric_limits::max()) - return RoundToZero(std::numeric_limits::max(), gsl::narrow_cast(BlockSize)); - if(readPos < std::numeric_limits::min()) - return RoundToZero(std::numeric_limits::min(), gsl::narrow_cast(BlockSize)); - return gsl::narrow_cast(readPos.c_val); + /* Round down to the block boundary. */ + const auto BlockSize = BufferFmt->blockSizeFromFmt(); + readPos = readPos / BufferFmt->mBlockAlign * BlockSize; + + if constexpr(std::floating_point) + return gsl::narrow_cast(readPos.c_val); + else + { + if(readPos > std::numeric_limits::max()) + return RoundToZero(std::numeric_limits::max(), + gsl::narrow_cast(BlockSize)); + if(readPos < std::numeric_limits::min()) + return RoundToZero(std::numeric_limits::min(), + gsl::narrow_cast(BlockSize)); + return gsl::narrow_cast(readPos.c_val); + } } + + default: + break; } return T{0}; } @@ -380,7 +479,7 @@ NOINLINE auto GetSourceOffset(gsl::not_null const Source, ALenum co * format (Bytes, Samples or Seconds). */ template NOINLINE -auto GetSourceLength(gsl::not_null const source, ALenum const name) -> T +auto GetSourceLength(gsl::not_null const source, SourceProp const name) -> T { const auto BufferFmt = std::invoke([source]() -> al::Buffer* { @@ -393,38 +492,43 @@ auto GetSourceLength(gsl::not_null const source, ALenum const return T{0}; const auto length = std::accumulate(source->mQueue.begin(), source->mQueue.end(), 0_u64, - [](u64 const count, al::BufferQueueItem const &item) - { return count + u64{item.mSampleLen}; }); + [](u64 const count, al::BufferQueueItem const &item) { return count + item.mSampleLen; }); if(length == 0) return T{0}; switch(name) { - case AL_SEC_LENGTH_SOFT: + case SourceProp::SecLength: if constexpr(std::floating_point) return gsl::narrow_cast(length.c_val) / gsl::narrow_cast(BufferFmt->mSampleRate); else return al::saturate_cast(length.c_val / BufferFmt->mSampleRate); - case AL_SAMPLE_LENGTH_SOFT: + case SourceProp::SampleLength: if constexpr(std::floating_point) return gsl::narrow_cast(length.c_val); else return al::saturate_cast(length.c_val); - case AL_BYTE_LENGTH_SOFT: - /* Round down to the block boundary. */ - const auto BlockSize = BufferFmt->blockSizeFromFmt(); - const auto alignedlen = length / u64{BufferFmt->mBlockAlign} * u64{BlockSize}; - - if constexpr(std::floating_point) - return gsl::narrow_cast(alignedlen.c_val); - else + case SourceProp::ByteLength: { - if(alignedlen > std::numeric_limits::max()) - return RoundToZero(std::numeric_limits::max(), gsl::narrow_cast(BlockSize)); - return gsl::narrow_cast(alignedlen.c_val); + /* Round down to the block boundary. */ + const auto BlockSize = BufferFmt->blockSizeFromFmt(); + const auto alignedlen = length / BufferFmt->mBlockAlign * BlockSize; + + if constexpr(std::floating_point) + return gsl::narrow_cast(alignedlen.c_val); + else + { + if(alignedlen > std::numeric_limits::max()) + return RoundToZero(std::numeric_limits::max(), + gsl::narrow_cast(BlockSize)); + return gsl::narrow_cast(alignedlen.c_val); + } } + + default: + break; } return T{0}; } @@ -443,7 +547,7 @@ struct VoicePos { * using the given offset type and offset. If the offset is out of range, * returns an empty optional. */ -auto GetSampleOffset(std::deque &BufferList, ALenum const OffsetType, +auto GetSampleOffset(std::deque &BufferList, SourceProp const OffsetType, f64 const Offset) -> std::optional { /* Find the first valid Buffer in the Queue */ @@ -464,8 +568,8 @@ auto GetSampleOffset(std::deque &BufferList, ALenum const O auto dblfrac = f64{}; switch(OffsetType) { - case AL_SEC_OFFSET: - dblfrac = (Offset*f64{BufferFmt->mSampleRate}).modf(dbloff); + case SourceProp::SecOffset: + dblfrac = (Offset*BufferFmt->mSampleRate).modf(dbloff); if(dblfrac < 0.0) { /* If there's a negative fraction, reduce the offset to "floor" @@ -478,7 +582,7 @@ auto GetSampleOffset(std::deque &BufferList, ALenum const O return {dbloff.reinterpret_as(), std::min(dblfrac*MixerFracOne, MixerFracOne-1.0_f64).reinterpret_as()}; - case AL_SAMPLE_OFFSET: + case SourceProp::SampleOffset: dblfrac = Offset.modf(dbloff); if(dblfrac < 0.0) { @@ -488,11 +592,16 @@ auto GetSampleOffset(std::deque &BufferList, ALenum const O return {dbloff.reinterpret_as(), std::min(dblfrac*MixerFracOne, MixerFracOne-1.0_f64).reinterpret_as()}; - case AL_BYTE_OFFSET: - /* Determine the ByteOffset (and ensure it is block aligned) */ - const auto blockoffset = (Offset / f64{BufferFmt->blockSizeFromFmt()}).floor(); - return {blockoffset.reinterpret_as()*i64{BufferFmt->mBlockAlign}, - 0_u32}; + case SourceProp::ByteOffset: + { + /* Determine the ByteOffset (and ensure it is block aligned) */ + const auto blockoffset = (Offset / BufferFmt->blockSizeFromFmt()).floor(); + return {blockoffset.reinterpret_as()*i64{BufferFmt->mBlockAlign}, + 0_u32}; + } + + default: + break; } return {0_i64, 0_u32}; }); @@ -502,7 +611,8 @@ auto GetSampleOffset(std::deque &BufferList, ALenum const O { if(offset < i32::min()) return std::nullopt; - return VoicePos{offset.reinterpret_as(), frac, &BufferList.front()}; + return VoicePos{.pos = offset.reinterpret_as(), .frac = frac, + .bufferitem = &BufferList.front()}; } if(BufferFmt->mCallback) @@ -518,7 +628,7 @@ auto GetSampleOffset(std::deque &BufferList, ALenum const O if(iter != BufferList.end()) { /* Offset is in this buffer */ - return VoicePos{offset.reinterpret_as(), frac, &*iter}; + return VoicePos{.pos = offset.reinterpret_as(), .frac = frac, .bufferitem = &*iter}; } /* Offset is out of range of the queue */ @@ -546,8 +656,8 @@ void InitVoice(Voice *const voice, gsl::not_null const source, voice->mAmbiScaling = IsUHJ(voice->mFmtChannels) ? AmbiScaling::N3D : buffer->mAmbiScaling; voice->mAmbiOrder = (voice->mFmtChannels == FmtSuperStereo) ? 1 : buffer->mAmbiOrder; - if(buffer->mCallback) voice->mFlags.set(VoiceIsCallback); - else if(source->mSourceType == AL_STATIC) voice->mFlags.set(VoiceIsStatic); + if(buffer->mCallback) voice->mFlags.set(VoiceFlag::IsCallback); + else if(source->mSourceType == AL_STATIC) voice->mFlags.set(VoiceFlag::IsStatic); voice->mNumCallbackBlocks = 0; voice->mCallbackBlockOffset = 0; @@ -662,7 +772,7 @@ auto SetVoiceOffset(Voice *const oldvoice, const VoicePos &vpos, newvoice->mFlags.reset(); if(vpos.pos > 0 || (vpos.pos == 0 && vpos.frac > 0) || vpos.bufferitem != &source->mQueue.front()) - newvoice->mFlags.set(VoiceIsFading); + newvoice->mFlags.set(VoiceFlag::IsFading); InitVoice(newvoice, source, vpos.bufferitem, context, device); source->mVoiceIdx = vidx; @@ -727,9 +837,9 @@ auto GetSourceState(gsl::not_null const source, Voice const *const auto EnsureSources(gsl::not_null const context, usize const needed) -> bool { - auto count = std::accumulate(context->mSourceList.cbegin(), context->mSourceList.cend(), 0_uz, - [](usize const cur, const SourceSubList &sublist) noexcept -> usize - { return cur + sublist.mFreeMask.popcount().c_val; }); + auto count = std::accumulate(context->mSourceList.cbegin(), context->mSourceList.cend(), + 0_usize, [](usize const cur, const SourceSubList &sublist) noexcept -> usize + { return cur + sublist.mFreeMask.popcount(); }); try { while(needed > count) @@ -757,7 +867,7 @@ auto AllocSource(gsl::not_null const context) noexcept -> gsl::not [](SourceSubList const &slist) { return slist.mFreeMask != 0; }); auto const lidx = gsl::narrow_cast(std::distance(context->mSourceList.begin(), sublist)); - auto const slidx = gsl::narrow_cast(sublist->mFreeMask.countr_zero().c_val); + auto const slidx = sublist->mFreeMask.countr_zero().c_val; ASSUME(slidx < 64); auto const source = gsl::make_not_null(std::construct_at( @@ -780,7 +890,7 @@ void FreeSource(gsl::not_null const context, gsl::not_nullmSourceNames.erase(source->mId); auto const id = source->mId - 1; - auto const lidx = usize{id >> 6}; + auto const lidx = std::size_t{id >> 6}; auto const slidx = id & 0x3f; if(auto *const voice = GetSourceVoice(source, context)) @@ -835,11 +945,11 @@ auto LookupBuffer(std::nothrow_t, gsl::not_null const device, if(lidx >= device->BufferList.size()) [[unlikely]] return nullptr; - auto &sublist = device->BufferList[gsl::narrow_cast(lidx)]; + auto &sublist = device->BufferList[gsl::narrow_cast(lidx)]; if((sublist.mFreeMask & (1_u64 << slidx)) != 0) [[unlikely]] return nullptr; return std::to_address(std::next(sublist.mBuffers->begin(), - gsl::narrow_cast(slidx))); + gsl::narrow_cast(slidx))); } [[nodiscard]] @@ -860,11 +970,11 @@ auto LookupFilter(std::nothrow_t, gsl::not_null const device, if(lidx >= device->FilterList.size()) [[unlikely]] return nullptr; - auto &sublist = device->FilterList[gsl::narrow_cast(lidx)]; + auto &sublist = device->FilterList[gsl::narrow_cast(lidx)]; if((sublist.mFreeMask & (1_u64 << slidx)) != 0) [[unlikely]] return nullptr; return std::to_address(std::next(sublist.mFilters->begin(), - gsl::narrow_cast(slidx))); + gsl::narrow_cast(slidx))); } [[nodiscard]] @@ -885,10 +995,11 @@ auto LookupEffectSlot(std::nothrow_t, gsl::not_null const context, if(lidx >= context->mEffectSlotList.size()) [[unlikely]] return nullptr; - auto &sublist = context->mEffectSlotList[gsl::narrow_cast(lidx)]; + auto &sublist = context->mEffectSlotList[gsl::narrow_cast(lidx)]; if((sublist.mFreeMask & (1_u64 << slidx)) != 0) [[unlikely]] return nullptr; - return std::to_address(sublist.mEffectSlots->begin() + gsl::narrow_cast(slidx)); + return std::to_address(std::next(sublist.mEffectSlots->begin(), + gsl::narrow_cast(slidx))); } [[nodiscard]] @@ -997,165 +1108,80 @@ auto ALenumFromDistanceModel(DistanceModel const model) -> ALenum int{al::to_underlying(model)})}; } -enum SourceProp : ALenum { - srcPitch = AL_PITCH, - srcGain = AL_GAIN, - srcMinGain = AL_MIN_GAIN, - srcMaxGain = AL_MAX_GAIN, - srcMaxDistance = AL_MAX_DISTANCE, - srcRolloffFactor = AL_ROLLOFF_FACTOR, - srcDopplerFactor = AL_DOPPLER_FACTOR, - srcConeOuterGain = AL_CONE_OUTER_GAIN, - srcSecOffset = AL_SEC_OFFSET, - srcSampleOffset = AL_SAMPLE_OFFSET, - srcByteOffset = AL_BYTE_OFFSET, - srcConeInnerAngle = AL_CONE_INNER_ANGLE, - srcConeOuterAngle = AL_CONE_OUTER_ANGLE, - srcRefDistance = AL_REFERENCE_DISTANCE, - - srcPosition = AL_POSITION, - srcVelocity = AL_VELOCITY, - srcDirection = AL_DIRECTION, - - srcSourceRelative = AL_SOURCE_RELATIVE, - srcLooping = AL_LOOPING, - srcBuffer = AL_BUFFER, - srcSourceState = AL_SOURCE_STATE, - srcBuffersQueued = AL_BUFFERS_QUEUED, - srcBuffersProcessed = AL_BUFFERS_PROCESSED, - srcSourceType = AL_SOURCE_TYPE, - - /* ALC_EXT_EFX */ - srcConeOuterGainHF = AL_CONE_OUTER_GAINHF, - srcAirAbsorptionFactor = AL_AIR_ABSORPTION_FACTOR, - srcRoomRolloffFactor = AL_ROOM_ROLLOFF_FACTOR, - srcDirectFilterGainHFAuto = AL_DIRECT_FILTER_GAINHF_AUTO, - srcAuxSendFilterGainAuto = AL_AUXILIARY_SEND_FILTER_GAIN_AUTO, - srcAuxSendFilterGainHFAuto = AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO, - srcDirectFilter = AL_DIRECT_FILTER, - srcAuxSendFilter = AL_AUXILIARY_SEND_FILTER, - - /* AL_SOFT_direct_channels */ - srcDirectChannelsSOFT = AL_DIRECT_CHANNELS_SOFT, - - /* AL_EXT_source_distance_model */ - srcDistanceModel = AL_DISTANCE_MODEL, - - /* AL_SOFT_source_latency */ - srcSampleOffsetLatencySOFT = AL_SAMPLE_OFFSET_LATENCY_SOFT, - srcSecOffsetLatencySOFT = AL_SEC_OFFSET_LATENCY_SOFT, - - /* AL_EXT_STEREO_ANGLES */ - srcAngles = AL_STEREO_ANGLES, - - /* AL_EXT_SOURCE_RADIUS */ - srcRadius = AL_SOURCE_RADIUS, - - /* AL_EXT_BFORMAT */ - srcOrientation = AL_ORIENTATION, - - /* AL_SOFT_source_length */ - srcByteLength = AL_BYTE_LENGTH_SOFT, - srcSampleLength = AL_SAMPLE_LENGTH_SOFT, - srcSecLength = AL_SEC_LENGTH_SOFT, - - /* AL_SOFT_source_resampler */ - srcResampler = AL_SOURCE_RESAMPLER_SOFT, - - /* AL_SOFT_source_spatialize */ - srcSpatialize = AL_SOURCE_SPATIALIZE_SOFT, - - /* ALC_SOFT_device_clock */ - srcSampleOffsetClockSOFT = AL_SAMPLE_OFFSET_CLOCK_SOFT, - srcSecOffsetClockSOFT = AL_SEC_OFFSET_CLOCK_SOFT, - - /* AL_SOFT_UHJ */ - srcStereoMode = AL_STEREO_MODE_SOFT, - srcSuperStereoWidth = AL_SUPER_STEREO_WIDTH_SOFT, - - /* AL_SOFT_buffer_sub_data */ - srcByteRWOffsetsSOFT = AL_BYTE_RW_OFFSETS_SOFT, - srcSampleRWOffsetsSOFT = AL_SAMPLE_RW_OFFSETS_SOFT, - - /* AL_SOFT_source_panning */ - srcPanningEnabledSOFT = AL_PANNING_ENABLED_SOFT, - srcPanSOFT = AL_PAN_SOFT, -}; - [[nodiscard]] constexpr auto IntValsByProp(ALenum const prop) -> ALuint { switch(SourceProp{prop}) { - case AL_SOURCE_STATE: - case AL_SOURCE_TYPE: - case AL_BUFFERS_QUEUED: - case AL_BUFFERS_PROCESSED: - case AL_BYTE_LENGTH_SOFT: - case AL_SAMPLE_LENGTH_SOFT: - case AL_SOURCE_RELATIVE: - case AL_LOOPING: - case AL_BUFFER: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_DIRECT_FILTER: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DIRECT_CHANNELS_SOFT: - case AL_DISTANCE_MODEL: - case AL_SOURCE_RESAMPLER_SOFT: - case AL_SOURCE_SPATIALIZE_SOFT: - case AL_STEREO_MODE_SOFT: - case AL_PANNING_ENABLED_SOFT: - case AL_PAN_SOFT: + case SourceProp::SourceState: + case SourceProp::SourceType: + case SourceProp::BuffersQueued: + case SourceProp::BuffersProcessed: + case SourceProp::ByteLength: + case SourceProp::SampleLength: + case SourceProp::SourceRelative: + case SourceProp::Looping: + case SourceProp::Buffer: + case SourceProp::SampleOffset: + case SourceProp::ByteOffset: + case SourceProp::DirectFilter: + case SourceProp::DirectFilterGainHFAuto: + case SourceProp::AuxSendFilterGainAuto: + case SourceProp::AuxSendFilterGainHFAuto: + case SourceProp::DirectChannelsSOFT: + case SourceProp::DistanceModel: + case SourceProp::Resampler: + case SourceProp::Spatialize: + case SourceProp::StereoMode: + case SourceProp::PanningEnabledSOFT: + case SourceProp::PanSOFT: return 1; - case AL_SOURCE_RADIUS: /*AL_BYTE_RW_OFFSETS_SOFT:*/ + case SourceProp::Radius: /*ByteRWOffsetsSOFT:*/ if(sBufferSubDataCompat) return 2; [[fallthrough]]; - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_PITCH: - case AL_GAIN: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_REFERENCE_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_CONE_OUTER_GAIN: - case AL_MAX_DISTANCE: - case AL_SEC_OFFSET: - case AL_DOPPLER_FACTOR: - case AL_CONE_OUTER_GAINHF: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - case AL_SEC_LENGTH_SOFT: - case AL_SUPER_STEREO_WIDTH_SOFT: + case SourceProp::ConeInnerAngle: + case SourceProp::ConeOuterAngle: + case SourceProp::Pitch: + case SourceProp::Gain: + case SourceProp::MinGain: + case SourceProp::MaxGain: + case SourceProp::RefDistance: + case SourceProp::RolloffFactor: + case SourceProp::ConeOuterGain: + case SourceProp::MaxDistance: + case SourceProp::SecOffset: + case SourceProp::DopplerFactor: + case SourceProp::ConeOuterGainHF: + case SourceProp::AirAbsorptionFactor: + case SourceProp::RoomRolloffFactor: + case SourceProp::SecLength: + case SourceProp::SuperStereoWidth: return 1; /* 1x float */ - case AL_SAMPLE_RW_OFFSETS_SOFT: + case SourceProp::SampleRWOffsetsSOFT: if(sBufferSubDataCompat) return 2; break; - case AL_AUXILIARY_SEND_FILTER: + case SourceProp::AuxSendFilter: return 3; - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: + case SourceProp::Position: + case SourceProp::Velocity: + case SourceProp::Direction: return 3; /* 3x float */ - case AL_ORIENTATION: + case SourceProp::Orientation: return 6; /* 6x float */ - case AL_SAMPLE_OFFSET_LATENCY_SOFT: - case AL_SAMPLE_OFFSET_CLOCK_SOFT: - case AL_STEREO_ANGLES: + case SourceProp::SampleOffsetLatencySOFT: + case SourceProp::SampleOffsetClockSOFT: + case SourceProp::StereoAngles: break; /* i64 only */ - case AL_SEC_OFFSET_LATENCY_SOFT: - case AL_SEC_OFFSET_CLOCK_SOFT: + case SourceProp::SecOffsetLatencySOFT: + case SourceProp::SecOffsetClockSOFT: break; /* double only */ } @@ -1167,76 +1193,76 @@ constexpr auto Int64ValsByProp(ALenum const prop) -> ALuint { switch(SourceProp{prop}) { - case AL_SOURCE_STATE: - case AL_SOURCE_TYPE: - case AL_BUFFERS_QUEUED: - case AL_BUFFERS_PROCESSED: - case AL_BYTE_LENGTH_SOFT: - case AL_SAMPLE_LENGTH_SOFT: - case AL_SOURCE_RELATIVE: - case AL_LOOPING: - case AL_BUFFER: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_DIRECT_FILTER: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DIRECT_CHANNELS_SOFT: - case AL_DISTANCE_MODEL: - case AL_SOURCE_RESAMPLER_SOFT: - case AL_SOURCE_SPATIALIZE_SOFT: - case AL_STEREO_MODE_SOFT: - case AL_PANNING_ENABLED_SOFT: - case AL_PAN_SOFT: + case SourceProp::SourceState: + case SourceProp::SourceType: + case SourceProp::BuffersQueued: + case SourceProp::BuffersProcessed: + case SourceProp::ByteLength: + case SourceProp::SampleLength: + case SourceProp::SourceRelative: + case SourceProp::Looping: + case SourceProp::Buffer: + case SourceProp::SampleOffset: + case SourceProp::ByteOffset: + case SourceProp::DirectFilter: + case SourceProp::DirectFilterGainHFAuto: + case SourceProp::AuxSendFilterGainAuto: + case SourceProp::AuxSendFilterGainHFAuto: + case SourceProp::DirectChannelsSOFT: + case SourceProp::DistanceModel: + case SourceProp::Resampler: + case SourceProp::Spatialize: + case SourceProp::StereoMode: + case SourceProp::PanningEnabledSOFT: + case SourceProp::PanSOFT: return 1; - case AL_SOURCE_RADIUS: /*AL_BYTE_RW_OFFSETS_SOFT:*/ + case SourceProp::Radius: /*ByteRWOffsetsSOFT:*/ if(sBufferSubDataCompat) return 2; [[fallthrough]]; - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_PITCH: - case AL_GAIN: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_REFERENCE_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_CONE_OUTER_GAIN: - case AL_MAX_DISTANCE: - case AL_SEC_OFFSET: - case AL_DOPPLER_FACTOR: - case AL_CONE_OUTER_GAINHF: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - case AL_SEC_LENGTH_SOFT: - case AL_SUPER_STEREO_WIDTH_SOFT: + case SourceProp::ConeInnerAngle: + case SourceProp::ConeOuterAngle: + case SourceProp::Pitch: + case SourceProp::Gain: + case SourceProp::MinGain: + case SourceProp::MaxGain: + case SourceProp::RefDistance: + case SourceProp::RolloffFactor: + case SourceProp::ConeOuterGain: + case SourceProp::MaxDistance: + case SourceProp::SecOffset: + case SourceProp::DopplerFactor: + case SourceProp::ConeOuterGainHF: + case SourceProp::AirAbsorptionFactor: + case SourceProp::RoomRolloffFactor: + case SourceProp::SecLength: + case SourceProp::SuperStereoWidth: return 1; /* 1x float */ - case AL_SAMPLE_RW_OFFSETS_SOFT: + case SourceProp::SampleRWOffsetsSOFT: if(sBufferSubDataCompat) return 2; break; - case AL_SAMPLE_OFFSET_LATENCY_SOFT: - case AL_SAMPLE_OFFSET_CLOCK_SOFT: - case AL_STEREO_ANGLES: + case SourceProp::SampleOffsetLatencySOFT: + case SourceProp::SampleOffsetClockSOFT: + case SourceProp::StereoAngles: return 2; - case AL_AUXILIARY_SEND_FILTER: + case SourceProp::AuxSendFilter: return 3; - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: + case SourceProp::Position: + case SourceProp::Velocity: + case SourceProp::Direction: return 3; /* 3x float */ - case AL_ORIENTATION: + case SourceProp::Orientation: return 6; /* 6x float */ - case AL_SEC_OFFSET_LATENCY_SOFT: - case AL_SEC_OFFSET_CLOCK_SOFT: + case SourceProp::SecOffsetLatencySOFT: + case SourceProp::SecOffsetClockSOFT: break; /* double only */ } @@ -1248,73 +1274,73 @@ constexpr auto FloatValsByProp(ALenum const prop) -> ALuint { switch(SourceProp{prop}) { - case AL_PITCH: - case AL_GAIN: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_DOPPLER_FACTOR: - case AL_CONE_OUTER_GAIN: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_REFERENCE_DISTANCE: - case AL_CONE_OUTER_GAINHF: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DIRECT_CHANNELS_SOFT: - case AL_DISTANCE_MODEL: - case AL_SOURCE_RELATIVE: - case AL_LOOPING: - case AL_SOURCE_STATE: - case AL_BUFFERS_QUEUED: - case AL_BUFFERS_PROCESSED: - case AL_SOURCE_TYPE: - case AL_SOURCE_RESAMPLER_SOFT: - case AL_SOURCE_SPATIALIZE_SOFT: - case AL_BYTE_LENGTH_SOFT: - case AL_SAMPLE_LENGTH_SOFT: - case AL_SEC_LENGTH_SOFT: - case AL_STEREO_MODE_SOFT: - case AL_SUPER_STEREO_WIDTH_SOFT: - case AL_PANNING_ENABLED_SOFT: - case AL_PAN_SOFT: + case SourceProp::Pitch: + case SourceProp::Gain: + case SourceProp::MinGain: + case SourceProp::MaxGain: + case SourceProp::MaxDistance: + case SourceProp::RolloffFactor: + case SourceProp::DopplerFactor: + case SourceProp::ConeOuterGain: + case SourceProp::SecOffset: + case SourceProp::SampleOffset: + case SourceProp::ByteOffset: + case SourceProp::ConeInnerAngle: + case SourceProp::ConeOuterAngle: + case SourceProp::RefDistance: + case SourceProp::ConeOuterGainHF: + case SourceProp::AirAbsorptionFactor: + case SourceProp::RoomRolloffFactor: + case SourceProp::DirectFilterGainHFAuto: + case SourceProp::AuxSendFilterGainAuto: + case SourceProp::AuxSendFilterGainHFAuto: + case SourceProp::DirectChannelsSOFT: + case SourceProp::DistanceModel: + case SourceProp::SourceRelative: + case SourceProp::Looping: + case SourceProp::SourceState: + case SourceProp::BuffersQueued: + case SourceProp::BuffersProcessed: + case SourceProp::SourceType: + case SourceProp::Resampler: + case SourceProp::Spatialize: + case SourceProp::ByteLength: + case SourceProp::SampleLength: + case SourceProp::SecLength: + case SourceProp::StereoMode: + case SourceProp::SuperStereoWidth: + case SourceProp::PanningEnabledSOFT: + case SourceProp::PanSOFT: return 1; - case AL_SOURCE_RADIUS: /*AL_BYTE_RW_OFFSETS_SOFT:*/ + case SourceProp::Radius: /*ByteRWOffsetsSOFT:*/ if(!sBufferSubDataCompat) return 1; [[fallthrough]]; - case AL_SAMPLE_RW_OFFSETS_SOFT: + case SourceProp::SampleRWOffsetsSOFT: break; - case AL_STEREO_ANGLES: + case SourceProp::StereoAngles: return 2; - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: + case SourceProp::Position: + case SourceProp::Velocity: + case SourceProp::Direction: return 3; - case AL_ORIENTATION: + case SourceProp::Orientation: return 6; - case AL_SEC_OFFSET_LATENCY_SOFT: - case AL_SEC_OFFSET_CLOCK_SOFT: + case SourceProp::SecOffsetLatencySOFT: + case SourceProp::SecOffsetClockSOFT: break; /* Double only */ - case AL_BUFFER: - case AL_DIRECT_FILTER: - case AL_AUXILIARY_SEND_FILTER: + case SourceProp::Buffer: + case SourceProp::DirectFilter: + case SourceProp::AuxSendFilter: break; /* i/i64 only */ - case AL_SAMPLE_OFFSET_LATENCY_SOFT: - case AL_SAMPLE_OFFSET_CLOCK_SOFT: + case SourceProp::SampleOffsetLatencySOFT: + case SourceProp::SampleOffsetClockSOFT: break; /* i64 only */ } return 0; @@ -1324,71 +1350,71 @@ constexpr auto DoubleValsByProp(ALenum const prop) -> ALuint { switch(SourceProp{prop}) { - case AL_PITCH: - case AL_GAIN: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_DOPPLER_FACTOR: - case AL_CONE_OUTER_GAIN: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_REFERENCE_DISTANCE: - case AL_CONE_OUTER_GAINHF: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DIRECT_CHANNELS_SOFT: - case AL_DISTANCE_MODEL: - case AL_SOURCE_RELATIVE: - case AL_LOOPING: - case AL_SOURCE_STATE: - case AL_BUFFERS_QUEUED: - case AL_BUFFERS_PROCESSED: - case AL_SOURCE_TYPE: - case AL_SOURCE_RESAMPLER_SOFT: - case AL_SOURCE_SPATIALIZE_SOFT: - case AL_BYTE_LENGTH_SOFT: - case AL_SAMPLE_LENGTH_SOFT: - case AL_SEC_LENGTH_SOFT: - case AL_STEREO_MODE_SOFT: - case AL_SUPER_STEREO_WIDTH_SOFT: - case AL_PANNING_ENABLED_SOFT: - case AL_PAN_SOFT: + case SourceProp::Pitch: + case SourceProp::Gain: + case SourceProp::MinGain: + case SourceProp::MaxGain: + case SourceProp::MaxDistance: + case SourceProp::RolloffFactor: + case SourceProp::DopplerFactor: + case SourceProp::ConeOuterGain: + case SourceProp::SecOffset: + case SourceProp::SampleOffset: + case SourceProp::ByteOffset: + case SourceProp::ConeInnerAngle: + case SourceProp::ConeOuterAngle: + case SourceProp::RefDistance: + case SourceProp::ConeOuterGainHF: + case SourceProp::AirAbsorptionFactor: + case SourceProp::RoomRolloffFactor: + case SourceProp::DirectFilterGainHFAuto: + case SourceProp::AuxSendFilterGainAuto: + case SourceProp::AuxSendFilterGainHFAuto: + case SourceProp::DirectChannelsSOFT: + case SourceProp::DistanceModel: + case SourceProp::SourceRelative: + case SourceProp::Looping: + case SourceProp::SourceState: + case SourceProp::BuffersQueued: + case SourceProp::BuffersProcessed: + case SourceProp::SourceType: + case SourceProp::Resampler: + case SourceProp::Spatialize: + case SourceProp::ByteLength: + case SourceProp::SampleLength: + case SourceProp::SecLength: + case SourceProp::StereoMode: + case SourceProp::SuperStereoWidth: + case SourceProp::PanningEnabledSOFT: + case SourceProp::PanSOFT: return 1; - case AL_SOURCE_RADIUS: /*AL_BYTE_RW_OFFSETS_SOFT:*/ + case SourceProp::Radius: /*ByteRWOffsetsSOFT:*/ if(!sBufferSubDataCompat) return 1; [[fallthrough]]; - case AL_SAMPLE_RW_OFFSETS_SOFT: + case SourceProp::SampleRWOffsetsSOFT: break; - case AL_SEC_OFFSET_LATENCY_SOFT: - case AL_SEC_OFFSET_CLOCK_SOFT: - case AL_STEREO_ANGLES: + case SourceProp::SecOffsetLatencySOFT: + case SourceProp::SecOffsetClockSOFT: + case SourceProp::StereoAngles: return 2; - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: + case SourceProp::Position: + case SourceProp::Velocity: + case SourceProp::Direction: return 3; - case AL_ORIENTATION: + case SourceProp::Orientation: return 6; - case AL_BUFFER: - case AL_DIRECT_FILTER: - case AL_AUXILIARY_SEND_FILTER: + case SourceProp::Buffer: + case SourceProp::DirectFilter: + case SourceProp::AuxSendFilter: break; /* i/i64 only */ - case AL_SAMPLE_OFFSET_LATENCY_SOFT: - case AL_SAMPLE_OFFSET_CLOCK_SOFT: + case SourceProp::SampleOffsetLatencySOFT: + case SourceProp::SampleOffsetClockSOFT: break; /* i64 only */ } return 0; @@ -1445,6 +1471,12 @@ template<> auto PropTypeName() -> std::string_view { return "double"sv; } +template +struct PairStruct { T First; U Second; }; + +template +PairStruct(T, U) -> PairStruct; + /** * Returns a pair of lambdas to check the following setter. * @@ -1454,18 +1486,12 @@ auto PropTypeName() -> std::string_view { return "double"sv; } * The second lambda tests the validity of the value check, throwing a context * error if it failed. */ -template -struct PairStruct { T First; U Second; }; - -template -PairStruct(T, U) -> PairStruct; - -template +template auto GetCheckers(gsl::not_null const context, SourceProp const prop, std::span const values) { return PairStruct{ - [=](usize const expect) -> void + [=](std::size_t const expect) -> void { if(values.size() == expect) return; context->throw_error(AL_INVALID_ENUM, "Property {:#04x} expects {} value{}, got {}", @@ -1492,10 +1518,10 @@ void SetProperty(const gsl::not_null Source, switch(prop) { - case AL_SOURCE_STATE: - case AL_SOURCE_TYPE: - case AL_BUFFERS_QUEUED: - case AL_BUFFERS_PROCESSED: + case SourceProp::SourceState: + case SourceProp::SourceType: + case SourceProp::BuffersQueued: + case SourceProp::BuffersProcessed: if constexpr(std::is_integral_v) { /* Query only */ @@ -1504,18 +1530,18 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_BYTE_LENGTH_SOFT: - case AL_SAMPLE_LENGTH_SOFT: - case AL_SEC_LENGTH_SOFT: - case AL_SAMPLE_OFFSET_LATENCY_SOFT: - case AL_SEC_OFFSET_LATENCY_SOFT: - case AL_SAMPLE_OFFSET_CLOCK_SOFT: - case AL_SEC_OFFSET_CLOCK_SOFT: + case SourceProp::ByteLength: + case SourceProp::SampleLength: + case SourceProp::SecLength: + case SourceProp::SampleOffsetLatencySOFT: + case SourceProp::SecOffsetLatencySOFT: + case SourceProp::SampleOffsetClockSOFT: + case SourceProp::SecOffsetClockSOFT: /* Query only */ Context->throw_error(AL_INVALID_OPERATION, "Setting read-only source property {:#04x}", as_unsigned(al::to_underlying(prop))); - case AL_PITCH: + case SourceProp::Pitch: CheckSize(1); if constexpr(std::is_floating_point_v) CheckValue(values[0] >= T{0} && is_finite(values[0])); @@ -1525,21 +1551,21 @@ void SetProperty(const gsl::not_null Source, Source->mPitch = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_CONE_INNER_ANGLE: + case SourceProp::ConeInnerAngle: CheckSize(1); CheckValue(values[0] >= T{0} && values[0] <= T{360}); Source->mInnerAngle = gsl::narrow_cast(values[0]); return CommitAndUpdateSourceProps(Source, Context); - case AL_CONE_OUTER_ANGLE: + case SourceProp::ConeOuterAngle: CheckSize(1); CheckValue(values[0] >= T{0} && values[0] <= T{360}); Source->mOuterAngle = gsl::narrow_cast(values[0]); return CommitAndUpdateSourceProps(Source, Context); - case AL_GAIN: + case SourceProp::Gain: CheckSize(1); if constexpr(std::is_floating_point_v) CheckValue(values[0] >= T{0} && is_finite(values[0])); @@ -1549,7 +1575,7 @@ void SetProperty(const gsl::not_null Source, Source->mGain = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_MAX_DISTANCE: + case SourceProp::MaxDistance: CheckSize(1); if constexpr(std::is_floating_point_v) CheckValue(values[0] >= T{0} && is_finite(values[0])); @@ -1559,7 +1585,7 @@ void SetProperty(const gsl::not_null Source, Source->mMaxDistance = gsl::narrow_cast(values[0]); return CommitAndUpdateSourceProps(Source, Context); - case AL_ROLLOFF_FACTOR: + case SourceProp::RolloffFactor: CheckSize(1); if constexpr(std::is_floating_point_v) CheckValue(values[0] >= T{0} && is_finite(values[0])); @@ -1569,7 +1595,7 @@ void SetProperty(const gsl::not_null Source, Source->mRolloffFactor = gsl::narrow_cast(values[0]); return CommitAndUpdateSourceProps(Source, Context); - case AL_REFERENCE_DISTANCE: + case SourceProp::RefDistance: CheckSize(1); if constexpr(std::is_floating_point_v) CheckValue(values[0] >= T{0} && is_finite(values[0])); @@ -1579,7 +1605,7 @@ void SetProperty(const gsl::not_null Source, Source->mRefDistance = gsl::narrow_cast(values[0]); return CommitAndUpdateSourceProps(Source, Context); - case AL_MIN_GAIN: + case SourceProp::MinGain: CheckSize(1); if constexpr(std::is_floating_point_v) CheckValue(values[0] >= T{0} && is_finite(values[0])); @@ -1589,7 +1615,7 @@ void SetProperty(const gsl::not_null Source, Source->mMinGain = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_MAX_GAIN: + case SourceProp::MaxGain: CheckSize(1); if constexpr(std::is_floating_point_v) CheckValue(values[0] >= T{0} && is_finite(values[0])); @@ -1599,35 +1625,35 @@ void SetProperty(const gsl::not_null Source, Source->mMaxGain = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_CONE_OUTER_GAIN: + case SourceProp::ConeOuterGain: CheckSize(1); CheckValue(values[0] >= T{0} && values[0] <= T{1}); Source->mOuterGain = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_CONE_OUTER_GAINHF: + case SourceProp::ConeOuterGainHF: CheckSize(1); CheckValue(values[0] >= T{0} && values[0] <= T{1}); Source->mOuterGainHF = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_AIR_ABSORPTION_FACTOR: + case SourceProp::AirAbsorptionFactor: CheckSize(1); CheckValue(values[0] >= T{0} && values[0] <= T{10}); Source->mAirAbsorptionFactor = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_ROOM_ROLLOFF_FACTOR: + case SourceProp::RoomRolloffFactor: CheckSize(1); CheckValue(values[0] >= T{0} && values[0] <= T{1}); Source->mRoomRolloffFactor = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_DOPPLER_FACTOR: + case SourceProp::DopplerFactor: CheckSize(1); CheckValue(values[0] >= T{0} && values[0] <= T{1}); @@ -1635,7 +1661,7 @@ void SetProperty(const gsl::not_null Source, return UpdateSourceProps(Source, Context); - case AL_SOURCE_RELATIVE: + case SourceProp::SourceRelative: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1646,7 +1672,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_LOOPING: + case SourceProp::Looping: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1670,7 +1696,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_BUFFER: + case SourceProp::Buffer: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1717,9 +1743,9 @@ void SetProperty(const gsl::not_null Source, break; - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: + case SourceProp::SecOffset: + case SourceProp::SampleOffset: + case SourceProp::ByteOffset: CheckSize(1); if constexpr(std::is_floating_point_v) CheckValue(std::isfinite(values[0])); @@ -1733,11 +1759,11 @@ void SetProperty(const gsl::not_null Source, if(SetVoiceOffset(voice, *vpos, Source, Context, device)) return; } - Source->mOffsetType = prop; + Source->mOffsetType = al::to_underlying(prop); Source->mOffset = gsl::narrow_cast(values[0]); return; - case AL_SAMPLE_RW_OFFSETS_SOFT: + case SourceProp::SampleRWOffsetsSOFT: if(sBufferSubDataCompat) { if constexpr(std::is_integral_v) @@ -1750,7 +1776,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_SOURCE_RADIUS: /*AL_BYTE_RW_OFFSETS_SOFT:*/ + case SourceProp::Radius: /*ByteRWOffsetsSOFT:*/ if(sBufferSubDataCompat) { if constexpr(std::is_integral_v) @@ -1771,28 +1797,28 @@ void SetProperty(const gsl::not_null Source, Source->mRadius = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_SUPER_STEREO_WIDTH_SOFT: + case SourceProp::SuperStereoWidth: CheckSize(1); CheckValue(values[0] >= T{0} && values[0] <= T{1}); Source->mEnhWidth = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_PANNING_ENABLED_SOFT: + case SourceProp::PanningEnabledSOFT: CheckSize(1); CheckValue(values[0] == AL_FALSE || values[0] == AL_TRUE); Source->mPanningEnabled = values[0] != AL_FALSE; return UpdateSourceProps(Source, Context); - case AL_PAN_SOFT: + case SourceProp::PanSOFT: CheckSize(1); CheckValue(values[0] >= T{-1} && values[0] <= T{1}); Source->mPan = gsl::narrow_cast(values[0]); return UpdateSourceProps(Source, Context); - case AL_STEREO_ANGLES: + case SourceProp::StereoAngles: CheckSize(2); if constexpr(std::is_floating_point_v) CheckValue(std::ranges::all_of(values, is_finite)); @@ -1802,7 +1828,7 @@ void SetProperty(const gsl::not_null Source, return UpdateSourceProps(Source, Context); - case AL_POSITION: + case SourceProp::Position: CheckSize(3); if constexpr(std::is_floating_point_v) CheckValue(std::ranges::all_of(values, is_finite)); @@ -1812,7 +1838,7 @@ void SetProperty(const gsl::not_null Source, Source->mPosition[2] = gsl::narrow_cast(values[2]); return CommitAndUpdateSourceProps(Source, Context); - case AL_VELOCITY: + case SourceProp::Velocity: CheckSize(3); if constexpr(std::is_floating_point_v) CheckValue(std::ranges::all_of(values, is_finite)); @@ -1822,7 +1848,7 @@ void SetProperty(const gsl::not_null Source, Source->mVelocity[2] = gsl::narrow_cast(values[2]); return CommitAndUpdateSourceProps(Source, Context); - case AL_DIRECTION: + case SourceProp::Direction: CheckSize(3); if constexpr(std::is_floating_point_v) CheckValue(std::ranges::all_of(values, is_finite)); @@ -1832,7 +1858,7 @@ void SetProperty(const gsl::not_null Source, Source->mDirection[2] = gsl::narrow_cast(values[2]); return CommitAndUpdateSourceProps(Source, Context); - case AL_ORIENTATION: + case SourceProp::Orientation: CheckSize(6); if constexpr(std::is_floating_point_v) CheckValue(std::ranges::all_of(values, is_finite)); @@ -1846,7 +1872,7 @@ void SetProperty(const gsl::not_null Source, return UpdateSourceProps(Source, Context); - case AL_DIRECT_FILTER: + case SourceProp::DirectFilter: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1873,7 +1899,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_DIRECT_FILTER_GAINHF_AUTO: + case SourceProp::DirectFilterGainHFAuto: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1884,7 +1910,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: + case SourceProp::AuxSendFilterGainAuto: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1895,7 +1921,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: + case SourceProp::AuxSendFilterGainHFAuto: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1906,7 +1932,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_DIRECT_CHANNELS_SOFT: + case SourceProp::DirectChannelsSOFT: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1920,7 +1946,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_DISTANCE_MODEL: + case SourceProp::DistanceModel: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1936,7 +1962,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_SOURCE_RESAMPLER_SOFT: + case SourceProp::Resampler: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1947,7 +1973,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_SOURCE_SPATIALIZE_SOFT: + case SourceProp::Spatialize: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1961,7 +1987,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_STEREO_MODE_SOFT: + case SourceProp::StereoMode: if constexpr(std::is_integral_v) { CheckSize(1); @@ -1980,7 +2006,7 @@ void SetProperty(const gsl::not_null Source, } break; - case AL_AUXILIARY_SEND_FILTER: + case SourceProp::AuxSendFilter: if constexpr(std::is_integral_v) { CheckSize(3); @@ -1995,7 +2021,7 @@ void SetProperty(const gsl::not_null Source, if(sendidx >= device->NumAuxSends) Context->throw_error(AL_INVALID_VALUE, "Invalid send {}", sendidx); - auto &send = Source->mSend[gsl::narrow_cast(sendidx)]; + auto &send = Source->mSend[gsl::narrow_cast(sendidx)]; if(filterid) { @@ -2044,11 +2070,11 @@ void SetProperty(const gsl::not_null Source, } -template +template auto GetSizeChecker(gsl::not_null const context, SourceProp const prop, std::span const values) { - return [=](usize const expect) -> void + return [=](std::size_t const expect) -> void { if(values.size() == expect) [[likely]] return; context->throw_error(AL_INVALID_ENUM, "Property {:#04x} expects {} value{}, got {}", @@ -2066,90 +2092,90 @@ void GetProperty(const gsl::not_null Source, switch(prop) { - case AL_GAIN: + case SourceProp::Gain: CheckSize(1); values[0] = gsl::narrow_cast(Source->mGain); return; - case AL_PITCH: + case SourceProp::Pitch: CheckSize(1); values[0] = gsl::narrow_cast(Source->mPitch); return; - case AL_MAX_DISTANCE: + case SourceProp::MaxDistance: CheckSize(1); values[0] = gsl::narrow_cast(Source->mMaxDistance); return; - case AL_ROLLOFF_FACTOR: + case SourceProp::RolloffFactor: CheckSize(1); values[0] = gsl::narrow_cast(Source->mRolloffFactor); return; - case AL_REFERENCE_DISTANCE: + case SourceProp::RefDistance: CheckSize(1); values[0] = gsl::narrow_cast(Source->mRefDistance); return; - case AL_CONE_INNER_ANGLE: + case SourceProp::ConeInnerAngle: CheckSize(1); values[0] = gsl::narrow_cast(Source->mInnerAngle); return; - case AL_CONE_OUTER_ANGLE: + case SourceProp::ConeOuterAngle: CheckSize(1); values[0] = gsl::narrow_cast(Source->mOuterAngle); return; - case AL_MIN_GAIN: + case SourceProp::MinGain: CheckSize(1); values[0] = gsl::narrow_cast(Source->mMinGain); return; - case AL_MAX_GAIN: + case SourceProp::MaxGain: CheckSize(1); values[0] = gsl::narrow_cast(Source->mMaxGain); return; - case AL_CONE_OUTER_GAIN: + case SourceProp::ConeOuterGain: CheckSize(1); values[0] = gsl::narrow_cast(Source->mOuterGain); return; - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: + case SourceProp::SecOffset: + case SourceProp::SampleOffset: + case SourceProp::ByteOffset: CheckSize(1); values[0] = GetSourceOffset(Source, prop, Context); return; - case AL_CONE_OUTER_GAINHF: + case SourceProp::ConeOuterGainHF: CheckSize(1); values[0] = gsl::narrow_cast(Source->mOuterGainHF); return; - case AL_AIR_ABSORPTION_FACTOR: + case SourceProp::AirAbsorptionFactor: CheckSize(1); values[0] = gsl::narrow_cast(Source->mAirAbsorptionFactor); return; - case AL_ROOM_ROLLOFF_FACTOR: + case SourceProp::RoomRolloffFactor: CheckSize(1); values[0] = gsl::narrow_cast(Source->mRoomRolloffFactor); return; - case AL_DOPPLER_FACTOR: + case SourceProp::DopplerFactor: CheckSize(1); values[0] = gsl::narrow_cast(Source->mDopplerFactor); return; - case AL_SAMPLE_RW_OFFSETS_SOFT: + case SourceProp::SampleRWOffsetsSOFT: if constexpr(std::is_integral_v) { if(sBufferSubDataCompat) { CheckSize(2); - values[0] = GetSourceOffset(Source, AL_SAMPLE_OFFSET, Context); + values[0] = GetSourceOffset(Source, SourceProp::SampleOffset, Context); /* FIXME: values[1] should be ahead of values[0] by the device * update time. It needs to clamp or wrap the length of the * buffer queue. @@ -2159,7 +2185,7 @@ void GetProperty(const gsl::not_null Source, } } break; - case AL_SOURCE_RADIUS: /*AL_BYTE_RW_OFFSETS_SOFT:*/ + case SourceProp::Radius: /*ByteRWOffsetsSOFT:*/ if constexpr(std::is_floating_point_v) { if(sBufferSubDataCompat) @@ -2173,7 +2199,7 @@ void GetProperty(const gsl::not_null Source, if(sBufferSubDataCompat) { CheckSize(2); - values[0] = GetSourceOffset(Source, AL_BYTE_OFFSET, Context); + values[0] = GetSourceOffset(Source, SourceProp::ByteOffset, Context); /* FIXME: values[1] should be ahead of values[0] by the device * update time. It needs to clamp or wrap the length of the * buffer queue. @@ -2188,29 +2214,29 @@ void GetProperty(const gsl::not_null Source, } return; - case AL_SUPER_STEREO_WIDTH_SOFT: + case SourceProp::SuperStereoWidth: CheckSize(1); values[0] = gsl::narrow_cast(Source->mEnhWidth); return; - case AL_BYTE_LENGTH_SOFT: - case AL_SAMPLE_LENGTH_SOFT: - case AL_SEC_LENGTH_SOFT: + case SourceProp::ByteLength: + case SourceProp::SampleLength: + case SourceProp::SecLength: CheckSize(1); values[0] = GetSourceLength(Source, prop); return; - case AL_PANNING_ENABLED_SOFT: + case SourceProp::PanningEnabledSOFT: CheckSize(1); values[0] = Source->mPanningEnabled; return; - case AL_PAN_SOFT: + case SourceProp::PanSOFT: CheckSize(1); values[0] = gsl::narrow_cast(Source->mPan); return; - case AL_STEREO_ANGLES: + case SourceProp::StereoAngles: if constexpr(std::is_floating_point_v) { CheckSize(2); @@ -2219,7 +2245,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_SAMPLE_OFFSET_LATENCY_SOFT: + case SourceProp::SampleOffsetLatencySOFT: if constexpr(std::is_same_v) { CheckSize(2); @@ -2248,7 +2274,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_SAMPLE_OFFSET_CLOCK_SOFT: + case SourceProp::SampleOffsetClockSOFT: if constexpr(std::is_same_v) { CheckSize(2); @@ -2259,7 +2285,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_SEC_OFFSET_LATENCY_SOFT: + case SourceProp::SecOffsetLatencySOFT: if constexpr(std::is_same_v) { CheckSize(2); @@ -2288,7 +2314,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_SEC_OFFSET_CLOCK_SOFT: + case SourceProp::SecOffsetClockSOFT: if constexpr(std::is_same_v) { CheckSize(2); @@ -2299,28 +2325,28 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_POSITION: + case SourceProp::Position: CheckSize(3); values[0] = gsl::narrow_cast(Source->mPosition[0]); values[1] = gsl::narrow_cast(Source->mPosition[1]); values[2] = gsl::narrow_cast(Source->mPosition[2]); return; - case AL_VELOCITY: + case SourceProp::Velocity: CheckSize(3); values[0] = gsl::narrow_cast(Source->mVelocity[0]); values[1] = gsl::narrow_cast(Source->mVelocity[1]); values[2] = gsl::narrow_cast(Source->mVelocity[2]); return; - case AL_DIRECTION: + case SourceProp::Direction: CheckSize(3); values[0] = gsl::narrow_cast(Source->mDirection[0]); values[1] = gsl::narrow_cast(Source->mDirection[1]); values[2] = gsl::narrow_cast(Source->mDirection[2]); return; - case AL_ORIENTATION: + case SourceProp::Orientation: CheckSize(6); values[0] = gsl::narrow_cast(Source->mOrientAt[0]); values[1] = gsl::narrow_cast(Source->mOrientAt[1]); @@ -2331,7 +2357,7 @@ void GetProperty(const gsl::not_null Source, return; - case AL_SOURCE_RELATIVE: + case SourceProp::SourceRelative: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2340,7 +2366,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_LOOPING: + case SourceProp::Looping: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2349,7 +2375,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_BUFFER: + case SourceProp::Buffer: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2377,7 +2403,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_SOURCE_STATE: + case SourceProp::SourceState: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2386,7 +2412,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_BUFFERS_QUEUED: + case SourceProp::BuffersQueued: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2395,7 +2421,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_BUFFERS_PROCESSED: + case SourceProp::BuffersProcessed: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2421,7 +2447,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_SOURCE_TYPE: + case SourceProp::SourceType: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2430,7 +2456,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_DIRECT_FILTER_GAINHF_AUTO: + case SourceProp::DirectFilterGainHFAuto: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2439,7 +2465,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: + case SourceProp::AuxSendFilterGainAuto: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2448,7 +2474,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: + case SourceProp::AuxSendFilterGainHFAuto: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2457,7 +2483,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_DIRECT_CHANNELS_SOFT: + case SourceProp::DirectChannelsSOFT: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2466,7 +2492,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_DISTANCE_MODEL: + case SourceProp::DistanceModel: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2475,7 +2501,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_SOURCE_RESAMPLER_SOFT: + case SourceProp::Resampler: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2484,7 +2510,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_SOURCE_SPATIALIZE_SOFT: + case SourceProp::Spatialize: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2493,7 +2519,7 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_STEREO_MODE_SOFT: + case SourceProp::StereoMode: if constexpr(std::is_integral_v) { CheckSize(1); @@ -2502,8 +2528,8 @@ void GetProperty(const gsl::not_null Source, } break; - case AL_DIRECT_FILTER: - case AL_AUXILIARY_SEND_FILTER: + case SourceProp::DirectFilter: + case SourceProp::AuxSendFilter: break; } @@ -2512,13 +2538,13 @@ void GetProperty(const gsl::not_null Source, } -using source_store_single = std::array,1>; +using source_store_single = std::array, 1>; using source_store_vector = std::vector>; using source_store_variant = std::variant; -constexpr auto get_srchandles(gsl::not_null const context, - source_store_variant &source_store, std::span const sids) - -> std::span> +[[nodiscard]] +auto get_srchandles(gsl::not_null const context, source_store_variant &source_store, + std::span const sids) -> std::span> { if(sids.size() == 1) { @@ -2678,14 +2704,14 @@ void StartSources(gsl::not_null const context, auto const offset = f64{source->mOffset}; source->mOffsetType = AL_NONE; source->mOffset = 0.0; - if(auto const vpos = GetSampleOffset(source->mQueue, offsettype, offset)) + if(auto const vpos = GetSampleOffset(source->mQueue, SourceProp{offsettype}, offset)) { voice->mPosition.store(vpos->pos.c_val, std::memory_order_relaxed); voice->mPositionFrac.store(vpos->frac.c_val, std::memory_order_relaxed); voice->mCurrentBuffer.store(vpos->bufferitem, std::memory_order_relaxed); if(vpos->pos > 0 || (vpos->pos == 0 && vpos->frac > 0) || vpos->bufferitem != &source->mQueue.front()) - voice->mFlags.set(VoiceIsFading); + voice->mFlags.set(VoiceFlag::IsFading); } } InitVoice(voice, source, &*BufferList, context, device); @@ -2702,7 +2728,7 @@ void StartSources(gsl::not_null const context, } -void alGenSources(gsl::not_null const context, ALsizei const n, +void alGenSources_(gsl::not_null const context, ALsizei const n, ALuint *const sources) noexcept try { if(n < 0) @@ -2729,7 +2755,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alDeleteSources(gsl::not_null context, ALsizei n, const ALuint *sources) +void alDeleteSources_(gsl::not_null context, ALsizei n, const ALuint *sources) noexcept try { if(n < 0) @@ -2756,7 +2782,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -auto alIsSource(gsl::not_null context, ALuint source) noexcept -> ALboolean +auto alIsSource_(gsl::not_null context, ALuint source) noexcept -> ALboolean { auto srclock = std::lock_guard{context->mSourceLock}; if(LookupSource(std::nothrow, context, source) != nullptr) @@ -2765,7 +2791,7 @@ auto alIsSource(gsl::not_null context, ALuint source) noexcept -> } -void alSourcef(gsl::not_null context, ALuint source, ALenum param, ALfloat value) +void alSourcef_(gsl::not_null context, ALuint source, ALenum param, ALfloat value) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2779,7 +2805,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSource3f(gsl::not_null context, ALuint source, ALenum param, ALfloat value1, +void alSource3f_(gsl::not_null context, ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2794,7 +2820,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourcefv(gsl::not_null context, ALuint source, ALenum param, +void alSourcefv_(gsl::not_null context, ALuint source, ALenum param, const ALfloat *values) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2814,7 +2840,7 @@ catch(std::exception &e) { } -void alSourcedSOFT(gsl::not_null context, ALuint source, ALenum param, +void alSourcedSOFT_(gsl::not_null context, ALuint source, ALenum param, ALdouble value) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2828,7 +2854,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSource3dSOFT(gsl::not_null context, ALuint source, ALenum param, +void alSource3dSOFT_(gsl::not_null context, ALuint source, ALenum param, ALdouble value1, ALdouble value2, ALdouble value3) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2843,7 +2869,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourcedvSOFT(gsl::not_null context, ALuint source, ALenum param, +void alSourcedvSOFT_(gsl::not_null context, ALuint source, ALenum param, const ALdouble *values) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2863,7 +2889,7 @@ catch(std::exception &e) { } -void alSourcei(gsl::not_null context, ALuint source, ALenum param, ALint value) +void alSourcei_(gsl::not_null context, ALuint source, ALenum param, ALint value) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2877,7 +2903,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSource3i(gsl::not_null context, ALuint source, ALenum param, ALint value1, +void alSource3i_(gsl::not_null context, ALuint source, ALenum param, ALint value1, ALint value2, ALint value3) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2892,7 +2918,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourceiv(gsl::not_null context, ALuint source, ALenum param, +void alSourceiv_(gsl::not_null context, ALuint source, ALenum param, const ALint *values) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2912,7 +2938,7 @@ catch(std::exception &e) { } -void alSourcei64SOFT(gsl::not_null context, ALuint source, ALenum param, +void alSourcei64SOFT_(gsl::not_null context, ALuint source, ALenum param, ALint64SOFT value) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2926,7 +2952,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSource3i64SOFT(gsl::not_null context, ALuint source, ALenum param, +void alSource3i64SOFT_(gsl::not_null context, ALuint source, ALenum param, ALint64SOFT value1, ALint64SOFT value2, ALint64SOFT value3) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2941,7 +2967,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourcei64vSOFT(gsl::not_null context, ALuint source, ALenum param, +void alSourcei64vSOFT_(gsl::not_null context, ALuint source, ALenum param, const ALint64SOFT *values) noexcept try { auto proplock = std::lock_guard{context->mPropLock}; @@ -2961,7 +2987,7 @@ catch(std::exception &e) { } -void alGetSourcef(gsl::not_null context, ALuint source, ALenum param, ALfloat *value) +void alGetSourcef_(gsl::not_null context, ALuint source, ALenum param, ALfloat *value) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -2978,7 +3004,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetSource3f(gsl::not_null context, ALuint source, ALenum param, +void alGetSource3f_(gsl::not_null context, ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -2999,7 +3025,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetSourcefv(gsl::not_null context, ALuint source, ALenum param, +void alGetSourcefv_(gsl::not_null context, ALuint source, ALenum param, ALfloat *values) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3018,7 +3044,7 @@ catch(std::exception &e) { } -void alGetSourcedSOFT(gsl::not_null context, ALuint source, ALenum param, +void alGetSourcedSOFT_(gsl::not_null context, ALuint source, ALenum param, ALdouble *value) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3035,7 +3061,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetSource3dSOFT(gsl::not_null context, ALuint source, ALenum param, +void alGetSource3dSOFT_(gsl::not_null context, ALuint source, ALenum param, ALdouble *value1, ALdouble *value2, ALdouble *value3) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3056,7 +3082,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetSourcedvSOFT(gsl::not_null context, ALuint source, ALenum param, +void alGetSourcedvSOFT_(gsl::not_null context, ALuint source, ALenum param, ALdouble *values) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3075,7 +3101,7 @@ catch(std::exception &e) { } -void alGetSourcei(gsl::not_null context, ALuint source, ALenum param, ALint *value) +void alGetSourcei_(gsl::not_null context, ALuint source, ALenum param, ALint *value) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3092,8 +3118,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetSource3i(gsl::not_null context, ALuint source, ALenum param, ALint *value1, - ALint *value2, ALint *value3) noexcept +void alGetSource3i_(gsl::not_null context, ALuint source, ALenum param, + ALint *value1, ALint *value2, ALint *value3) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3113,8 +3139,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetSourceiv(gsl::not_null context, ALuint source, ALenum param, ALint *values) - noexcept +void alGetSourceiv_(gsl::not_null context, ALuint source, ALenum param, + ALint *values) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3132,7 +3158,7 @@ catch(std::exception &e) { } -void alGetSourcei64SOFT(gsl::not_null context, ALuint source, ALenum param, +void alGetSourcei64SOFT_(gsl::not_null context, ALuint source, ALenum param, ALint64SOFT *value) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3149,7 +3175,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetSource3i64SOFT(gsl::not_null context, ALuint source, ALenum param, +void alGetSource3i64SOFT_(gsl::not_null context, ALuint source, ALenum param, ALint64SOFT *value1, ALint64SOFT *value2, ALint64SOFT *value3) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3170,7 +3196,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alGetSourcei64vSOFT(gsl::not_null context, ALuint source, ALenum param, +void alGetSourcei64vSOFT_(gsl::not_null context, ALuint source, ALenum param, ALint64SOFT *values) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; @@ -3189,7 +3215,7 @@ catch(std::exception &e) { } -void alSourcePlayv(gsl::not_null context, ALsizei n, const ALuint *sources) noexcept +void alSourcePlayv_(gsl::not_null context, ALsizei n, const ALuint *sources) noexcept try { if(n < 0) context->throw_error(AL_INVALID_VALUE, "Playing {} sources", n); @@ -3209,7 +3235,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourcePlay(gsl::not_null context, ALuint source) noexcept +void alSourcePlay_(gsl::not_null context, ALuint source) noexcept try { auto srclock = std::lock_guard{context->mSourceLock}; auto Source = LookupSource(context, source); @@ -3221,8 +3247,8 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourcePlayAtTimevSOFT(gsl::not_null context, ALsizei n, const ALuint *sources, - ALint64SOFT start_time) noexcept +void alSourcePlayAtTimevSOFT_(gsl::not_null context, ALsizei n, + ALuint const *sources, ALint64SOFT start_time) noexcept try { if(n < 0) context->throw_error(AL_INVALID_VALUE, "Playing {} sources", n); @@ -3245,7 +3271,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourcePlayAtTimeSOFT(gsl::not_null context, ALuint source, +void alSourcePlayAtTimeSOFT_(gsl::not_null context, ALuint source, ALint64SOFT start_time) noexcept try { if(start_time < 0) @@ -3262,7 +3288,8 @@ catch(std::exception &e) { } -void alSourcePausev(gsl::not_null context, ALsizei n, const ALuint *sources) noexcept +void alSourcePausev_(gsl::not_null context, ALsizei n, const ALuint *sources) + noexcept try { if(n < 0) context->throw_error(AL_INVALID_VALUE, "Pausing {} sources", n); @@ -3319,11 +3346,11 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourcePause(gsl::not_null const context, ALuint const source) noexcept -{ alSourcePausev(context, 1, &source); } +void alSourcePause_(gsl::not_null const context, ALuint const source) noexcept +{ alSourcePausev_(context, 1, &source); } -void alSourceStopv(gsl::not_null context, ALsizei n, const ALuint *sources) noexcept +void alSourceStopv_(gsl::not_null context, ALsizei n, const ALuint *sources) noexcept try { if(n < 0) context->throw_error(AL_INVALID_VALUE, "Stopping {} sources", n); @@ -3367,11 +3394,11 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourceStop(gsl::not_null context, ALuint source) noexcept -{ alSourceStopv(context, 1, &source); } +void alSourceStop_(gsl::not_null context, ALuint source) noexcept +{ alSourceStopv_(context, 1, &source); } -void alSourceRewindv(gsl::not_null context, ALsizei n, const ALuint *sources) +void alSourceRewindv_(gsl::not_null context, ALsizei n, const ALuint *sources) noexcept try { if(n < 0) @@ -3418,11 +3445,11 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourceRewind(gsl::not_null context, ALuint source) noexcept -{ alSourceRewindv(context, 1, &source); } +void alSourceRewind_(gsl::not_null context, ALuint source) noexcept +{ alSourceRewindv_(context, 1, &source); } -void alSourceQueueBuffers(gsl::not_null context, ALuint src, ALsizei nb, +void alSourceQueueBuffers_(gsl::not_null context, ALuint src, ALsizei nb, const ALuint *buffers) noexcept try { if(nb < 0) @@ -3513,7 +3540,7 @@ try { /* A buffer failed (invalid ID or format), or there was some other * unexpected error, so release the buffers we had. */ - source->mQueue.resize(gsl::narrow_cast(NewListStart)); + source->mQueue.resize(gsl::narrow_cast(NewListStart)); throw; } /* All buffers good. */ @@ -3534,7 +3561,7 @@ catch(std::exception &e) { ERR("Caught exception: {}", e.what()); } -void alSourceUnqueueBuffers(gsl::not_null context, ALuint src, ALsizei nb, +void alSourceUnqueueBuffers_(gsl::not_null context, ALuint src, ALsizei nb, ALuint *buffers) noexcept try { if(nb < 0) @@ -3551,7 +3578,7 @@ try { /* Make sure enough buffers have been processed to unqueue. */ const auto bids = std::views::counted(buffers, nb); - auto processed = 0_uz; + auto processed = 0_usize; if(source->mState != AL_INITIAL) [[likely]] { const auto Current = std::invoke([source,context]() -> const VoiceBufferItem* @@ -3562,7 +3589,7 @@ try { }); const auto qiter = std::ranges::find(source->mQueue, Current, [](al::BufferQueueItem const &item) { return &item; }); - processed = gsl::narrow_cast(std::distance(source->mQueue.begin(), qiter)); + processed = isize{std::distance(source->mQueue.begin(), qiter)}.reinterpret_as(); } if(processed < bids.size()) context->throw_error(AL_INVALID_VALUE, "Unqueueing {} buffer{} (only {} processed)", @@ -3571,7 +3598,7 @@ try { std::ranges::generate(bids, [source]() noexcept -> ALuint { auto bid = 0u; - if(auto *buffer = source->mQueue.front().mBuffer.get()) + if(auto const *const buffer = source->mQueue.front().mBuffer.get()) bid = buffer->mId; source->mQueue.pop_front(); return bid; @@ -3585,58 +3612,58 @@ catch(std::exception &e) { } // namespace -AL_API DECL_FUNC2(void, alGenSources, ALsizei,n, ALuint*,sources) -AL_API DECL_FUNC2(void, alDeleteSources, ALsizei,n, const ALuint*,sources) -AL_API DECL_FUNC1(ALboolean, alIsSource, ALuint,source) +DECL_FUNC(AL_API, void, alGenSources, ALsizei,n, ALuint*,sources) +DECL_FUNC(AL_API, void, alDeleteSources, ALsizei,n, const ALuint*,sources) +DECL_FUNC(AL_API, ALboolean, alIsSource, ALuint,source) -AL_API DECL_FUNC3(void, alSourcef, ALuint,source, ALenum,param, ALfloat,value) -AL_API DECL_FUNC5(void, alSource3f, ALuint,source, ALenum,param, ALfloat,value1, ALfloat,value2, ALfloat,value3) -AL_API DECL_FUNC3(void, alSourcefv, ALuint,source, ALenum,param, const ALfloat*,values) +DECL_FUNC(AL_API, void, alSourcef, ALuint,source, ALenum,param, ALfloat,value) +DECL_FUNC(AL_API, void, alSource3f, ALuint,source, ALenum,param, ALfloat,value1, ALfloat,value2, ALfloat,value3) +DECL_FUNC(AL_API, void, alSourcefv, ALuint,source, ALenum,param, const ALfloat*,values) -AL_API DECL_FUNCEXT3(void, alSourced,SOFT, ALuint,source, ALenum,param, ALdouble,value) -AL_API DECL_FUNCEXT5(void, alSource3d,SOFT, ALuint,source, ALenum,param, ALdouble,value1, ALdouble,value2, ALdouble,value3) -AL_API DECL_FUNCEXT3(void, alSourcedv,SOFT, ALuint,source, ALenum,param, const ALdouble*,values) +DECL_FUNCEXT(AL_API, void, alSourced,SOFT, ALuint,source, ALenum,param, ALdouble,value) +DECL_FUNCEXT(AL_API, void, alSource3d,SOFT, ALuint,source, ALenum,param, ALdouble,value1, ALdouble,value2, ALdouble,value3) +DECL_FUNCEXT(AL_API, void, alSourcedv,SOFT, ALuint,source, ALenum,param, const ALdouble*,values) -AL_API DECL_FUNC3(void, alSourcei, ALuint,source, ALenum,param, ALint,value) -AL_API DECL_FUNC5(void, alSource3i, ALuint,buffer, ALenum,param, ALint,value1, ALint,value2, ALint,value3) -AL_API DECL_FUNC3(void, alSourceiv, ALuint,source, ALenum,param, const ALint*,values) +DECL_FUNC(AL_API, void, alSourcei, ALuint,source, ALenum,param, ALint,value) +DECL_FUNC(AL_API, void, alSource3i, ALuint,buffer, ALenum,param, ALint,value1, ALint,value2, ALint,value3) +DECL_FUNC(AL_API, void, alSourceiv, ALuint,source, ALenum,param, const ALint*,values) -AL_API DECL_FUNCEXT3(void, alSourcei64,SOFT, ALuint,source, ALenum,param, ALint64SOFT,value) -AL_API DECL_FUNCEXT5(void, alSource3i64,SOFT, ALuint,source, ALenum,param, ALint64SOFT,value1, ALint64SOFT,value2, ALint64SOFT,value3) -AL_API DECL_FUNCEXT3(void, alSourcei64v,SOFT, ALuint,source, ALenum,param, const ALint64SOFT*,values) +DECL_FUNCEXT(AL_API, void, alSourcei64,SOFT, ALuint,source, ALenum,param, ALint64SOFT,value) +DECL_FUNCEXT(AL_API, void, alSource3i64,SOFT, ALuint,source, ALenum,param, ALint64SOFT,value1, ALint64SOFT,value2, ALint64SOFT,value3) +DECL_FUNCEXT(AL_API, void, alSourcei64v,SOFT, ALuint,source, ALenum,param, const ALint64SOFT*,values) -AL_API DECL_FUNC3(void, alGetSourcef, ALuint,source, ALenum,param, ALfloat*,value) -AL_API DECL_FUNC5(void, alGetSource3f, ALuint,source, ALenum,param, ALfloat*,value1, ALfloat*,value2, ALfloat*,value3) -AL_API DECL_FUNC3(void, alGetSourcefv, ALuint,source, ALenum,param, ALfloat*,values) +DECL_FUNC(AL_API, void, alGetSourcef, ALuint,source, ALenum,param, ALfloat*,value) +DECL_FUNC(AL_API, void, alGetSource3f, ALuint,source, ALenum,param, ALfloat*,value1, ALfloat*,value2, ALfloat*,value3) +DECL_FUNC(AL_API, void, alGetSourcefv, ALuint,source, ALenum,param, ALfloat*,values) -AL_API DECL_FUNCEXT3(void, alGetSourced,SOFT, ALuint,source, ALenum,param, ALdouble*,value) -AL_API DECL_FUNCEXT5(void, alGetSource3d,SOFT, ALuint,source, ALenum,param, ALdouble*,value1, ALdouble*,value2, ALdouble*,value3) -AL_API DECL_FUNCEXT3(void, alGetSourcedv,SOFT, ALuint,source, ALenum,param, ALdouble*,values) +DECL_FUNCEXT(AL_API, void, alGetSourced,SOFT, ALuint,source, ALenum,param, ALdouble*,value) +DECL_FUNCEXT(AL_API, void, alGetSource3d,SOFT, ALuint,source, ALenum,param, ALdouble*,value1, ALdouble*,value2, ALdouble*,value3) +DECL_FUNCEXT(AL_API, void, alGetSourcedv,SOFT, ALuint,source, ALenum,param, ALdouble*,values) -AL_API DECL_FUNC3(void, alGetSourcei, ALuint,source, ALenum,param, ALint*,value) -AL_API DECL_FUNC5(void, alGetSource3i, ALuint,source, ALenum,param, ALint*,value1, ALint*,value2, ALint*,value3) -AL_API DECL_FUNC3(void, alGetSourceiv, ALuint,source, ALenum,param, ALint*,values) +DECL_FUNC(AL_API, void, alGetSourcei, ALuint,source, ALenum,param, ALint*,value) +DECL_FUNC(AL_API, void, alGetSource3i, ALuint,source, ALenum,param, ALint*,value1, ALint*,value2, ALint*,value3) +DECL_FUNC(AL_API, void, alGetSourceiv, ALuint,source, ALenum,param, ALint*,values) -AL_API DECL_FUNCEXT3(void, alGetSourcei64,SOFT, ALuint,source, ALenum,param, ALint64SOFT*,value) -AL_API DECL_FUNCEXT5(void, alGetSource3i64,SOFT, ALuint,source, ALenum,param, ALint64SOFT*,value1, ALint64SOFT*,value2, ALint64SOFT*,value3) -AL_API DECL_FUNCEXT3(void, alGetSourcei64v,SOFT, ALuint,source, ALenum,param, ALint64SOFT*,values) +DECL_FUNCEXT(AL_API, void, alGetSourcei64,SOFT, ALuint,source, ALenum,param, ALint64SOFT*,value) +DECL_FUNCEXT(AL_API, void, alGetSource3i64,SOFT, ALuint,source, ALenum,param, ALint64SOFT*,value1, ALint64SOFT*,value2, ALint64SOFT*,value3) +DECL_FUNCEXT(AL_API, void, alGetSourcei64v,SOFT, ALuint,source, ALenum,param, ALint64SOFT*,values) -AL_API DECL_FUNC1(void, alSourcePlay, ALuint,source) -FORCE_ALIGN DECL_FUNCEXT2(void, alSourcePlayAtTime,SOFT, ALuint,source, ALint64SOFT,start_time) -AL_API DECL_FUNC2(void, alSourcePlayv, ALsizei,n, const ALuint*,sources) -FORCE_ALIGN DECL_FUNCEXT3(void, alSourcePlayAtTimev,SOFT, ALsizei,n, const ALuint*,sources, ALint64SOFT,start_time) +DECL_FUNC(AL_API, void, alSourcePlay, ALuint,source) +DECL_FUNCEXT(FORCE_ALIGN, void, alSourcePlayAtTime,SOFT, ALuint,source, ALint64SOFT,start_time) +DECL_FUNC(AL_API, void, alSourcePlayv, ALsizei,n, const ALuint*,sources) +DECL_FUNCEXT(FORCE_ALIGN, void, alSourcePlayAtTimev,SOFT, ALsizei,n, const ALuint*,sources, ALint64SOFT,start_time) -AL_API DECL_FUNC1(void, alSourcePause, ALuint,source) -AL_API DECL_FUNC2(void, alSourcePausev, ALsizei,n, const ALuint*,sources) +DECL_FUNC(AL_API, void, alSourcePause, ALuint,source) +DECL_FUNC(AL_API, void, alSourcePausev, ALsizei,n, const ALuint*,sources) -AL_API DECL_FUNC1(void, alSourceStop, ALuint,source) -AL_API DECL_FUNC2(void, alSourceStopv, ALsizei,n, const ALuint*,sources) +DECL_FUNC(AL_API, void, alSourceStop, ALuint,source) +DECL_FUNC(AL_API, void, alSourceStopv, ALsizei,n, const ALuint*,sources) -AL_API DECL_FUNC1(void, alSourceRewind, ALuint,source) -AL_API DECL_FUNC2(void, alSourceRewindv, ALsizei,n, const ALuint*,sources) +DECL_FUNC(AL_API, void, alSourceRewind, ALuint,source) +DECL_FUNC(AL_API, void, alSourceRewindv, ALsizei,n, const ALuint*,sources) -AL_API DECL_FUNC3(void, alSourceQueueBuffers, ALuint,source, ALsizei,nb, const ALuint*,buffers) -AL_API DECL_FUNC3(void, alSourceUnqueueBuffers, ALuint,source, ALsizei,nb, ALuint*,buffers) +DECL_FUNC(AL_API, void, alSourceQueueBuffers, ALuint,source, ALsizei,nb, const ALuint*,buffers) +DECL_FUNC(AL_API, void, alSourceUnqueueBuffers, ALuint,source, ALsizei,nb, ALuint*,buffers) AL_API void AL_APIENTRY alSourceQueueBufferLayersSOFT(ALuint, ALsizei, const ALuint*) noexcept @@ -3745,7 +3772,7 @@ void al::Source::eax_fail_unknown_receiving_fx_slot_id() {eax_fail("Unknown rece void al::Source::eax_set_sends_defaults(EaxSends& sends, const EaxFxSlotIds& ids) noexcept { - for(auto const i : std::views::iota(0_uz, usize{EAX_MAX_FXSLOTS})) + for(auto const i : std::views::iota(0_uz, std::size_t{EAX_MAX_FXSLOTS})) { auto& send = sends[i]; send.guidReceivingFXSlotID = *(ids[i]); @@ -3858,7 +3885,7 @@ void al::Source::eax5_set_active_fx_slots_defaults(EAX50ACTIVEFXSLOTS& slots) no void al::Source::eax5_set_speaker_levels_defaults(EaxSpeakerLevels& speaker_levels) noexcept { - for(auto const i : std::views::iota(0_uz, usize{eax_max_speakers})) + for(auto const i : std::views::iota(0_uz, std::size_t{eax_max_speakers})) { auto& speaker_level = speaker_levels[i]; speaker_level.lSpeakerID = gsl::narrow_cast(EAXSPEAKER_FRONT_LEFT + i); @@ -3963,15 +3990,15 @@ void al::Source::eax4_translate(const Eax4Props& src, Eax5Props& dst) noexcept // dst.sends = src.sends; - for(auto const i : std::views::iota(0_uz, usize{EAX_MAX_FXSLOTS})) + for(auto const i : std::views::iota(0_uz, std::size_t{EAX_MAX_FXSLOTS})) dst.sends[i].guidReceivingFXSlotID = *(eax5_fx_slot_ids[i]); // Active FX slots. // const auto src_slots = std::span{src.active_fx_slots.guidActiveFXSlots}; const auto dst_slots = std::span{dst.active_fx_slots.guidActiveFXSlots}; - auto dstiter = std::ranges::transform(src_slots, dst_slots.begin(), [](const GUID &src_id) - -> GUID + auto dstiter = std::ranges::transform(src_slots, dst_slots.begin(), [](AL_GUID const& src_id) + -> AL_GUID { if(src_id == EAX_NULL_GUID) return EAX_NULL_GUID; @@ -4013,7 +4040,7 @@ auto al::Source::eax_create_direct_filter_param() const noexcept -> EaxAlLowPass * source.mObstruction.flObstructionLFRatio; auto gainhf_mb = gsl::narrow_cast(source.mObstruction.lObstruction); - for(const auto i : std::views::iota(0_uz, usize{EAX_MAX_FXSLOTS})) + for(const auto i : std::views::iota(0_uz, std::size_t{EAX_MAX_FXSLOTS})) { if(!mEaxActiveFxSlots.test(i)) continue; @@ -4118,7 +4145,7 @@ void al::Source::eax_update_direct_filter() void al::Source::eax_update_room_filters() { - for(const auto i : std::views::iota(0_uz, usize{EAX_MAX_FXSLOTS})) + for(const auto i : std::views::iota(0_uz, std::size_t{EAX_MAX_FXSLOTS})) { if(!mEaxActiveFxSlots.test(i)) continue; @@ -4439,7 +4466,7 @@ void al::Source::eax5_defer_speaker_levels(const EaxCall& call, EaxSpeakerLevels for(const auto &value : values) { - const auto index = gsl::narrow_cast(value.lSpeakerID - EAXSPEAKER_FRONT_LEFT); + const auto index = gsl::narrow_cast(value.lSpeakerID-EAXSPEAKER_FRONT_LEFT); props[index].lLevel = value.lLevel; } } @@ -4538,10 +4565,11 @@ void al::Source::eax_set(const EaxCall& call) mEaxVersion = eax_version; } -void al::Source::eax_get_active_fx_slot_id(const EaxCall& call, const std::span srcids) +void al::Source::eax_get_active_fx_slot_id(EaxCall const& call, + std::span const srcids) { Expects(srcids.size()==EAX40_MAX_ACTIVE_FXSLOTS || srcids.size()==EAX50_MAX_ACTIVE_FXSLOTS); - const auto dst_ids = call.as_span(srcids.size()); + const auto dst_ids = call.as_span(srcids.size()); std::uninitialized_copy_n(srcids.begin(), dst_ids.size(), dst_ids.begin()); } @@ -4769,7 +4797,7 @@ void al::Source::eax_get(const EaxCall &call) const } void al::Source::eax_set_al_source_send(al::intrusive_ptr slot, - usize const sendidx, const EaxAlLowPassParam &filter) + std::size_t const sendidx, const EaxAlLowPassParam &filter) { if(sendidx >= EAX_MAX_FXSLOTS) return; @@ -4814,7 +4842,7 @@ void al::Source::eax_commit_active_fx_slots() // Deactivate EFX auxiliary effect slots for inactive slots. Active slots // will be updated with the room filters. - for(const auto i : std::views::iota(0_uz, usize{EAX_MAX_FXSLOTS})) + for(const auto i : std::views::iota(0_uz, std::size_t{EAX_MAX_FXSLOTS})) { if(!mEaxActiveFxSlots.test(i)) eax_set_al_source_send({}, i, EaxAlLowPassParam{1.0f, 1.0f}); diff --git a/3rdparty/openal/al/source.h b/3rdparty/openal/al/source.h index 39428a7277a7..4e96ceca9eea 100644 --- a/3rdparty/openal/al/source.h +++ b/3rdparty/openal/al/source.h @@ -18,7 +18,7 @@ #include "AL/alext.h" #include "almalloc.h" -#include "alnumeric.h" +#include "altypes.hpp" #include "core/context.h" #include "core/voice.h" #include "gsl/gsl" @@ -58,6 +58,11 @@ class EaxSourceException final : public EaxException { : EaxException{"EAX_SOURCE", message} { } }; + +struct EaxAlLowPassParam { + float gain; + float gain_hf; +}; #endif // ALSOFT_EAX namespace al { @@ -112,7 +117,7 @@ struct Source { -std::numbers::pi_v/6.0f}}; float mRadius{0.0f}; - float mEnhWidth{0.593f}; + float mEnhWidth{0.46f}; float mPan{0.0f}; /** Direct filter and auxiliary send info. */ @@ -187,7 +192,7 @@ struct Source { static constexpr auto eax_max_speakers = 9u; - using EaxFxSlotIds = std::array; + using EaxFxSlotIds = std::array; static constexpr auto eax4_fx_slot_ids = EaxFxSlotIds{ &EAXPROPERTYID_EAX40_FXSlot0, @@ -611,7 +616,7 @@ struct Source { // Send validators struct Eax4SendReceivingFxSlotIdValidator { - void operator()(const GUID& guidReceivingFXSlotID) const + void operator()(AL_GUID const& guidReceivingFXSlotID) const { if (guidReceivingFXSlotID != EAXPROPERTYID_EAX40_FXSlot0 && guidReceivingFXSlotID != EAXPROPERTYID_EAX40_FXSlot1 && @@ -624,7 +629,7 @@ struct Source { }; struct Eax5SendReceivingFxSlotIdValidator { - void operator()(const GUID& guidReceivingFXSlotID) const + void operator()(AL_GUID const& guidReceivingFXSlotID) const { if (guidReceivingFXSlotID != EAXPROPERTYID_EAX50_FXSlot0 && guidReceivingFXSlotID != EAXPROPERTYID_EAX50_FXSlot1 && @@ -723,7 +728,7 @@ struct Source { // Active FX slot ID validators struct Eax4ActiveFxSlotIdValidator { - void operator()(const GUID &guid) const + void operator()(AL_GUID const& guid) const { if(guid != EAX_NULL_GUID && guid != EAX_PrimaryFXSlotID && guid != EAXPROPERTYID_EAX40_FXSlot0 && guid != EAXPROPERTYID_EAX40_FXSlot1 @@ -735,7 +740,7 @@ struct Source { }; struct Eax5ActiveFxSlotIdValidator { - void operator()(const GUID &guid) const + void operator()(AL_GUID const& guid) const { if(guid != EAX_NULL_GUID && guid != EAX_PrimaryFXSlotID && guid != EAXPROPERTYID_EAX50_FXSlot0 && guid != EAXPROPERTYID_EAX50_FXSlot1 @@ -792,7 +797,7 @@ struct Source { // ---------------------------------------------------------------------- struct Eax4SendIndexGetter { - EaxFxSlotIndexValue operator()(const GUID &guid) const + EaxFxSlotIndexValue operator()(AL_GUID const &guid) const { if(guid == EAXPROPERTYID_EAX40_FXSlot0) return 0; @@ -807,7 +812,7 @@ struct Source { }; struct Eax5SendIndexGetter { - EaxFxSlotIndexValue operator()(const GUID &guid) const + EaxFxSlotIndexValue operator()(AL_GUID const& guid) const { if(guid == EAXPROPERTYID_EAX50_FXSlot0) return 0; @@ -901,7 +906,7 @@ struct Source { } } - static void eax_get_active_fx_slot_id(const EaxCall &call, const std::span srcids); + static void eax_get_active_fx_slot_id(const EaxCall &call, std::span srcids); static void eax1_get(const EaxCall &call, const EAXBUFFER_REVERBPROPERTIES &props); static void eax2_get(const EaxCall &call, const EAX20BUFFERPROPERTIES &props); static void eax3_get(const EaxCall &call, const EAX30SOURCEPROPERTIES &props); @@ -937,7 +942,7 @@ struct Source { dst.mExclusion = src.mExclusion; } - template TIndexGetter, typename TSrcSend> + template TIndexGetter, typename TSrcSend> static void eax_defer_sends(const EaxCall &call, EaxSends &dst_sends, std::invocable auto&& validator) { @@ -961,20 +966,20 @@ struct Source { std::invocable auto validator) { eax_defer_sends(call, dst_sends, std::move(validator)); } - template TValidator> - static void eax_defer_active_fx_slot_id(const EaxCall &call, const std::span dst_ids) + template TValidator> + static void eax_defer_active_fx_slot_id(const EaxCall &call, const std::span dst_ids) { - const auto src_ids = call.as_span(dst_ids.size()); + const auto src_ids = call.as_span(dst_ids.size()); std::ranges::for_each(src_ids, TValidator{}); std::ranges::uninitialized_copy(src_ids, dst_ids); } - static void eax4_defer_active_fx_slot_id(const EaxCall &call, const std::span dst_ids) + static void eax4_defer_active_fx_slot_id(EaxCall const& call, std::span const dst_ids) { eax_defer_active_fx_slot_id(call, dst_ids); } - static void eax5_defer_active_fx_slot_id(const EaxCall &call, const std::span dst_ids) + static void eax5_defer_active_fx_slot_id(EaxCall const& call, std::span const dst_ids) { eax_defer_active_fx_slot_id(call, dst_ids); } @@ -1007,7 +1012,7 @@ struct Source { void eax_set(const EaxCall& call); // `alSource3i(source, AL_AUXILIARY_SEND_FILTER, ...)` - void eax_set_al_source_send(intrusive_ptr slot, usize sendidx, + void eax_set_al_source_send(intrusive_ptr slot, std::size_t sendidx, EaxAlLowPassParam const &filter); void eax_commit_active_fx_slots(); diff --git a/3rdparty/openal/al/state.cpp b/3rdparty/openal/al/state.cpp index 3509f5fcc899..ca66fd2b2432 100644 --- a/3rdparty/openal/al/state.cpp +++ b/3rdparty/openal/al/state.cpp @@ -39,18 +39,14 @@ #include "al/debug.h" #include "al/listener.h" #include "alc/alu.h" -#include "alc/context.h" #include "alc/device.h" #include "alc/inprogext.h" -#include "alformat.hpp" #include "alnumeric.h" #include "atomic.h" #include "core/context.h" -#include "core/logging.h" #include "core/mixer/defs.h" #include "core/voice.h" #include "direct_defs.h" -#include "gsl/gsl" #include "intrusive_ptr.h" #include "opthelpers.h" #include "strutils.hpp" @@ -60,6 +56,16 @@ #include "eax/x_ram.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { @@ -180,7 +186,7 @@ struct PropertyCastType { template [[nodiscard]] constexpr auto operator()(U&& value) const noexcept -> T { - if constexpr(al::strong_number>) + if constexpr(al::strict_number>) return gsl::narrow_cast(std::forward(value).c_val); else return gsl::narrow_cast(std::forward(value)); @@ -192,7 +198,7 @@ struct PropertyCastType { template [[nodiscard]] constexpr auto operator()(U&& value) const noexcept -> ALboolean { - if constexpr(al::strong_number>) + if constexpr(al::strict_number>) return gsl::narrow_cast(std::forward(value).c_val) ? AL_TRUE : AL_FALSE; else return gsl::narrow_cast(std::forward(value)) ? AL_TRUE : AL_FALSE; @@ -351,7 +357,7 @@ inline void UpdateProps(al::Context *context) } -void alEnable(gsl::not_null context, ALenum capability) noexcept +void alEnable_(gsl::not_null context, ALenum capability) noexcept { switch(capability) { @@ -375,7 +381,7 @@ void alEnable(gsl::not_null context, ALenum capability) noexcept as_unsigned(capability)); } -void alDisable(gsl::not_null context, ALenum capability) noexcept +void alDisable_(gsl::not_null context, ALenum capability) noexcept { switch(capability) { @@ -399,7 +405,7 @@ void alDisable(gsl::not_null context, ALenum capability) noexcept as_unsigned(capability)); } -auto alIsEnabled(gsl::not_null context, ALenum capability) noexcept -> ALboolean +auto alIsEnabled_(gsl::not_null context, ALenum capability) noexcept -> ALboolean { auto proplock = std::lock_guard{context->mPropLock}; switch(capability) @@ -415,7 +421,7 @@ auto alIsEnabled(gsl::not_null context, ALenum capability) noexcep } -auto alGetString(gsl::not_null context, ALenum pname) noexcept -> gsl::czstring +auto alGetString_(gsl::not_null context, ALenum pname) noexcept -> gsl::czstring { switch(pname) { @@ -446,7 +452,7 @@ auto alGetString(gsl::not_null context, ALenum pname) noexcept -> } -void alDopplerFactor(gsl::not_null context, ALfloat value) noexcept +void alDopplerFactor_(gsl::not_null context, ALfloat value) noexcept { if(!(value >= 0.0f && std::isfinite(value))) context->setError(AL_INVALID_VALUE, "Doppler factor {} out of range", value); @@ -458,7 +464,7 @@ void alDopplerFactor(gsl::not_null context, ALfloat value) noexcep } } -void alSpeedOfSound(gsl::not_null context, ALfloat value) noexcept +void alSpeedOfSound_(gsl::not_null context, ALfloat value) noexcept { if(!(value > 0.0f && std::isfinite(value))) context->setError(AL_INVALID_VALUE, "Speed of sound {} out of range", value); @@ -470,7 +476,7 @@ void alSpeedOfSound(gsl::not_null context, ALfloat value) noexcept } } -void alDistanceModel(gsl::not_null context, ALenum value) noexcept +void alDistanceModel_(gsl::not_null context, ALenum value) noexcept { if(auto model = DistanceModelFromALenum(value)) { @@ -485,7 +491,7 @@ void alDistanceModel(gsl::not_null context, ALenum value) noexcept } -auto alGetStringiSOFT(gsl::not_null context, ALenum pname, ALsizei index) noexcept +auto alGetStringiSOFT_(gsl::not_null context, ALenum pname, ALsizei index) noexcept -> gsl::czstring { switch(pname) @@ -502,13 +508,13 @@ auto alGetStringiSOFT(gsl::not_null context, ALenum pname, ALsizei } -void alDeferUpdatesSOFT(gsl::not_null context) noexcept +void alDeferUpdatesSOFT_(gsl::not_null context) noexcept { auto proplock = std::lock_guard{context->mPropLock}; context->deferUpdates(); } -void alProcessUpdatesSOFT(gsl::not_null context) noexcept +void alProcessUpdatesSOFT_(gsl::not_null context) noexcept { auto proplock = std::lock_guard{context->mPropLock}; context->processUpdates(); @@ -527,9 +533,9 @@ AL_API auto AL_APIENTRY alsoft_get_version() noexcept -> const ALchar* } -AL_API DECL_FUNC1(void, alEnable, ALenum,capability) -AL_API DECL_FUNC1(void, alDisable, ALenum,capability) -AL_API DECL_FUNC1(ALboolean, alIsEnabled, ALenum,capability) +DECL_FUNC(AL_API, void, alEnable, ALenum,capability) +DECL_FUNC(AL_API, void, alDisable, ALenum,capability) +DECL_FUNC(AL_API, ALboolean, alIsEnabled, ALenum,capability) #define DECL_GETFUNC(DECL, R, Name, Ext) \ DECL auto AL_APIENTRY Name##Ext(ALenum pname) noexcept -> R \ @@ -540,6 +546,7 @@ DECL auto AL_APIENTRY Name##Ext(ALenum pname) noexcept -> R \ GetValue(gsl::make_not_null(context.get()), pname, &value); \ return value; \ } \ +DefineFuncAlias(Name##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, \ ALenum pname) noexcept -> R \ { \ @@ -547,17 +554,20 @@ FORCE_ALIGN auto AL_APIENTRY Name##Direct##Ext(ALCcontext *context, \ GetValue(al::verify_context(context), pname, &value); \ return value; \ } \ +DefineFuncAlias(Name##Direct##Ext) \ DECL auto AL_APIENTRY Name##v##Ext(ALenum pname, R *values) noexcept -> void \ { \ auto context = GetContextRef(); \ if(context) [[likely]] \ GetValue(gsl::make_not_null(context.get()), pname, values); \ } \ +DefineFuncAlias(Name##v##Ext) \ FORCE_ALIGN auto AL_APIENTRY Name##v##Direct##Ext(ALCcontext *context, \ ALenum pname, R *values) noexcept -> void \ { \ GetValue(al::verify_context(context), pname, values); \ -} +} \ +DefineFuncAlias(Name##v##Direct##Ext) DECL_GETFUNC(AL_API, ALboolean, alGetBoolean,) DECL_GETFUNC(AL_API, ALdouble, alGetDouble,) @@ -570,16 +580,16 @@ DECL_GETFUNC(AL_API, ALvoidptr, alGetPointer,SOFT) #undef DECL_GETFUNC -AL_API DECL_FUNC1(const ALchar*, alGetString, ALenum,pname) +DECL_FUNC(AL_API, const ALchar*, alGetString, ALenum,pname) -AL_API DECL_FUNC1(void, alDopplerFactor, ALfloat,value) -AL_API DECL_FUNC1(void, alSpeedOfSound, ALfloat,value) -AL_API DECL_FUNC1(void, alDistanceModel, ALenum,value) +DECL_FUNC(AL_API, void, alDopplerFactor, ALfloat,value) +DECL_FUNC(AL_API, void, alSpeedOfSound, ALfloat,value) +DECL_FUNC(AL_API, void, alDistanceModel, ALenum,value) -AL_API DECL_FUNCEXT(void, alDeferUpdates,SOFT) -AL_API DECL_FUNCEXT(void, alProcessUpdates,SOFT) +DECL_FUNCEXT(AL_API, void, alDeferUpdates,SOFT) +DECL_FUNCEXT(AL_API, void, alProcessUpdates,SOFT) -AL_API DECL_FUNCEXT2(const ALchar*, alGetStringi,SOFT, ALenum,pname, ALsizei,index) +DECL_FUNCEXT(AL_API, const ALchar*, alGetStringi,SOFT, ALenum,pname, ALsizei,index) AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value) noexcept @@ -602,6 +612,7 @@ AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value) noexcept UpdateProps(context.get()); } } +DefineFuncAlias(alDopplerVelocity) void UpdateContextProps(al::Context *context) diff --git a/3rdparty/openal/alc/alc.cpp b/3rdparty/openal/alc/alc.cpp index 37f8e59d0546..321b185cad35 100644 --- a/3rdparty/openal/alc/alc.cpp +++ b/3rdparty/openal/alc/alc.cpp @@ -79,11 +79,9 @@ #include "alstring.h" #include "alu.h" #include "atomic.h" -#include "context.h" #include "core/ambidefs.h" #include "core/bformatdec.h" #include "core/bs2b.h" -#include "core/context.h" #include "core/cpu_caps.h" #include "core/devformat.h" #include "core/device.h" @@ -94,7 +92,6 @@ #include "core/front_stablizer.h" #include "core/helpers.h" #include "core/hrtf.h" -#include "core/logging.h" #include "core/mastering.h" #include "core/tsmefilter.hpp" #include "core/uhjfilter.h" @@ -172,6 +169,16 @@ #include "al/eax/globals.h" #endif +#if HAVE_CXXMODULES +import alc.context; +import format.types; +import logging; +#else +#include "context.hpp" +#include "alformattypes.hpp" +#include "core/logging.h" +#endif + /************************************************ * Library initialization @@ -194,6 +201,12 @@ auto APIENTRY DllMain(HINSTANCE module, DWORD reason, LPVOID /*reserved*/) -> BO namespace { +#if defined(__linux__) && !defined(AL_LIBTYPE_STATIC) && HAS_ATTRIBUTE(gnu::alias) +#define DefineAlcAlias(X) extern "C" DECL_HIDDEN [[gnu::alias(#X)]] decltype(X) X##_; +#else +#define DefineAlcAlias(X) +#endif + using namespace std::string_view_literals; using std::chrono::seconds; using std::chrono::nanoseconds; @@ -360,7 +373,8 @@ constexpr auto DitherRNGSeed = 22222u; constexpr auto extlist = std::string_view{GetNoDeviceExtString()}; auto ret = std::array{}; std::ranges::transform(extlist | std::views::split(' '), ret.begin(), - [](auto&& namerange) { return std::string_view{namerange.begin(), namerange.end()}; }); + [](std::ranges::contiguous_range auto&& namerange) -> std::string_view + { return std::string_view{std::to_address(namerange.begin()), namerange.size()}; }); return ret; } /* Returns the above Extension string as an array of string_views. */ @@ -369,7 +383,8 @@ constexpr auto DitherRNGSeed = 22222u; constexpr auto extlist = std::string_view{GetExtensionString()}; auto ret = std::array{}; std::ranges::transform(extlist | std::views::split(' '), ret.begin(), - [](auto&& namerange) { return std::string_view{namerange.begin(), namerange.end()}; }); + [](std::ranges::contiguous_range auto&& namerange) -> std::string_view + { return std::string_view{std::to_address(namerange.begin()), namerange.size()}; }); return ret; } @@ -436,6 +451,9 @@ void alc_initconfig() } auto capfilter = 0; +#if HAVE_NEON + capfilter |= CPU_CAP_NEON; +#endif #if HAVE_SSE4_1 capfilter |= CPU_CAP_SSE | CPU_CAP_SSE2 | CPU_CAP_SSE3 | CPU_CAP_SSE4_1; #elif HAVE_SSE3 @@ -444,9 +462,6 @@ void alc_initconfig() capfilter |= CPU_CAP_SSE | CPU_CAP_SSE2; #elif HAVE_SSE capfilter |= CPU_CAP_SSE; -#endif -#if HAVE_NEON - capfilter |= CPU_CAP_NEON; #endif if(auto cpuopt = ConfigValueStr({}, {}, "disable-cpu-exts"sv)) { @@ -454,9 +469,11 @@ void alc_initconfig() capfilter = 0; else { - std::ranges::for_each(cpulist | std::views::split(','), [&capfilter](auto&& namerange) + std::ranges::for_each(cpulist | std::views::split(','), + [&capfilter](std::ranges::contiguous_range auto&& namerange) { - auto entry = std::string_view{namerange.begin(), namerange.end()}; + auto entry = std::string_view{std::to_address(namerange.begin()), + namerange.size()}; constexpr auto wspace_chars = " \t\n\f\r\v"sv; entry.remove_prefix(std::min(entry.find_first_not_of(wspace_chars), entry.size())); entry.remove_suffix(entry.size() - (entry.find_last_not_of(wspace_chars)+1)); @@ -544,6 +561,18 @@ void alc_initconfig() else WARN("Unsupported uhj/encode-filter: {}", *uhjfiltopt); } + + if(auto tsmefiltopt = ConfigValueStr({}, "tsme"sv, "decode-filter"sv)) + { + if(al::case_compare(*tsmefiltopt, "fir256"sv) == 0) + TsmeDecodeQuality = TsmeQualityType::FIR256; + else if(al::case_compare(*tsmefiltopt, "fir512"sv) == 0) + TsmeDecodeQuality = TsmeQualityType::FIR512; + else if(al::case_compare(*tsmefiltopt, "iir"sv) == 0) + TsmeDecodeQuality = TsmeQualityType::IIR; + else + WARN("Unsupported tsme/decode-filter: {}", *tsmefiltopt); + } if(auto tsmefiltopt = ConfigValueStr({}, "tsme"sv, "encode-filter"sv)) { if(al::case_compare(*tsmefiltopt, "fir256"sv) == 0) @@ -596,9 +625,10 @@ void alc_initconfig() auto endlist = true; std::ranges::for_each(*drvopt | std::views::split(','), - [backends,&BackendListEnd,&backendlist_cur,&endlist](auto&& namerange) + [backends,&BackendListEnd,&backendlist_cur,&endlist] + (std::ranges::contiguous_range auto&& namerange) { - auto entry = std::string_view{namerange.begin(), namerange.end()}; + auto entry = std::string_view{std::to_address(namerange.begin()), namerange.size()}; constexpr auto whitespace_chars = " \t\n\f\r\v"sv; entry.remove_prefix(std::min(entry.find_first_not_of(whitespace_chars), entry.size())); @@ -681,9 +711,11 @@ void alc_initconfig() if(auto exclopt = ConfigValueStr({}, {}, "excludefx"sv)) { - std::ranges::for_each(*exclopt | std::views::split(','), [](auto&& namerange) noexcept + std::ranges::for_each(*exclopt | std::views::split(','), + [](std::ranges::contiguous_range auto&& namerange) noexcept { - const auto entry = std::string_view{namerange.begin(), namerange.end()}; + const auto entry = std::string_view{std::to_address(namerange.begin()), + namerange.size()}; std::ranges::for_each(gEffectList, [entry](const EffectList &effectitem) noexcept { if(entry == effectitem.name) @@ -1033,24 +1065,18 @@ constexpr auto X71Downmix = std::array{ }; -auto CreateDeviceLimiter(gsl::not_null const device, float const threshold) +auto CreateDeviceLimiter(gsl::not_null const device, f32 const threshold) -> std::unique_ptr { - static constexpr auto LookAheadTime = 0.001f; - static constexpr auto HoldTime = 0.002f; - static constexpr auto PreGainDb = 0.0f; - static constexpr auto PostGainDb = 0.0f; - static constexpr auto Ratio = std::numeric_limits::infinity(); - static constexpr auto KneeDb = 0.0f; - static constexpr auto AttackTime = 0.02f; - static constexpr auto ReleaseTime = 0.2f; - - auto const flags = Compressor::FlagBits{}.set(Compressor::AutoKnee).set(Compressor::AutoAttack) - .set(Compressor::AutoRelease).set(Compressor::AutoPostGain).set(Compressor::AutoDeclip); + auto const flags = Compressor::FlagBits{}.set(Compressor::Flags::AutoKnee) + .set(Compressor::Flags::AutoAttack).set(Compressor::Flags::AutoRelease) + .set(Compressor::Flags::AutoPostGain).set(Compressor::Flags::AutoDeclip); - return Compressor::Create(device->RealOut.Buffer.size(), - gsl::narrow_cast(device->mSampleRate), flags, LookAheadTime, HoldTime, PreGainDb, - PostGainDb, threshold, Ratio, KneeDb, AttackTime, ReleaseTime); + return Compressor::Create({.NumChans = usize{device->RealOut.Buffer.size()}.cast_to(), + .SampleRate = sys_uint{device->mSampleRate}.reinterpret_as(), .AutoFlags = flags, + .LookAheadTime = 0.001_f32, .HoldTime = 0.002_f32, .PreGainDb = 0.0_f32, + .PostGainDb = 0.0_f32, .ThresholdDb = threshold, .Ratio = f32::infinity(), + .KneeDb = 0.0_f32, .AttackTime = 0.02_f32, .ReleaseTime = 0.2_f32}); } /** @@ -1263,86 +1289,77 @@ auto UpdateDeviceParams(gsl::not_null device, auto opthrtf = std::optional{}; auto freqAttr = int{}; - for(const auto attrparam : attrList) + for(auto const [attrparam, attrvalue] : attrList) { -#define ATTRIBUTE(a) a: TRACE("{} = {}", #a, attrparam.value); -#define ATTRIBUTE_HEX(a) a: TRACE("{} = {:#x}", #a, as_unsigned(attrparam.value)); - switch(attrparam.attribute) +#define ATTRIBUTE(a) a: TRACE("{} = {}", #a, attrvalue); +#define ATTRIBUTE_HEX(a) a: TRACE("{} = {:#x}", #a, as_unsigned(attrvalue)); + switch(attrparam) { case ATTRIBUTE_HEX(ALC_FORMAT_CHANNELS_SOFT) if(device->Type == DeviceType::Loopback) - optchans = DevFmtChannelsFromEnum(attrparam.value); + optchans = DevFmtChannelsFromEnum(attrvalue); break; case ATTRIBUTE_HEX(ALC_FORMAT_TYPE_SOFT) if(device->Type == DeviceType::Loopback) - opttype = DevFmtTypeFromEnum(attrparam.value); + opttype = DevFmtTypeFromEnum(attrvalue); break; case ATTRIBUTE(ALC_FREQUENCY) - freqAttr = attrparam.value; + freqAttr = attrvalue; break; case ATTRIBUTE_HEX(ALC_AMBISONIC_LAYOUT_SOFT) if(device->Type == DeviceType::Loopback) - optlayout = DevAmbiLayoutFromEnum(attrparam.value); + optlayout = DevAmbiLayoutFromEnum(attrvalue); break; case ATTRIBUTE_HEX(ALC_AMBISONIC_SCALING_SOFT) if(device->Type == DeviceType::Loopback) - optscale = DevAmbiScalingFromEnum(attrparam.value); + optscale = DevAmbiScalingFromEnum(attrvalue); break; case ATTRIBUTE(ALC_AMBISONIC_ORDER_SOFT) if(device->Type == DeviceType::Loopback) - aorder = gsl::narrow_cast(attrparam.value); + aorder = gsl::narrow_cast(attrvalue); break; case ATTRIBUTE(ALC_MONO_SOURCES) - if(const auto val = attrparam.value; val >= 0) - numMono = gsl::narrow_cast(val); - else - numMono = 0; + numMono = al::saturate_cast(attrvalue); break; case ATTRIBUTE(ALC_STEREO_SOURCES) - if(const auto val = attrparam.value; val >= 0) - numStereo = gsl::narrow_cast(val); - else - numStereo = 0; + numStereo = al::saturate_cast(attrvalue); break; case ATTRIBUTE(ALC_MAX_AUXILIARY_SENDS) - if(const auto val = attrparam.value; val >= 0) - numSends = std::min(gsl::narrow_cast(val), ALCuint{MaxSendCount}); - else - numSends = 0; + numSends = gsl::narrow(std::clamp(attrvalue, 0, MaxSendCount)); break; case ATTRIBUTE(ALC_HRTF_SOFT) - if(attrparam.value == ALC_FALSE) + if(attrvalue == ALC_FALSE) opthrtf = false; - else if(attrparam.value == ALC_TRUE) + else if(attrvalue == ALC_TRUE) opthrtf = true; - else if(attrparam.value == ALC_DONT_CARE_SOFT) + else if(attrvalue == ALC_DONT_CARE_SOFT) opthrtf = std::nullopt; break; case ATTRIBUTE(ALC_HRTF_ID_SOFT) - hrtf_id = attrparam.value; + hrtf_id = attrvalue; break; case ATTRIBUTE(ALC_OUTPUT_LIMITER_SOFT) - if(attrparam.value == ALC_FALSE) + if(attrvalue == ALC_FALSE) optlimit = false; - else if(attrparam.value == ALC_TRUE) + else if(attrvalue == ALC_TRUE) optlimit = true; - else if(attrparam.value == ALC_DONT_CARE_SOFT) + else if(attrvalue == ALC_DONT_CARE_SOFT) optlimit = std::nullopt; break; case ATTRIBUTE_HEX(ALC_OUTPUT_MODE_SOFT) - outmode = attrparam.value; + outmode = attrvalue; break; case ATTRIBUTE_HEX(ALC_CONTEXT_FLAGS_EXT) @@ -1358,8 +1375,8 @@ auto UpdateDeviceParams(gsl::not_null device, break; default: - TRACE("{:#04x} = {} ({:#x})", as_unsigned(attrparam.attribute), attrparam.value, - as_unsigned(attrparam.value)); + TRACE("{:#06x} = {} ({:#x})", as_unsigned(attrparam), attrvalue, + as_unsigned(attrvalue)); break; } #undef ATTRIBUTE_HEX @@ -1402,7 +1419,7 @@ auto UpdateDeviceParams(gsl::not_null device, else if(outmode == ALC_STEREO_HRTF_SOFT) stereomode = StereoEncoding::Hrtf; } - optsrate = gsl::narrow_cast(freqAttr); + optsrate = gsl::narrow(freqAttr); } else { @@ -1513,7 +1530,8 @@ auto UpdateDeviceParams(gsl::not_null device, device->mAmbiLayout = *optlayout; device->mAmbiScale = *optscale; } - device->Flags.set(FrequencyRequest).set(ChannelsRequest).set(SampleTypeRequest); + device->mFlags.set(DeviceFlag::FrequencyRequest).set(DeviceFlag::ChannelsRequest) + .set(DeviceFlag::SampleTypeRequest); } else { @@ -1523,9 +1541,9 @@ auto UpdateDeviceParams(gsl::not_null device, device->mBufferSize = buffer_size; device->mUpdateSize = period_size; device->mSampleRate = optsrate.value_or(DefaultOutputRate); - device->Flags.set(FrequencyRequest, optsrate.has_value()) - .set(ChannelsRequest, optchans.has_value()) - .set(SampleTypeRequest, opttype.has_value()); + device->mFlags.set(DeviceFlag::FrequencyRequest, optsrate.has_value()) + .set(DeviceFlag::ChannelsRequest, optchans.has_value()) + .set(DeviceFlag::SampleTypeRequest, opttype.has_value()); if(device->FmtChans == DevFmtAmbi3D) { @@ -1544,9 +1562,11 @@ auto UpdateDeviceParams(gsl::not_null device, } TRACE("Pre-reset: {}{}, {}{}, {}{}hz, {} / {} buffer", - device->Flags.test(ChannelsRequest)?"*":"", DevFmtChannelsString(device->FmtChans), - device->Flags.test(SampleTypeRequest)?"*":"", DevFmtTypeString(device->FmtType), - device->Flags.test(FrequencyRequest)?"*":"", device->mSampleRate, + device->mFlags.test(DeviceFlag::ChannelsRequest) ? "*" : "", + DevFmtChannelsString(device->FmtChans), + device->mFlags.test(DeviceFlag::SampleTypeRequest) ? "*" : "", + DevFmtTypeString(device->FmtType), + device->mFlags.test(DeviceFlag::FrequencyRequest) ? "*" : "", device->mSampleRate, device->mUpdateSize, device->mBufferSize); const auto oldFreq = device->mSampleRate; @@ -1562,22 +1582,22 @@ auto UpdateDeviceParams(gsl::not_null device, return ALC_INVALID_DEVICE; } - if(device->FmtChans != oldChans && device->Flags.test(ChannelsRequest)) + if(device->FmtChans != oldChans && device->mFlags.test(DeviceFlag::ChannelsRequest)) { ERR("Failed to set {}, got {} instead", DevFmtChannelsString(oldChans), DevFmtChannelsString(device->FmtChans)); - device->Flags.reset(ChannelsRequest); + device->mFlags.reset(DeviceFlag::ChannelsRequest); } - if(device->FmtType != oldType && device->Flags.test(SampleTypeRequest)) + if(device->FmtType != oldType && device->mFlags.test(DeviceFlag::SampleTypeRequest)) { ERR("Failed to set {}, got {} instead", DevFmtTypeString(oldType), DevFmtTypeString(device->FmtType)); - device->Flags.reset(SampleTypeRequest); + device->mFlags.reset(DeviceFlag::SampleTypeRequest); } - if(device->mSampleRate != oldFreq && device->Flags.test(FrequencyRequest)) + if(device->mSampleRate != oldFreq && device->mFlags.test(DeviceFlag::FrequencyRequest)) { WARN("Failed to set {}hz, got {}hz instead", oldFreq, device->mSampleRate); - device->Flags.reset(FrequencyRequest); + device->mFlags.reset(DeviceFlag::FrequencyRequest); } TRACE("Post-reset: {}, {}, {}hz, {} / {} buffer", @@ -1589,9 +1609,9 @@ auto UpdateDeviceParams(gsl::not_null device, if(auto modeopt = device->configValue({}, "stereo-mode")) { if(al::case_compare(*modeopt, "headphones"sv) == 0) - device->Flags.set(DirectEar); + device->mFlags.set(DeviceFlag::DirectEar); else if(al::case_compare(*modeopt, "speakers"sv) == 0) - device->Flags.reset(DirectEar); + device->mFlags.reset(DeviceFlag::DirectEar); else if(al::case_compare(*modeopt, "auto"sv) != 0) ERR("Unexpected stereo-mode: {}", *modeopt); } @@ -1643,7 +1663,7 @@ auto UpdateDeviceParams(gsl::not_null device, case DevFmtAmbi3D: break; } - auto sample_delay = 0_uz; + auto sample_delay = 0_usize; if(auto *uhjenc = std::get_if(&device->mPostProcess)) sample_delay += uhjenc->mUhjEncoder->getDelay(); @@ -1708,7 +1728,7 @@ auto UpdateDeviceParams(gsl::not_null device, TRACE("Output limiter disabled"); else { - auto thrshld = 1.0f; + auto thrshld = 1.0_f32; switch(device->FmtType) { case DevFmtByte: @@ -1727,7 +1747,7 @@ auto UpdateDeviceParams(gsl::not_null device, if(device->DitherDepth > 0.0f) thrshld -= 1.0f / device->DitherDepth; - const auto thrshld_dB = std::log10(thrshld) * 20.0f; + const auto thrshld_dB = log10(thrshld) * 20.0f; auto limiter = CreateDeviceLimiter(device, thrshld_dB); sample_delay += limiter->getLookAhead(); @@ -1736,8 +1756,8 @@ auto UpdateDeviceParams(gsl::not_null device, } /* Convert the sample delay from samples to nanosamples to nanoseconds. */ - sample_delay = std::min(sample_delay, usize{std::numeric_limits::max()}); - device->FixedLatency += nanoseconds{seconds{sample_delay}} / device->mSampleRate; + sample_delay = std::min(sample_delay, i32::max().as()); + device->FixedLatency += nanoseconds{seconds{sample_delay.c_val}} / device->mSampleRate; TRACE("Fixed device latency: {}ns", device->FixedLatency.count()); auto mixer_mode = FPUCtl{}; @@ -1868,7 +1888,7 @@ auto UpdateDeviceParams(gsl::not_null device, mixer_mode.leave(); device->mDeviceState = DeviceState::Configured; - if(!device->Flags.test(DevicePaused)) + if(!device->mFlags.test(DeviceFlag::DevicePaused)) { try { auto backend = device->Backend.get(); @@ -2019,6 +2039,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device) noexcept return al::Device::sLastGlobalError.exchange(ALC_NO_ERROR); } } +DefineAlcAlias(alcGetError) ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context) noexcept @@ -2039,6 +2060,7 @@ try { } catch(al::base_exception&) { } +DefineAlcAlias(alcSuspendContext) ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context) noexcept try { @@ -2058,6 +2080,7 @@ try { } catch(al::base_exception&) { } +DefineAlcAlias(alcProcessContext) ALC_API auto ALC_APIENTRY alcGetString(ALCdevice *Device, ALCenum param) noexcept -> const ALCchar* @@ -2162,10 +2185,11 @@ try { catch(al::base_exception&) { return nullptr; } +DefineAlcAlias(alcGetString) namespace { auto GetIntegerv(al::Device *const device, ALCenum const param, std::span const values) - -> usize + -> std::size_t { Expects(!values.empty()); @@ -2497,6 +2521,7 @@ try { } catch(al::base_exception&) { } +DefineAlcAlias(alcGetIntegerv) ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, ALCsizei size, ALCint64SOFT *values) noexcept @@ -2646,6 +2671,7 @@ try { } catch(al::base_exception&) { } +DefineAlcAlias(alcGetInteger64vSOFT) ALC_API auto ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extName) noexcept @@ -2672,11 +2698,13 @@ try { catch(al::base_exception&) { return ALC_FALSE; } +DefineAlcAlias(alcIsExtensionPresent) auto ALC_APIENTRY alcGetProcAddress2(ALCdevice *device, const ALCchar *funcName) noexcept -> ALCvoid* { return alcGetProcAddress(device, funcName); } +DefineAlcAlias(alcGetProcAddress2) ALC_API auto ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcName) noexcept -> ALCvoid* @@ -2706,6 +2734,7 @@ try { catch(al::base_exception&) { return nullptr; } +DefineAlcAlias(alcGetProcAddress) ALC_API auto ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumName) noexcept @@ -2735,6 +2764,7 @@ try { catch(al::base_exception&) { return 0; } +DefineAlcAlias(alcGetEnumValue) ALC_API auto ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList) noexcept @@ -2764,11 +2794,11 @@ try { } auto ctxflags = ContextFlagBitset{0}; - for(const auto attrparam : attrSpan) + for(auto const [attrparam, attrvalue] : attrSpan) { - if(attrparam.attribute == ALC_CONTEXT_FLAGS_EXT) + if(attrparam == ALC_CONTEXT_FLAGS_EXT) { - ctxflags = as_unsigned(attrparam.value); + ctxflags = as_unsigned(attrvalue); break; } } @@ -2846,6 +2876,7 @@ catch(std::exception &e) { ERR("Caught exception in {}: {}", std::source_location::current().function_name(), e.what()); return nullptr; } +DefineAlcAlias(alcCreateContext) ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context) noexcept { @@ -2879,6 +2910,7 @@ ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context) noexcept device->mDeviceState = DeviceState::Configured; } } +DefineAlcAlias(alcDestroyContext) ALC_API auto ALC_APIENTRY alcGetCurrentContext() noexcept -> ALCcontext* @@ -2887,10 +2919,12 @@ ALC_API auto ALC_APIENTRY alcGetCurrentContext() noexcept -> ALCcontext* if(!Context) Context = al::Context::sGlobalContext.load(); return Context; } +DefineAlcAlias(alcGetCurrentContext) /** Returns the currently active thread-local context. */ ALC_API auto ALC_APIENTRY alcGetThreadContext() noexcept -> ALCcontext* { return al::Context::getThreadContext(); } +DefineAlcAlias(alcGetThreadContext) ALC_API auto ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) noexcept -> ALCboolean try { @@ -2921,6 +2955,7 @@ try { catch(al::base_exception&) { return ALC_FALSE; } +DefineAlcAlias(alcMakeContextCurrent) /** Makes the given context the active context for the current thread. */ ALC_API auto ALC_APIENTRY alcSetThreadContext(ALCcontext *context) noexcept -> ALCboolean @@ -2937,6 +2972,7 @@ try { catch(al::base_exception&) { return ALC_FALSE; } +DefineAlcAlias(alcSetThreadContext) ALC_API auto ALC_APIENTRY alcGetContextsDevice(ALCcontext *Context) noexcept -> ALCdevice* @@ -2946,6 +2982,7 @@ try { catch(al::base_exception&) { return nullptr; } +DefineAlcAlias(alcGetContextsDevice) ALC_API auto ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) noexcept -> ALCdevice* @@ -3065,6 +3102,7 @@ catch(std::exception &e) { ERR("Caught exception in {}: {}", std::source_location::current().function_name(), e.what()); return nullptr; } +DefineAlcAlias(alcOpenDevice) ALC_API auto ALC_APIENTRY alcCloseDevice(ALCdevice *device) noexcept -> ALCboolean { @@ -3121,6 +3159,7 @@ ALC_API auto ALC_APIENTRY alcCloseDevice(ALCdevice *device) noexcept -> ALCboole return ALC_TRUE; } +DefineAlcAlias(alcCloseDevice) /************************************************ @@ -3172,9 +3211,9 @@ try { device->mSampleRate = frequency; device->FmtChans = decompfmt->chans; device->FmtType = decompfmt->type; - device->Flags.set(FrequencyRequest); - device->Flags.set(ChannelsRequest); - device->Flags.set(SampleTypeRequest); + device->mFlags.set(DeviceFlag::FrequencyRequest); + device->mFlags.set(DeviceFlag::ChannelsRequest); + device->mFlags.set(DeviceFlag::SampleTypeRequest); device->mUpdateSize = gsl::narrow_cast(samples); device->mBufferSize = gsl::narrow_cast(samples); @@ -3218,6 +3257,7 @@ catch(std::exception &e) { ERR("Caught exception in {}: {}", std::source_location::current().function_name(), e.what()); return nullptr; } +DefineAlcAlias(alcCaptureOpenDevice) ALC_API auto ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device) noexcept -> ALCboolean { @@ -3250,6 +3290,7 @@ ALC_API auto ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device) noexcept -> A return ALC_TRUE; } +DefineAlcAlias(alcCaptureCloseDevice) ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device) noexcept try { @@ -3280,6 +3321,7 @@ try { } catch(al::base_exception&) { } +DefineAlcAlias(alcCaptureStart) ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device) noexcept try { @@ -3298,6 +3340,7 @@ try { } catch(al::base_exception&) { } +DefineAlcAlias(alcCaptureStop) ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) noexcept @@ -3328,10 +3371,11 @@ try { } backend->captureSamples(std::span{static_cast(buffer), - usize{usamples}*dev->frameSizeFromFmt()}); + std::size_t{usamples}*dev->frameSizeFromFmt()}); } catch(al::base_exception&) { } +DefineAlcAlias(alcCaptureSamples) /************************************************ @@ -3407,6 +3451,7 @@ catch(std::exception &e) { ERR("Caught exception in {}: {}", std::source_location::current().function_name(), e.what()); return nullptr; } +DefineAlcAlias(alcLoopbackOpenDeviceSOFT) /** * Determines if the loopback device supports the given format for rendering. @@ -3431,6 +3476,7 @@ try { catch(al::base_exception&) { return ALC_FALSE; } +DefineAlcAlias(alcIsRenderFormatSupportedSOFT) /** * Renders some samples into a buffer, using the format last set by the @@ -3458,6 +3504,7 @@ ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffe return dev->setError(ALC_INVALID_VALUE); dev->renderSamples(buffer, gsl::narrow_cast(samples), dev->channelsFromFmt()); } +DefineAlcAlias(alcRenderSamplesSOFT) /************************************************ @@ -3478,11 +3525,12 @@ try { dev->Backend->stop(); dev->mDeviceState = DeviceState::Configured; } - dev->Flags.set(DevicePaused); + dev->mFlags.set(DeviceFlag::DevicePaused); } } catch(al::base_exception&) { } +DefineAlcAlias(alcDevicePauseSOFT) /** Resume the DSP to restart audio processing. */ ALC_API void ALC_APIENTRY alcDeviceResumeSOFT(ALCdevice *device) noexcept @@ -3495,7 +3543,7 @@ try { } auto statelock = std::lock_guard{dev->StateLock}; - if(!dev->Flags.test(DevicePaused)) + if(!dev->mFlags.test(DeviceFlag::DevicePaused)) return; if(dev->mDeviceState < DeviceState::Configured) { @@ -3509,7 +3557,7 @@ try { dev->setError(ALC_INVALID_DEVICE); return; } - dev->Flags.reset(DevicePaused); + dev->mFlags.reset(DeviceFlag::DevicePaused); if(dev->mContexts.load()->empty()) return; @@ -3530,6 +3578,7 @@ try { } catch(al::base_exception&) { } +DefineAlcAlias(alcDeviceResumeSOFT) /************************************************ @@ -3560,6 +3609,7 @@ try { catch(al::base_exception&) { return nullptr; } +DefineAlcAlias(alcGetStringiSOFT) /** Resets the given device output, using the specified attribute list. */ ALC_API auto ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs) noexcept @@ -3590,6 +3640,7 @@ try { catch(al::base_exception&) { return ALC_FALSE; } +DefineAlcAlias(alcResetDeviceSOFT) /************************************************ @@ -3713,6 +3764,7 @@ catch(std::exception &e) { ERR("Caught exception in {}: {}", std::source_location::current().function_name(), e.what()); return ALC_FALSE; } +DefineAlcAlias(alcReopenDeviceSOFT) /************************************************ * ALC event query functions @@ -3746,3 +3798,4 @@ FORCE_ALIGN auto ALC_APIENTRY alcEventIsSupportedSOFT(ALCenum eventType, ALCenum al::Device::SetGlobalError(ALC_INVALID_ENUM); return ALC_FALSE; } +DefineAlcAlias(alcEventIsSupportedSOFT) diff --git a/3rdparty/openal/alc/alconfig.cpp b/3rdparty/openal/alc/alconfig.cpp index 28ceb9e344c3..7925c18b53f2 100644 --- a/3rdparty/openal/alc/alconfig.cpp +++ b/3rdparty/openal/alc/alconfig.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,6 @@ #include "alnumeric.h" #include "alstring.h" #include "core/helpers.h" -#include "core/logging.h" #include "filesystem.h" #include "fmt/ranges.h" #include "gsl/gsl" @@ -62,6 +62,12 @@ using namespace winrt; #endif +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { using namespace std::string_view_literals; @@ -188,7 +194,7 @@ void LoadConfigFromFile(std::istream &f) auto curSection = std::string{}; auto buffer = std::string{}; - auto linenum = 0_uz; + auto linenum = std::size_t{0}; while(std::getline(f, buffer)) { diff --git a/3rdparty/openal/alc/alu.cpp b/3rdparty/openal/alc/alu.cpp index cb3faeda2c62..b7f0918ee98e 100644 --- a/3rdparty/openal/alc/alu.cpp +++ b/3rdparty/openal/alc/alu.cpp @@ -27,10 +27,7 @@ #include #include #include -#include #include -#include -#include #include #include #include @@ -119,8 +116,8 @@ auto NfcScale = 1.0f; using HrtfDirectMixerFunc = void(*)(FloatBufferSpan LeftOut, FloatBufferSpan RightOut, std::span InSamples, std::span AccumSamples, - std::span TempBuf, std::span ChanState, usize IrSize, - usize SamplesToDo); + std::span TempBuf, std::span ChanState, + std::size_t IrSize, std::size_t SamplesToDo); constinit auto MixDirectHrtf = HrtfDirectMixerFunc{MixDirectHrtf_C}; @@ -141,17 +138,18 @@ auto SelectHrtfMixer() -> HrtfDirectMixerFunc void BsincPrepare(unsigned const increment, BsincState *const state, BSincTable const *const table) + noexcept NONBLOCKING { - auto si = usize{BSincScaleCount - 1}; + auto si = std::size_t{BSincScaleCount - 1}; auto sf = 0.0_f32; if(increment > MixerFracOne) { - sf = MixerFracOne/f32::make_from(increment) - table->scaleBase; - sf = std::max(0.0_f32, BSincScaleCount*sf*table->scaleRange - 1.0f); + sf = float{MixerFracOne}/f32::from(increment) - table->scaleBase; + sf = std::max(0.0_f32, float{BSincScaleCount}*sf*table->scaleRange - 1.0f); si = float2uint(sf.c_val); - sf -= f32::make_from(si); + sf -= f32::from(si); /* The interpolation factor is fit to this diagonally-symmetric curve * to reduce the transition ripple caused by interpolating different * scales of the sinc function. @@ -161,12 +159,13 @@ void BsincPrepare(unsigned const increment, BsincState *const state, BSincTable state->sf = sf.c_val; state->m = table->m[si]; - state->l = (state->m/2) - 1; + state->l = (state->m/2u) - 1u; state->filter = table->Tab.subspan(table->filterOffset[si].c_val); } [[nodiscard]] -auto SelectResampler(Resampler const resampler, unsigned const increment) -> ResamplerFunc +auto SelectResampler(Resampler const resampler, unsigned const increment) noexcept NONBLOCKING + -> ResamplerFunc { switch(resampler) { @@ -252,7 +251,7 @@ void aluInit(CompatFlagBitset const flags, float const nfcscale) auto PrepareResampler(Resampler const resampler, unsigned const increment, - InterpState *const state) -> ResamplerFunc + InterpState *const state) noexcept NONBLOCKING -> ResamplerFunc { switch(resampler) { @@ -282,12 +281,12 @@ auto PrepareResampler(Resampler const resampler, unsigned const increment, } -void DeviceBase::Process(AmbiDecPostProcess const &proc, usize const SamplesToDo) const +void DeviceBase::Process(AmbiDecPostProcess const &proc, std::size_t const SamplesToDo) const { proc.mAmbiDecoder->process(RealOut.Buffer, Dry.Buffer, SamplesToDo); } -void DeviceBase::Process(HrtfPostProcess const &proc, usize const SamplesToDo) +void DeviceBase::Process(HrtfPostProcess const &proc, std::size_t const SamplesToDo) { /* HRTF is stereo output only. */ auto const lidx = RealOut.ChannelIndex[FrontLeft]; @@ -298,7 +297,7 @@ void DeviceBase::Process(HrtfPostProcess const &proc, usize const SamplesToDo) proc.mHrtfState->mIrSize, SamplesToDo); } -void DeviceBase::Process(UhjPostProcess const &proc, usize const SamplesToDo) +void DeviceBase::Process(UhjPostProcess const &proc, std::size_t const SamplesToDo) { /* UHJ is stereo output only. */ auto const lidx = RealOut.ChannelIndex[FrontLeft]; @@ -312,7 +311,7 @@ void DeviceBase::Process(UhjPostProcess const &proc, usize const SamplesToDo) std::span{Dry.Buffer[2]}.first(SamplesToDo)}}); } -void DeviceBase::Process(TsmePostProcess const &proc, usize const SamplesToDo) +void DeviceBase::Process(TsmePostProcess const &proc, std::size_t const SamplesToDo) { /* TSME is stereo output only. */ auto const lidx = RealOut.ChannelIndex[FrontLeft]; @@ -327,12 +326,12 @@ void DeviceBase::Process(TsmePostProcess const &proc, usize const SamplesToDo) std::span{Dry.Buffer[3]}.first(SamplesToDo)}}); } -void DeviceBase::Process(StablizerPostProcess const &proc, usize const SamplesToDo) +void DeviceBase::Process(StablizerPostProcess const &proc, std::size_t const SamplesToDo) { /* Decode with front image stabilization. */ - auto const lidx = usize{RealOut.ChannelIndex[FrontLeft].c_val}; - auto const ridx = usize{RealOut.ChannelIndex[FrontRight].c_val}; - auto const cidx = usize{RealOut.ChannelIndex[FrontCenter].c_val}; + auto const lidx = std::size_t{RealOut.ChannelIndex[FrontLeft].c_val}; + auto const ridx = std::size_t{RealOut.ChannelIndex[FrontRight].c_val}; + auto const cidx = std::size_t{RealOut.ChannelIndex[FrontCenter].c_val}; /* Move the existing direct L/R signal out so it doesn't get processed by * the stabilizer. @@ -405,7 +404,7 @@ void DeviceBase::Process(StablizerPostProcess const &proc, usize const SamplesTo } } -void DeviceBase::Process(Bs2bPostProcess const &proc, usize const SamplesToDo) +void DeviceBase::Process(Bs2bPostProcess const &proc, std::size_t const SamplesToDo) { /* BS2B is stereo output only. */ auto const lidx = RealOut.ChannelIndex[FrontLeft]; @@ -459,7 +458,7 @@ void UpsampleBFormatTransform( std::span,MaxAmbiChannels> const output, std::span const> const upsampler, std::span const,MaxAmbiChannels> const rotator, - usize const ambi_order) + std::size_t const ambi_order) { auto const num_chans = AmbiChannelsFromOrder(ambi_order); std::ranges::fill(output | std::views::take(upsampler.size()) | std::views::join, 0.0f); @@ -729,7 +728,7 @@ auto ScaleAzimuthFront3_2(std::array pos) -> std::array * followed by the third-order coefficients, etc. */ [[nodiscard]] -constexpr auto CalcRotatorSize(usize const l) noexcept -> usize +constexpr auto CalcRotatorSize(std::size_t const l) noexcept -> std::size_t { if(l >= 2) return (l*2 + 1)*(l*2 + 1) + CalcRotatorSize(l-1); @@ -805,16 +804,18 @@ void AmbiRotator(AmbiRotateMatrix &matrix, int const order) static constexpr auto P = [](isize const i, isize const l, isize const a, isize const n, usize const last_base, AmbiRotateMatrix const &R) { - auto const ri1 = R[ 1+2][gsl::narrow_cast(i+2_z)]; - auto const rim1 = R[-1+2][gsl::narrow_cast(i+2_z)]; - auto const ri0 = R[ 0+2][gsl::narrow_cast(i+2_z)]; + auto const ip2 = (i+2_z).reinterpret_as().c_val; + auto const ri1 = R[ 1+2][ip2]; + auto const rim1 = R[-1+2][ip2]; + auto const ri0 = R[ 0+2][ip2]; - auto const x = last_base + gsl::narrow_cast(a+l-1); + auto const lm1 = (l-1_z).reinterpret_as().c_val; + auto const x = (last_base + lm1 + a.reinterpret_as()).c_val; if(n == -l) - return ri1*R[last_base][x] + rim1*R[last_base + gsl::narrow_cast(l-1_z)*2][x]; + return ri1*R[last_base.c_val][x] + rim1*R[last_base.c_val + lm1*2][x]; if(n == l) - return ri1*R[last_base + gsl::narrow_cast(l-1_z)*2][x] - rim1*R[last_base][x]; - return ri0*R[last_base + gsl::narrow_cast(l-1_z+n)][x]; + return ri1*R[last_base.c_val + lm1*2][x] - rim1*R[last_base.c_val][x]; + return ri0*R[(last_base + lm1 + n.reinterpret_as()).c_val][x]; }; static constexpr auto U = [](isize const l, isize const m, isize const n, @@ -857,7 +858,7 @@ void AmbiRotator(AmbiRotateMatrix &matrix, int const order) auto coeffs = RotatorCoeffArray.mCoeffs.cbegin(); auto base_idx = 4_uz; auto last_base = 1_uz; - for(auto const l : std::views::iota(2, order+1)) + for(auto const l : std::views::iota(2_isize, isize{order}+1)) { auto y = base_idx; for(auto const n : std::views::iota(-l, l+1)) @@ -882,7 +883,7 @@ void AmbiRotator(AmbiRotateMatrix &matrix, int const order) ++y; } last_base = base_idx; - base_idx += gsl::narrow_cast(l)*2_uz + 1; + base_idx += (l*2 + 1).reinterpret_as().c_val; } } /* End ambisonic rotation helpers. */ @@ -936,7 +937,7 @@ void CalcAmbisonicPanning(Voice *const voice, float const xpos, float const ypos voice->mChans[0].mDryParams.NFCtrlFilter.adjust(w0); } - voice->mFlags.set(VoiceHasNfc); + voice->mFlags.set(VoiceFlag::HasNfc); } /* Panning a B-Format sound toward some direction is easy. Just pan the @@ -1050,7 +1051,7 @@ void CalcAmbisonicPanning(Voice *const voice, float const xpos, float const ypos for(const auto c : std::views::iota(0_uz, index_map.size())) { - auto const acn = usize{index_map[c].c_val}; + auto const acn = std::size_t{index_map[c].c_val}; auto const scale = scales[acn] * coverage; /* For channel 0, combine the B-Format signal (scaled according to the @@ -1332,7 +1333,7 @@ void CalcNormalPanning(Voice *const voice, float const xpos, float const ypos, f for(auto &chanparams : voice->mChans | std::views::take(chans.size())) chanparams.mDryParams.NFCtrlFilter.adjust(w0); - voice->mFlags.set(VoiceHasNfc); + voice->mFlags.set(VoiceFlag::HasNfc); } if(voice->mFmtChannels == FmtMono && !props.mPanningEnabled) @@ -1419,7 +1420,7 @@ void CalcNormalPanning(Voice *const voice, float const xpos, float const ypos, f for(auto &chanparams : voice->mChans | std::views::take(chans.size())) chanparams.mDryParams.NFCtrlFilter.adjust(w0); - voice->mFlags.set(VoiceHasNfc); + voice->mFlags.set(VoiceFlag::HasNfc); } /* With no distance, spread is only meaningful for 3D mono sources @@ -1574,7 +1575,7 @@ void CalcPanningAndFilters(Voice *const voice, float const xpos, float const ypo return {props.DirectChannels, {}}; }); - voice->mFlags.reset(VoiceHasHrtf).reset(VoiceHasNfc); + voice->mFlags.reset(VoiceFlag::HasHrtf).reset(VoiceFlag::HasNfc); if(auto *const decoder = voice->mDecoder.get()) decoder->mWidthControl = std::min(props.EnhWidth, 0.7f); @@ -1602,7 +1603,7 @@ void CalcPanningAndFilters(Voice *const voice, float const xpos, float const ypo sendslots, device); voice->mDuplicateMono = voice->mFmtChannels == FmtMono && props.mPanningEnabled; - voice->mFlags.set(VoiceHasHrtf); + voice->mFlags.set(VoiceFlag::HasHrtf); } else { @@ -2135,7 +2136,7 @@ void ProcessVoiceChanges(ContextBase *const ctx) } oldvoice->mPendingChange.store(false, std::memory_order_release); } - if(sendevt && enabledevt.test(al::to_underlying(AsyncEnableBits::SourceState))) + if(sendevt && enabledevt.test(AsyncEnableBits::SourceState)) SendSourceStateEvent(ctx, cur->mSourceID, cur->mState); next = cur->mNext.load(std::memory_order_acquire); @@ -2257,7 +2258,7 @@ void ProcessContexts(DeviceBase const *const device, unsigned const SamplesToDo) } -void ApplyDistanceComp(std::span const Samples, usize const SamplesToDo, +void ApplyDistanceComp(std::span const Samples, std::size_t const SamplesToDo, std::span const chandata) { ASSUME(SamplesToDo > 0); @@ -2291,7 +2292,7 @@ void ApplyDistanceComp(std::span const Samples, usize const Sam } void ApplyDither(std::span const Samples, unsigned *const dither_seed, - float const quant_scale, usize const SamplesToDo) + float const quant_scale, std::size_t const SamplesToDo) { static constexpr auto invRNGRange = 1.0 / std::numeric_limits::max(); ASSUME(SamplesToDo > 0); @@ -2345,7 +2346,7 @@ template<> [[nodiscard]] auto SampleConv(float const val) noexcept -> u8 template void Write(std::span const InBuffer, void *const OutBuffer, - usize const Offset, usize const SamplesToDo, usize const FrameStep) + std::size_t const Offset, std::size_t const SamplesToDo, std::size_t const FrameStep) { ASSUME(FrameStep > 0); ASSUME(SamplesToDo > 0); @@ -2376,7 +2377,7 @@ void Write(std::span const InBuffer, void *const OutBuffe template void Write(std::span const InBuffer, std::span const OutBuffers, - usize const Offset, usize const SamplesToDo) + std::size_t const Offset, std::size_t const SamplesToDo) { ASSUME(SamplesToDo > 0); @@ -2463,7 +2464,7 @@ void DeviceBase::renderSamples(std::span const outBuffers, unsigned } void DeviceBase::renderSamples(void *const outBuffer, unsigned const numSamples, - usize const frameStep) + std::size_t const frameStep) { auto mixer_mode = FPUCtl{}; auto total = 0u; diff --git a/3rdparty/openal/alc/alu.h b/3rdparty/openal/alc/alu.h index 10ed6e1cbdcd..d28f114a984a 100644 --- a/3rdparty/openal/alc/alu.h +++ b/3rdparty/openal/alc/alu.h @@ -1,10 +1,11 @@ #ifndef ALU_H #define ALU_H -#include #include #include +#include "bitset.hpp" + struct EffectSlotBase; enum class StereoEncoding : std::uint8_t; @@ -17,14 +18,14 @@ struct Device; constexpr inline auto GainMixMax = 1000.0f; /* +60dB */ -enum CompatFlags : std::uint8_t { +enum class CompatFlags : std::uint8_t { ReverseX, ReverseY, ReverseZ, - Count + MaxValue = ReverseZ }; -using CompatFlagBitset = std::bitset; +using CompatFlagBitset = al::bitset; void aluInit(CompatFlagBitset flags, float nfcscale); diff --git a/3rdparty/openal/alc/backends/alsa.cpp b/3rdparty/openal/alc/backends/alsa.cpp index 57d236614cdc..6b17ee10646d 100644 --- a/3rdparty/openal/alc/backends/alsa.cpp +++ b/3rdparty/openal/alc/backends/alsa.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -43,13 +42,18 @@ #include "althrd_setname.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "dynload.h" #include "gsl/gsl" #include "ringbuffer.h" #include +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { @@ -730,7 +734,7 @@ auto AlsaPlayback::reset() -> bool } /* set rate (implicitly constrains period/buffer parameters) */ if(!GetConfigValueBool(mDevice->mDeviceName, "alsa", "allow-resampler", false) - || !mDevice->Flags.test(FrequencyRequest)) + || !mDevice->mFlags.test(DeviceFlag::FrequencyRequest)) { if(snd_pcm_hw_params_set_rate_resample(mPcmHandle, hp.get(), 0) < 0) WARN("Failed to disable ALSA resampler"); @@ -793,7 +797,7 @@ void AlsaPlayback::start() if(access == SND_PCM_ACCESS_RW_INTERLEAVED) { auto const datalen = snd_pcm_frames_to_bytes(mPcmHandle, mDevice->mUpdateSize); - mBuffer.resize(gsl::narrow(datalen)); + mBuffer.resize(gsl::narrow(datalen)); thread_func = &AlsaPlayback::mixerNoMMapProc; } else @@ -850,7 +854,7 @@ struct AlsaCapture final : public BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; auto getClockLatency() -> ClockLatency override; snd_pcm_t *mPcmHandle{nullptr}; @@ -985,7 +989,7 @@ void AlsaCapture::stop() */ auto const savail = al::saturate_cast(avail); auto const numbytes = snd_pcm_frames_to_bytes(mPcmHandle, savail); - auto temp = std::vector(al::saturate_cast(numbytes)); + auto temp = std::vector(al::saturate_cast(numbytes)); captureSamples(temp); mBuffer = std::move(temp); } @@ -1056,7 +1060,7 @@ void AlsaCapture::captureSamples(std::span outbuffer) std::ranges::fill(outbuffer, (mDevice->FmtType==DevFmtUByte)?std::byte{0x80}:std::byte{0}); } -auto AlsaCapture::availableSamples() -> usize +auto AlsaCapture::availableSamples() -> std::size_t { auto avail = snd_pcm_sframes_t{0}; if(mDevice->Connected.load(std::memory_order_acquire) && mDoCapture) @@ -1085,7 +1089,7 @@ auto AlsaCapture::availableSamples() -> usize avail = std::max(avail, 0); avail += snd_pcm_bytes_to_frames(mPcmHandle, std::ssize(mBuffer)); mLastAvail = std::max(mLastAvail, avail); - return gsl::narrow_cast(mLastAvail); + return gsl::narrow_cast(mLastAvail); } while(avail > 0) diff --git a/3rdparty/openal/alc/backends/base.cpp b/3rdparty/openal/alc/backends/base.cpp index fd28049e4689..94306142efe8 100644 --- a/3rdparty/openal/alc/backends/base.cpp +++ b/3rdparty/openal/alc/backends/base.cpp @@ -26,7 +26,7 @@ auto BackendBase::reset() -> bool void BackendBase::captureSamples(std::span outbuffer [[maybe_unused]]) { } -auto BackendBase::availableSamples() -> usize +auto BackendBase::availableSamples() -> std::size_t { return 0_uz; } auto BackendBase::getClockLatency() -> ClockLatency diff --git a/3rdparty/openal/alc/backends/base.h b/3rdparty/openal/alc/backends/base.h index 764e3a748965..5ca2580817b5 100644 --- a/3rdparty/openal/alc/backends/base.h +++ b/3rdparty/openal/alc/backends/base.h @@ -2,6 +2,7 @@ #define ALC_BACKENDS_BASE_H #include +#include #include #include #include @@ -10,7 +11,6 @@ #include "alc/events.h" #include "alformat.hpp" -#include "altypes.hpp" #include "core/device.h" #include "core/except.h" #include "gsl/gsl" @@ -30,7 +30,7 @@ struct BackendBase { virtual void stop() = 0; virtual void captureSamples(std::span outbuffer); - virtual auto availableSamples() -> usize; + virtual auto availableSamples() -> std::size_t; virtual auto getClockLatency() -> ClockLatency; diff --git a/3rdparty/openal/alc/backends/coreaudio.cpp b/3rdparty/openal/alc/backends/coreaudio.cpp index e62da767694f..fce77a7fd213 100644 --- a/3rdparty/openal/alc/backends/coreaudio.cpp +++ b/3rdparty/openal/alc/backends/coreaudio.cpp @@ -36,12 +36,10 @@ #include #include -#include "alformat.hpp" #include "alnumeric.h" #include "alstring.h" #include "core/converter.h" #include "core/device.h" -#include "core/logging.h" #include "gsl/gsl" #include "ringbuffer.h" @@ -55,6 +53,12 @@ #define CAN_ENUMERATE 1 #endif +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { constexpr auto OutputElement = 0; @@ -179,7 +183,7 @@ std::string GetDeviceName(AudioDeviceID devId) { const CFIndex propSize{CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef), kCFStringEncodingUTF8)}; - devname.resize(gsl::narrow_cast(propSize)+1, '\0'); + devname.resize(gsl::narrow_cast(propSize)+1, '\0'); CFStringGetCString(nameRef, &devname[0], propSize+1, kCFStringEncodingUTF8); CFRelease(nameRef); @@ -235,7 +239,7 @@ auto GetDeviceChannelCount(AudioDeviceID devId, bool isCapture) -> UInt32 } auto numChannels = UInt32{0}; - for(usize i{0};i < buflist->mNumberBuffers;++i) + for(auto i=0_uz;i < buflist->mNumberBuffers;++i) numChannels += buflist->mBuffers[i].mNumberChannels; return numChannels; } @@ -391,7 +395,7 @@ CoreAudioPlayback::~CoreAudioPlayback() OSStatus CoreAudioPlayback::MixerProc(AudioUnitRenderActionFlags*, const AudioTimeStamp*, UInt32, UInt32, AudioBufferList *ioData) noexcept { - for(usize i{0};i < ioData->mNumberBuffers;++i) + for(auto i=0_uz;i < ioData->mNumberBuffers;++i) { auto &buffer = ioData->mBuffers[i]; mDevice->renderSamples(buffer.mData, buffer.mDataByteSize/mFrameSize, @@ -497,7 +501,8 @@ void CoreAudioPlayback::open(std::string_view name) else { TRACE("Got device type '{}'", FourCCPrinter{type}.c_str()); - mDevice->Flags.set(DirectEar, (type == kIOAudioOutputPortSubTypeHeadphones)); + mDevice->mFlags.set(DeviceFlag::DirectEar, + (type == kIOAudioOutputPortSubTypeHeadphones)); } } @@ -551,7 +556,7 @@ bool CoreAudioPlayback::reset() { DevFmtMono, MonoChanMap, false } }}; - if(!mDevice->Flags.test(ChannelsRequest)) + if(!mDevice->mFlags.test(DeviceFlag::ChannelsRequest)) { auto propSize = UInt32{}; auto writable = Boolean{}; @@ -690,7 +695,7 @@ struct CoreAudioCapture final : public BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; AudioUnit mAudioUnit{0}; @@ -734,7 +739,8 @@ OSStatus CoreAudioCapture::RecordProc(AudioUnitRenderActionFlags *ioActionFlags, return err; } - std::ignore = mRing->write(std::span{mCaptureData}.first(inNumberFrames*usize{mFrameSize})); + std::ignore = mRing->write(std::span{mCaptureData} + .first(inNumberFrames*std::size_t{mFrameSize})); return noErr; } @@ -1024,7 +1030,7 @@ void CoreAudioCapture::captureSamples(std::span outbuffer) mRing->readAdvance(total_read); } -auto CoreAudioCapture::availableSamples() -> usize +auto CoreAudioCapture::availableSamples() -> std::size_t { if(!mConverter) return mRing->readSpace(); return mConverter->availableOut(gsl::narrow_cast(mRing->readSpace())); @@ -1102,7 +1108,6 @@ alc::EventSupport CoreAudioBackendFactory::queryEventSupport(alc::EventType even case alc::EventType::DeviceAdded: case alc::EventType::DeviceRemoved: - case alc::EventType::Count: break; } return alc::EventSupport::NoSupport; diff --git a/3rdparty/openal/alc/backends/dsound.cpp b/3rdparty/openal/alc/backends/dsound.cpp index 12155c1a4f21..1e839a282b74 100644 --- a/3rdparty/openal/alc/backends/dsound.cpp +++ b/3rdparty/openal/alc/backends/dsound.cpp @@ -35,19 +35,16 @@ #include #include #include -#include #include #include #include #include -#include "alformat.hpp" #include "alnumeric.h" #include "althrd_setname.h" #include "comptr.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "dynload.h" #include "gsl/gsl" #include "ringbuffer.h" @@ -86,6 +83,12 @@ DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); #endif +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { #if HAVE_DYNLOAD @@ -202,7 +205,7 @@ FORCE_ALIGN void DSoundPlayback::mixerProc() const return; } - auto const FrameStep = usize{mDevice->channelsFromFmt()}; + auto const FrameStep = std::size_t{mDevice->channelsFromFmt()}; auto const FrameSize = DWORD{mDevice->frameSizeFromFmt()}; auto const FragSize = DWORD{mDevice->mUpdateSize} * FrameSize; @@ -349,7 +352,7 @@ auto DSoundPlayback::reset() -> bool mDevice->FmtType = DevFmtUByte; break; case DevFmtFloat: - if(mDevice->Flags.test(SampleTypeRequest)) + if(mDevice->mFlags.test(DeviceFlag::SampleTypeRequest)) break; [[fallthrough]]; case DevFmtUShort: @@ -372,7 +375,7 @@ auto DSoundPlayback::reset() -> bool "Failed to get speaker config: {:#x}", as_unsigned(hr)}; speakers = DSSPEAKER_CONFIG(speakers); - if(!mDevice->Flags.test(ChannelsRequest)) + if(!mDevice->mFlags.test(DeviceFlag::ChannelsRequest)) { if(speakers == DSSPEAKER_MONO) mDevice->FmtChans = DevFmtMono; @@ -387,7 +390,7 @@ auto DSoundPlayback::reset() -> bool else ERR("Unknown system speaker config: {:#x}", speakers); } - mDevice->Flags.set(DirectEar, (speakers == DSSPEAKER_HEADPHONE)); + mDevice->mFlags.set(DeviceFlag::DirectEar, (speakers == DSSPEAKER_HEADPHONE)); auto const isRear51 = speakers == DSSPEAKER_5POINT1_BACK; switch(mDevice->FmtChans) @@ -530,7 +533,7 @@ struct DSoundCapture final : BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; ComPtr mDSC; ComPtr mDSCbuffer; @@ -692,7 +695,7 @@ void DSoundCapture::stop() void DSoundCapture::captureSamples(std::span outbuffer) { std::ignore = mRing->read(outbuffer); } -auto DSoundCapture::availableSamples() -> usize +auto DSoundCapture::availableSamples() -> std::size_t { if(mDevice->Connected.load(std::memory_order_acquire)) { diff --git a/3rdparty/openal/alc/backends/jack.cpp b/3rdparty/openal/alc/backends/jack.cpp index 911f5b2a2ede..acd19e967f69 100644 --- a/3rdparty/openal/alc/backends/jack.cpp +++ b/3rdparty/openal/alc/backends/jack.cpp @@ -23,10 +23,7 @@ #include "jack.h" #include -#include -#include #include -#include #include #include #include @@ -40,7 +37,6 @@ #include "althrd_setname.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "dynload.h" #include "gsl/gsl" #include "opthelpers.h" @@ -49,6 +45,12 @@ #include #include +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { @@ -365,7 +367,7 @@ int JackPlayback::process(jack_nframes_t numframes) noexcept { auto const data = mRing->getReadVector(); - const auto outlen = usize{numframes / mDevice->mUpdateSize}; + const auto outlen = std::size_t{numframes / mDevice->mUpdateSize}; const auto updates1 = std::min(data[0].size() / mRing->getElemSize(), outlen); const auto updates2 = std::min(data[1].size() / mRing->getElemSize(), outlen - updates1); @@ -519,8 +521,8 @@ bool JackPlayback::reset() mDevice->FmtType = DevFmtFloat; try { - const auto numchans = usize{mDevice->channelsFromFmt()}; - std::ranges::for_each(std::views::iota(0_uz, numchans), [this](usize const idx) + const auto numchans = std::size_t{mDevice->channelsFromFmt()}; + std::ranges::for_each(std::views::iota(0_uz, numchans), [this](std::size_t const idx) { auto const name = al::format("channel_{}", idx); auto &newport = mPort.emplace_back(); @@ -611,7 +613,7 @@ void JackPlayback::start() mDevice->mBufferSize = (bufsize+1) * mDevice->mUpdateSize; mRing = RingBuffer::Create(bufsize, - usize{mDevice->mUpdateSize} * mDevice->channelsFromFmt(), true); + std::size_t{mDevice->mUpdateSize} * mDevice->channelsFromFmt(), true); try { mPlaying.store(true, std::memory_order_release); diff --git a/3rdparty/openal/alc/backends/oboe.cpp b/3rdparty/openal/alc/backends/oboe.cpp index 7ba5282ad0b4..23342683a116 100644 --- a/3rdparty/openal/alc/backends/oboe.cpp +++ b/3rdparty/openal/alc/backends/oboe.cpp @@ -8,12 +8,17 @@ #include "alnumeric.h" #include "alstring.h" #include "core/device.h" -#include "core/logging.h" #include "gsl/gsl" #include "ringbuffer.h" #include "oboe/Oboe.h" +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { @@ -89,12 +94,12 @@ auto OboePlayback::reset() -> bool builder.setFormatConversionAllowed(false); builder.setCallback(this); - if(mDevice->Flags.test(FrequencyRequest)) + if(mDevice->mFlags.test(DeviceFlag::FrequencyRequest)) { builder.setSampleRateConversionQuality(oboe::SampleRateConversionQuality::High); builder.setSampleRate(gsl::narrow_cast(mDevice->mSampleRate)); } - if(mDevice->Flags.test(ChannelsRequest)) + if(mDevice->mFlags.test(DeviceFlag::ChannelsRequest)) { /* Only use mono or stereo at user request. There's no telling what * other counts may be inferred as. @@ -103,7 +108,7 @@ auto OboePlayback::reset() -> bool : (mDevice->FmtChans==DevFmtStereo) ? oboe::ChannelCount::Stereo : oboe::ChannelCount::Unspecified); } - if(mDevice->Flags.test(SampleTypeRequest)) + if(mDevice->mFlags.test(DeviceFlag::SampleTypeRequest)) { oboe::AudioFormat format{oboe::AudioFormat::Unspecified}; switch(mDevice->FmtType) @@ -225,7 +230,7 @@ struct OboeCapture final : BackendBase, oboe::AudioStreamCallback { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; }; auto OboeCapture::onAudioReady(oboe::AudioStream*, void *const audioData, int32_t const numFrames) @@ -327,7 +332,7 @@ void OboeCapture::stop() ERR("Failed to stop stream: {}", oboe::convertToText(result)); } -auto OboeCapture::availableSamples() -> usize +auto OboeCapture::availableSamples() -> std::size_t { return mRing->readSpace(); } void OboeCapture::captureSamples(std::span const outbuffer) diff --git a/3rdparty/openal/alc/backends/opensl.cpp b/3rdparty/openal/alc/backends/opensl.cpp index 546e2e2059d4..13c9b12f313b 100644 --- a/3rdparty/openal/alc/backends/opensl.cpp +++ b/3rdparty/openal/alc/backends/opensl.cpp @@ -37,12 +37,11 @@ #include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "alstring.h" #include "althrd_setname.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "dynload.h" #include "gsl/gsl" #include "opthelpers.h" @@ -52,6 +51,12 @@ #include #include +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { @@ -275,7 +280,7 @@ void OpenSLPlayback::mixerProc() PrintErr(result, "bufferQueue->GetInterface SL_IID_PLAY"); } - const auto frame_step = usize{mDevice->channelsFromFmt()}; + const auto frame_step = std::size_t{mDevice->channelsFromFmt()}; if(SL_RESULT_SUCCESS != result) mDevice->handleDisconnect("Failed to get playback buffer: {:#08x}", result); @@ -317,11 +322,11 @@ void OpenSLPlayback::mixerProc() gsl::narrow_cast(data[1].size()/mFrameSize), frame_step); const auto updatebytes = mRing->getElemSize(); - const auto todo = usize{data[0].size() + data[1].size()} / updatebytes; + const auto todo = std::size_t{data[0].size() + data[1].size()} / updatebytes; mRing->writeAdvance(todo); dlock.unlock(); - for(usize i{0};i < todo;++i) + for(auto i=0_uz;i < todo;++i) { if(data[0].empty()) { @@ -615,7 +620,7 @@ struct OpenSLCapture final : public BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; /* engine interfaces */ SLObjectItf mEngineObj{nullptr}; @@ -792,12 +797,12 @@ void OpenSLCapture::open(std::string_view name) auto data = mRing->getWriteVector(); std::ranges::fill(data[0], silence); std::ranges::fill(data[1], silence); - for(usize i{0u};i < data[0].size() && SL_RESULT_SUCCESS == result;i+=chunk_size) + for(auto i=0_uz;i < data[0].size() && SL_RESULT_SUCCESS == result;i+=chunk_size) { result = VCALL(bufferQueue,Enqueue)(data[0].data() + i, chunk_size); PrintErr(result, "bufferQueue->Enqueue"); } - for(usize i{0u};i < data[1].size() && SL_RESULT_SUCCESS == result;i+=chunk_size) + for(auto i=0_uz;i < data[1].size() && SL_RESULT_SUCCESS == result;i+=chunk_size) { result = VCALL(bufferQueue,Enqueue)(data[1].data() + i, chunk_size); PrintErr(result, "bufferQueue->Enqueue"); @@ -853,7 +858,7 @@ void OpenSLCapture::stop() void OpenSLCapture::captureSamples(std::span outbuffer) { - const auto update_size = usize{mDevice->mUpdateSize}; + const auto update_size = std::size_t{mDevice->mUpdateSize}; const auto chunk_size = update_size * mFrameSize; auto bufferQueue = SLAndroidSimpleBufferQueueItf{}; @@ -875,7 +880,7 @@ void OpenSLCapture::captureSamples(std::span outbuffer) auto rdata = mRing->getReadVector(); while(!outbuffer.empty()) { - auto const rem = std::min(outbuffer.size(), usize{chunk_size}-mByteOffset); + auto const rem = std::min(outbuffer.size(), std::size_t{chunk_size}-mByteOffset); auto const oiter = std::ranges::copy(rdata[0].subspan(mByteOffset, rem), outbuffer.begin()).out; outbuffer = {oiter, outbuffer.end()}; @@ -905,7 +910,7 @@ void OpenSLCapture::captureSamples(std::span outbuffer) } } -auto OpenSLCapture::availableSamples() -> usize +auto OpenSLCapture::availableSamples() -> std::size_t { return mRing->readSpace()*mDevice->mUpdateSize - mByteOffset/mFrameSize; } diff --git a/3rdparty/openal/alc/backends/oss.cpp b/3rdparty/openal/alc/backends/oss.cpp index fad6b7d4136a..2b483186f44a 100644 --- a/3rdparty/openal/alc/backends/oss.cpp +++ b/3rdparty/openal/alc/backends/oss.cpp @@ -49,7 +49,6 @@ #include "althrd_setname.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "gsl/gsl" #include "ringbuffer.h" @@ -78,6 +77,12 @@ #define ALC_OSS_DEVNODE_TRUC #endif +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { using namespace std::string_literals; @@ -286,8 +291,8 @@ void OSSPlayback::mixerProc() SetRTPriority(); althrd_setname(GetMixerThreadName()); - const auto frame_step = usize{mDevice->channelsFromFmt()}; - const auto frame_size = usize{mDevice->frameSizeFromFmt()}; + const auto frame_step = std::size_t{mDevice->channelsFromFmt()}; + const auto frame_size = std::size_t{mDevice->frameSizeFromFmt()}; while(!mKillNow.load(std::memory_order_acquire) && mDevice->Connected.load(std::memory_order_acquire)) @@ -327,7 +332,7 @@ void OSSPlayback::mixerProc() break; } - write_buf = write_buf.subspan(gsl::narrow_cast(wrote)); + write_buf = write_buf.subspan(gsl::narrow_cast(wrote)); } } } @@ -424,7 +429,7 @@ auto OSSPlayback::reset() -> bool setDefaultChannelOrder(); - mMixData.resize(usize{mDevice->mUpdateSize} * mDevice->frameSizeFromFmt()); + mMixData.resize(std::size_t{mDevice->mUpdateSize} * mDevice->frameSizeFromFmt()); return true; } @@ -462,7 +467,7 @@ struct OSSCapture final : BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; FileHandle mFd; @@ -480,7 +485,7 @@ void OSSCapture::recordProc() const SetRTPriority(); althrd_setname(GetRecordThreadName()); - auto const frame_size = usize{mDevice->frameSizeFromFmt()}; + auto const frame_size = std::size_t{mDevice->frameSizeFromFmt()}; while(!mKillNow.load(std::memory_order_acquire)) { auto pollitem = pollfd{}; @@ -512,7 +517,7 @@ void OSSCapture::recordProc() const mDevice->handleDisconnect("Failed reading capture samples: {}", errstr); break; } - mRing->writeAdvance(gsl::narrow_cast(amt) / frame_size); + mRing->writeAdvance(gsl::narrow_cast(amt) / frame_size); } } } @@ -621,7 +626,7 @@ void OSSCapture::stop() void OSSCapture::captureSamples(std::span outbuffer) { std::ignore = mRing->read(outbuffer); } -auto OSSCapture::availableSamples() -> usize +auto OSSCapture::availableSamples() -> std::size_t { return mRing->readSpace(); } } // namespace diff --git a/3rdparty/openal/alc/backends/pipewire.cpp b/3rdparty/openal/alc/backends/pipewire.cpp index a5df38784f86..2555d625dd32 100644 --- a/3rdparty/openal/alc/backends/pipewire.cpp +++ b/3rdparty/openal/alc/backends/pipewire.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -52,11 +51,9 @@ #include "core/devformat.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "dynload.h" #include "fmt/core.h" #include "fmt/ranges.h" -#include "gsl/gsl" #include "opthelpers.h" #include "pragmadefs.h" #include "ringbuffer.h" @@ -68,7 +65,6 @@ DIAGNOSTIC_PUSH std_pragma("GCC diagnostic ignored \"-Wpedantic\"") std_pragma("GCC diagnostic ignored \"-Wconversion\"") -std_pragma("GCC diagnostic ignored \"-Warith-conversion\"") std_pragma("GCC diagnostic ignored \"-Wfloat-conversion\"") std_pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") std_pragma("GCC diagnostic ignored \"-Wunused-parameter\"") @@ -119,9 +115,9 @@ constexpr auto get_pod_type(const spa_pod *pod) noexcept { return SPA_POD_TYPE(pod); } template -constexpr auto get_pod_body(spa_pod const *const pod, usize const count) noexcept +constexpr auto get_pod_body(spa_pod const *const pod, std::size_t const count) noexcept { return std::span{static_cast(SPA_POD_BODY(pod)), count}; } -template +template constexpr auto get_pod_body(spa_pod const *const pod) noexcept { return std::span{static_cast(SPA_POD_BODY(pod)), N}; } @@ -135,7 +131,17 @@ constexpr auto PwIdAny = PW_ID_ANY; } // namespace /* NOLINTEND */ -DIAGNOSTIC_POP +DIAGNOSTIC_POP; + +#if HAVE_CXXMODULES +import format.types; +import gsl; +import logging; +#else +#include "alformattypes.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif namespace { @@ -144,12 +150,30 @@ auto as_const_ptr(T *ptr) noexcept -> std::add_const_t* { return ptr; } struct SpaHook : spa_hook { SpaHook() : spa_hook{} { } - ~SpaHook() { spa_hook_remove(this); } + ~SpaHook() + { + /* Prior to 0.3.57, spa_hook_remove will crash if the spa_hook hasn't + * been linked with anything, which complicates removing on destruction + * since the spa_hook object needs to exist before it's linked, but if + * linking fails, there's no function to test if it can be removed. The + * PipeWire headers say spa_hook should be treated as opaque, meaning + * accessing any fields directly risks breaking compilation in the + * future. So we only peek into the spa_hool to do this check on older + * versions that need it. + */ +#if !PW_CHECK_VERSION(0,3,57) + if(this->link.prev != nullptr) +#endif + spa_hook_remove(this); + } void remove() { - spa_hook_remove(this); - static_cast(*this) = {}; +#if !PW_CHECK_VERSION(0,3,57) + if(this->link.prev != nullptr) +#endif + spa_hook_remove(this); + static_cast(*this) = spa_hook{}; } SpaHook(const SpaHook&) = delete; @@ -360,7 +384,7 @@ auto pwire_load() -> bool #if PW_CHECK_VERSION(0,3,50) #define pw_stream_get_time_n ppw_stream_get_time_n #else -inline auto pw_stream_get_time_n(pw_stream *stream, pw_time *ptime, usize /*size*/) +inline auto pw_stream_get_time_n(pw_stream *stream, pw_time *ptime, size_t /*size*/) { return ppw_stream_get_time(stream, ptime); } #endif #endif @@ -498,7 +522,7 @@ class ThreadMainloop { auto signal(bool const wait) const { return pw_thread_loop_signal(mLoop, wait); } - auto newContext(pw_properties *const props=nullptr, usize const user_data_size=0) const + auto newContext(pw_properties *const props=nullptr, std::size_t const user_data_size=0) const { return PwContextPtr{pw_context_new(getLoop(), props, user_data_size)}; } static auto Create(gsl::czstring const name, spa_dict *const props=nullptr) @@ -1020,11 +1044,11 @@ void NodeProxy::infoCallback(void*, const pw_node_info *info) noexcept { errno = 0; auto *serial_end = gsl::zstring{}; - serial_id = u64{std::strtoull(serial_str, &serial_end, 0)}; + serial_id = std::strtoull(serial_str, &serial_end, 0); if(*serial_end != '\0' || errno == ERANGE) { ERR("Unexpected object serial: {}", serial_str); - serial_id = u64{info->id}; + serial_id = info->id; } } #endif @@ -1036,13 +1060,9 @@ void NodeProxy::infoCallback(void*, const pw_node_info *info) noexcept return al::format("PipeWire node #{}", info->id); }); - auto *form_factor = spa_dict_lookup(info->props, PW_KEY_DEVICE_FORM_FACTOR); - TRACE("Got {} device \"{}\"{}{}{}", AsString(ntype), devName ? devName : "(nil)", - form_factor?" (":"", form_factor?form_factor:"", form_factor?")":""); - TRACE(" \"{}\" = ID {}", name, serial_id); - auto &node = EventManager::AddDevice(info->id); node.mSerial = serial_id; + /* This method is called both to notify about a new sink/source node, * and update properties for the node. It's unclear what properties can * change for an existing node without being removed first, so err on @@ -1056,6 +1076,27 @@ void NodeProxy::infoCallback(void*, const pw_node_info *info) noexcept * * This is overkill if the node type, name, and devname can't change. */ + if(node.mName != name) + { + /* First, check if this name already exists for another node in the + * device list and needs a count suffix. If this node is already + * using the name, keep it. + */ + auto const&& devlist = EventManager::GetDeviceList(); + auto count = 1u; + auto newname = name; + while(node.mName != newname + and std::ranges::find(devlist, newname, &DeviceNode::mName) != devlist.end()) + newname = al::format("{} #{}", name, ++count); + name = std::move(newname); + } + + auto *form_factor = spa_dict_lookup(info->props, PW_KEY_DEVICE_FORM_FACTOR); + TRACE("Got {} device \"{}\"{}{}{}", AsString(ntype), devName ? devName : "(nil)", + form_factor?" (":"", form_factor?form_factor:"", form_factor?")":""); + TRACE(" \"{}\" = ID {}", name, serial_id); + + /* Now check if the name is being changed. */ auto notifyAdd = false; if(node.mName != name) { @@ -1074,6 +1115,7 @@ void NodeProxy::infoCallback(void*, const pw_node_info *info) noexcept node.mType = ntype; node.mIsHeadphones = form_factor && (al::case_compare(form_factor, "headphones"sv) == 0 || al::case_compare(form_factor, "headset"sv) == 0); + if(notifyAdd) { const auto msg = al::format("Device added: {}", node.mName); @@ -1497,7 +1539,7 @@ void PipeWirePlayback::outputCallback() noexcept if(!pw_buf) [[unlikely]] return; auto const datas = std::span{pw_buf->buffer->datas, - std::min(mChannelPtrs.size(), usize{pw_buf->buffer->n_datas})}; + std::min(mChannelPtrs.size(), std::size_t{pw_buf->buffer->n_datas})}; #if PW_CHECK_VERSION(0,3,49) /* In 0.3.49, pw_buffer::requested specifies the number of samples needed * by the resampler/graph for this audio update. @@ -1626,7 +1668,7 @@ auto PipeWirePlayback::reset() -> bool * match its format. */ auto is51rear = false; - mDevice->Flags.reset(DirectEar); + mDevice->mFlags.reset(DeviceFlag::DirectEar); if(mTargetId != PwIdAny) { const auto evtlock = EventWatcherLockGuard{gEventHandler}; @@ -1635,7 +1677,7 @@ auto PipeWirePlayback::reset() -> bool const auto match = std::ranges::find(devlist, mTargetId, &DeviceNode::mSerial); if(match != devlist.end()) { - if(!mDevice->Flags.test(FrequencyRequest) && match->mSampleRate > 0) + if(!mDevice->mFlags.test(DeviceFlag::FrequencyRequest) && match->mSampleRate > 0) { /* Scale the update size if the sample rate changes. */ const auto scale = gsl::narrow_cast(match->mSampleRate) @@ -1661,10 +1703,11 @@ auto PipeWirePlayback::reset() -> bool } mDevice->mSampleRate = match->mSampleRate; } - if(!mDevice->Flags.test(ChannelsRequest) && match->mChannels != InvalidChannelConfig) + if(!mDevice->mFlags.test(DeviceFlag::ChannelsRequest) + && match->mChannels != InvalidChannelConfig) mDevice->FmtChans = match->mChannels; if(match->mChannels == DevFmtStereo && match->mIsHeadphones) - mDevice->Flags.set(DirectEar); + mDevice->mFlags.set(DeviceFlag::DirectEar); is51rear = match->mIs51Rear; } } @@ -1822,7 +1865,7 @@ void PipeWirePlayback::start() if(ptime.rate.denom > 0 && updatesize > 0) { /* Ensure the delay is in sample frames. */ - const auto delay = gsl::narrow_cast(ptime.delay) * mDevice->mSampleRate * + const auto delay = gsl::narrow_cast(ptime.delay) * mDevice->mSampleRate * ptime.rate.num / ptime.rate.denom; mDevice->mUpdateSize = updatesize; @@ -1947,7 +1990,7 @@ class PipeWireCapture final : public BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; u64 mTargetId{PwIdAny}; ThreadMainloop mLoop; @@ -2200,7 +2243,7 @@ void PipeWireCapture::stop() { return pw_stream_get_state(stream, nullptr) != PW_STREAM_STATE_STREAMING; }); } -auto PipeWireCapture::availableSamples() -> usize +auto PipeWireCapture::availableSamples() -> std::size_t { return mRing->readSpace(); } void PipeWireCapture::captureSamples(std::span const outbuffer) @@ -2316,9 +2359,6 @@ auto PipeWireBackendFactory::queryEventSupport(alc::EventType const eventType, B case alc::EventType::DeviceAdded: case alc::EventType::DeviceRemoved: return alc::EventSupport::FullSupport; - - case alc::EventType::Count: - break; } return alc::EventSupport::NoSupport; } diff --git a/3rdparty/openal/alc/backends/portaudio.cpp b/3rdparty/openal/alc/backends/portaudio.cpp index 71ea4d58358c..ace910107165 100644 --- a/3rdparty/openal/alc/backends/portaudio.cpp +++ b/3rdparty/openal/alc/backends/portaudio.cpp @@ -23,20 +23,23 @@ #include "portaudio.hpp" #include -#include -#include #include #include #include #include "alc/alconfig.h" #include "core/device.h" -#include "core/logging.h" #include "dynload.h" #include "ringbuffer.h" #include +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { @@ -306,7 +309,7 @@ struct PortCapture final : public BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; PaStream *mStream{nullptr}; PaStreamParameters mParams{}; @@ -410,7 +413,7 @@ void PortCapture::stop() } -auto PortCapture::availableSamples() -> usize +auto PortCapture::availableSamples() -> std::size_t { return mRing->readSpace(); } void PortCapture::captureSamples(std::span const outbuffer) diff --git a/3rdparty/openal/alc/backends/pulseaudio.cpp b/3rdparty/openal/alc/backends/pulseaudio.cpp index aea518c42524..ad7121187dd9 100644 --- a/3rdparty/openal/alc/backends/pulseaudio.cpp +++ b/3rdparty/openal/alc/backends/pulseaudio.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -37,24 +36,28 @@ #include #include #include -#include #include #include #include "alc/alconfig.h" -#include "alformat.hpp" #include "alnumeric.h" #include "base.h" #include "core/devformat.h" #include "core/device.h" -#include "core/logging.h" #include "dynload.h" -#include "gsl/gsl" #include "opthelpers.h" #include "strutils.hpp" #include +#if HAVE_CXXMODULES +import gsl; +import logging; +#else +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { @@ -699,7 +702,7 @@ struct PulsePlayback final : BackendBase { void bufferAttrCallback(pa_stream *stream) noexcept; void streamStateCallback(pa_stream *stream) const noexcept; - void streamWriteCallback(pa_stream *stream, usize nbytes) const noexcept; + void streamWriteCallback(pa_stream *stream, size_t nbytes) const noexcept; void sinkInfoCallback(pa_context *context, const pa_sink_info *info, int eol) noexcept; void sinkNameCallback(pa_context *context, const pa_sink_info *info, int eol) noexcept; void streamMovedCallback(pa_stream *stream) noexcept; @@ -748,7 +751,7 @@ void PulsePlayback::streamStateCallback(pa_stream *const stream) const noexcept mMainloop.signal(); } -void PulsePlayback::streamWriteCallback(pa_stream *const stream, usize nbytes) const noexcept +void PulsePlayback::streamWriteCallback(pa_stream *const stream, size_t nbytes) const noexcept { do { auto free_func = pa_free_cb_t{nullptr}; @@ -801,7 +804,7 @@ void PulsePlayback::sinkInfoCallback(pa_context*, pa_sink_info const *const info { return pa_channel_map_superset(&info->channel_map, &chanmap.map); }); if(chaniter != chanmaps.end()) { - if(!mDevice->Flags.test(ChannelsRequest)) + if(!mDevice->mFlags.test(DeviceFlag::ChannelsRequest)) mDevice->FmtChans = chaniter->fmt; mIs51Rear = chaniter->is_51rear; } @@ -815,7 +818,7 @@ void PulsePlayback::sinkInfoCallback(pa_context*, pa_sink_info const *const info if(info->active_port) TRACE("Active port: {} ({})", info->active_port->name, info->active_port->description); - mDevice->Flags.set(DirectEar, (info->active_port + mDevice->mFlags.set(DeviceFlag::DirectEar, (info->active_port && info->active_port->name == "analog-output-headphones"sv)); } @@ -937,7 +940,7 @@ auto PulsePlayback::reset() -> bool flags |= PA_STREAM_ADJUST_LATENCY; } if(GetConfigValueBool(mDevice->mDeviceName, "pulse", "fix-rate", false) - || !mDevice->Flags.test(FrequencyRequest)) + || !mDevice->mFlags.test(DeviceFlag::FrequencyRequest)) flags |= PA_STREAM_FIX_RATE; auto chanmap = pa_channel_map{}; @@ -1072,7 +1075,7 @@ void PulsePlayback::start() pa_stream_write(mStream, buf, todo, pa_xfree, 0, PA_SEEK_RELATIVE); } - static constexpr auto stream_write = [](pa_stream *const stream, usize const nbytes, + static constexpr auto stream_write = [](pa_stream *const stream, size_t const nbytes, void *const pdata) noexcept { return static_cast(pdata)->streamWriteCallback(stream, nbytes); }; pa_stream_set_write_callback(mStream, stream_write, this); @@ -1138,7 +1141,7 @@ struct PulseCapture final : public BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; auto getClockLatency() -> ClockLatency override; PulseMainloop mMainloop; @@ -1146,10 +1149,10 @@ struct PulseCapture final : public BackendBase { std::optional mDeviceId{std::nullopt}; std::span mCapBuffer; - usize mHoleLength{0}; - usize mPacketLength{0}; + std::size_t mHoleLength{0}; + std::size_t mPacketLength{0}; - usize mLastReadable{0}; + std::size_t mLastReadable{0}; std::byte mSilentVal{}; pa_buffer_attr mAttr{}; @@ -1360,7 +1363,7 @@ void PulseCapture::captureSamples(std::span outbuffer) } auto *capbuf = cvoidp{}; - auto caplen = usize{}; + auto caplen = size_t{}; if(pa_stream_peek(mStream, &capbuf, &caplen) < 0) [[unlikely]] { mDevice->handleDisconnect("Failed retrieving capture samples: {}", @@ -1380,7 +1383,7 @@ void PulseCapture::captureSamples(std::span outbuffer) std::ranges::fill(outbuffer, mSilentVal); } -auto PulseCapture::availableSamples() -> usize +auto PulseCapture::availableSamples() -> std::size_t { auto readable = std::max(mCapBuffer.size(), mHoleLength); @@ -1582,9 +1585,6 @@ auto PulseBackendFactory::queryEventSupport(alc::EventType const eventType, Back case alc::EventType::DeviceRemoved: case alc::EventType::DefaultDeviceChanged: return alc::EventSupport::FullSupport; - - case alc::EventType::Count: - break; } return alc::EventSupport::NoSupport; } diff --git a/3rdparty/openal/alc/backends/sdl3.cpp b/3rdparty/openal/alc/backends/sdl3.cpp index acd6f36a91e4..12647ca8136c 100644 --- a/3rdparty/openal/alc/backends/sdl3.cpp +++ b/3rdparty/openal/alc/backends/sdl3.cpp @@ -22,18 +22,22 @@ #include "sdl3.h" -#include +#include +#include #include +#include #include #include #include #include +#include "alformat.hpp" #include "alnumeric.h" +#include "altypes.hpp" #include "core/device.h" -#include "core/logging.h" #include "gsl/gsl" #include "pragmadefs.h" +#include "ringbuffer.h" DIAGNOSTIC_PUSH std_pragma("GCC diagnostic ignored \"-Wold-style-cast\"") @@ -43,8 +47,15 @@ std_pragma("GCC diagnostic ignored \"-Wold-style-cast\"") namespace { constexpr auto DefaultPlaybackDeviceID = SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK; +constexpr auto DefaultCaptureDeviceID = SDL_AUDIO_DEVICE_DEFAULT_RECORDING; } /* namespace */ -DIAGNOSTIC_POP +DIAGNOSTIC_POP; + +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif namespace { @@ -55,24 +66,44 @@ template using unique_sdl_ptr = std::unique_ptr ptr) { SDL_free(ptr); })>; +auto SDLCALL EventHandler(void* /*userptr*/, SDL_Event *const event) noexcept -> bool +{ + if(event->type == SDL_EVENT_AUDIO_DEVICE_ADDED) + { + auto &evt = event->adevice; + auto const devtype = evt.recording ? alc::DeviceType::Capture : alc::DeviceType::Playback; + + auto const msg = al::format("Device ID added: {}", evt.which); + alc::Event(alc::EventType::DeviceAdded, devtype, msg); + } + else if(event->type == SDL_EVENT_AUDIO_DEVICE_REMOVED) + { + auto &evt = event->adevice; + auto const devtype = evt.recording ? alc::DeviceType::Capture : alc::DeviceType::Playback; + + auto const msg = al::format("Device ID removed: {}", evt.which); + alc::Event(alc::EventType::DeviceRemoved, devtype, msg); + } + return true; +} + struct DeviceEntry { std::string mName; SDL_AudioDeviceID mPhysDeviceID{}; }; -auto gPlaybackDevices = std::vector{}; - -void EnumeratePlaybackDevices() +void EnumerateDevices(std::invocable auto&& get_devices, std::vector &list) + requires(std::same_as, SDL_AudioDeviceID*>) { - auto numdevs = int{}; - auto devicelist = unique_sdl_ptr{SDL_GetAudioPlaybackDevices(&numdevs)}; + auto numdevs = sys_int{}; + auto const devicelist = unique_sdl_ptr{get_devices(&numdevs.c_val)}; if(!devicelist || numdevs < 0) { ERR("Failed to get playback devices: {}", SDL_GetError()); return; } - auto devids = std::span{devicelist.get(), gsl::narrow(numdevs)}; + auto devids = std::span{devicelist.get(), numdevs.cast_to().c_val}; auto newlist = std::vector{}; newlist.reserve(devids.size()); @@ -80,21 +111,49 @@ void EnumeratePlaybackDevices() { auto *name = SDL_GetAudioDeviceName(id); if(!name) return DeviceEntry{}; + TRACE("Got device \"{}\", ID {}", name, id); - return DeviceEntry{name, id}; + return DeviceEntry{.mName = name, .mPhysDeviceID = id}; }); - gPlaybackDevices.swap(newlist); + /* De-duplicate device names (append #2, #3, etc, as needed). */ + if(newlist.size() > 1) + { + for(auto const idx : std::views::iota(1_uz, newlist.size())) + { + auto &entry = newlist[idx]; + auto const namelist = newlist | std::views::take(idx) + | std::views::transform(&DeviceEntry::mName); + auto name_exists = [namelist](std::string_view const name) -> bool + { return std::ranges::find(namelist, name) != namelist.end(); }; + + if(name_exists(entry.mName)) + { + auto count = 1u; + auto newname = std::string{}; + do { + newname = al::format("{} #{}", entry.mName, ++count); + } while(name_exists(newname)); + entry.mName = std::move(newname); + } + } + } + + list.swap(newlist); } +auto gPlaybackDevices = std::vector{}; +auto gCaptureDevices = std::vector{}; + + [[nodiscard]] constexpr auto getDefaultDeviceName() noexcept -> std::string_view { return "Default Device"sv; } -struct Sdl3Backend final : BackendBase { - explicit Sdl3Backend(gsl::not_null const device) noexcept : BackendBase{device} +struct Sdl3Playback final : BackendBase { + explicit Sdl3Playback(gsl::not_null const device) noexcept : BackendBase{device} { } - ~Sdl3Backend() final; + ~Sdl3Playback() final; void audioCallback(SDL_AudioStream *stream, int additional_amount, int total_amount) noexcept; @@ -110,14 +169,14 @@ struct Sdl3Backend final : BackendBase { std::vector mBuffer; }; -Sdl3Backend::~Sdl3Backend() +Sdl3Playback::~Sdl3Playback() { if(mStream) SDL_DestroyAudioStream(mStream); mStream = nullptr; } -void Sdl3Backend::audioCallback(SDL_AudioStream *stream, int additional_amount, int total_amount) +void Sdl3Playback::audioCallback(SDL_AudioStream *stream, int additional_amount, int total_amount) noexcept { if(additional_amount < 0) @@ -136,7 +195,7 @@ void Sdl3Backend::audioCallback(SDL_AudioStream *stream, int additional_amount, SDL_PutAudioStreamData(stream, mBuffer.data(), additional_amount); } -void Sdl3Backend::open(std::string_view name) +void Sdl3Playback::open(std::string_view name) { const auto defaultDeviceName = getDefaultDeviceName(); if(name.empty() || name == defaultDeviceName) @@ -147,11 +206,12 @@ void Sdl3Backend::open(std::string_view name) else { if(gPlaybackDevices.empty()) - EnumeratePlaybackDevices(); + EnumerateDevices(SDL_GetAudioPlaybackDevices, gPlaybackDevices); const auto iter = std::ranges::find(gPlaybackDevices, name, &DeviceEntry::mName); if(iter == gPlaybackDevices.end()) - throw al::backend_exception{al::backend_error::NoDevice, "No device named {}", name}; + throw al::backend_exception{al::backend_error::NoDevice, "No playback device named {}", + name}; mDeviceID = iter->mPhysDeviceID; } @@ -214,12 +274,12 @@ void Sdl3Backend::open(std::string_view name) mDeviceName = name; } -auto Sdl3Backend::reset() -> bool +auto Sdl3Playback::reset() -> bool { static constexpr auto callback = [](void *ptr, SDL_AudioStream *stream, int additional_amount, int total_amount) noexcept { - return static_cast(ptr)->audioCallback(stream, additional_amount, + return static_cast(ptr)->audioCallback(stream, additional_amount, total_amount); }; @@ -234,9 +294,9 @@ auto Sdl3Backend::reset() -> bool if(!SDL_GetAudioDeviceFormat(mDeviceID, &want, nullptr)) ERR("Failed to get device format: {}", SDL_GetError()); - if(mDevice->Flags.test(FrequencyRequest) || want.freq < int{MinOutputRate}) + if(mDevice->mFlags.test(DeviceFlag::FrequencyRequest) || want.freq < int{MinOutputRate}) want.freq = gsl::narrow_cast(mDevice->mSampleRate); - if(mDevice->Flags.test(SampleTypeRequest) + if(mDevice->mFlags.test(DeviceFlag::SampleTypeRequest) || !(want.format == SDL_AUDIO_U8 || want.format == SDL_AUDIO_S8 || want.format == SDL_AUDIO_S16 || want.format == SDL_AUDIO_S32 || want.format == SDL_AUDIO_F32)) @@ -252,7 +312,7 @@ auto Sdl3Backend::reset() -> bool case DevFmtFloat: want.format = SDL_AUDIO_F32; break; } } - if(mDevice->Flags.test(ChannelsRequest) || want.channels < 1) + if(mDevice->mFlags.test(DeviceFlag::ChannelsRequest) || want.channels < 1) want.channels = al::saturate_cast(mDevice->channelsFromFmt()); mStream = SDL_OpenAudioDeviceStream(mDeviceID, &want, callback, this); @@ -274,7 +334,7 @@ auto Sdl3Backend::reset() -> bool throw al::backend_exception{al::backend_error::DeviceError, "Failed to get stream format: {}", SDL_GetError()}; - if(!mDevice->Flags.test(ChannelsRequest) + if(!mDevice->mFlags.test(DeviceFlag::ChannelsRequest) || (std::cmp_not_equal(have.channels, mDevice->channelsFromFmt()) && !(mDevice->FmtChans == DevFmtStereo && have.channels >= 2))) { @@ -322,7 +382,7 @@ auto Sdl3Backend::reset() -> bool mDevice->mUpdateSize = gsl::narrow_cast(update_size); mDevice->mBufferSize = mDevice->mUpdateSize * 2u; - mBuffer.resize(usize{mDevice->mUpdateSize} * mFrameSize); + mBuffer.resize(std::size_t{mDevice->mUpdateSize} * mFrameSize); std::ranges::fill(mBuffer, mDevice->FmtType==DevFmtUByte ? std::byte{0x80} : std::byte{}); } else @@ -333,17 +393,138 @@ auto Sdl3Backend::reset() -> bool return true; } -void Sdl3Backend::start() +void Sdl3Playback::start() { SDL_ResumeAudioStreamDevice(mStream); } -void Sdl3Backend::stop() +void Sdl3Playback::stop() { SDL_PauseAudioStreamDevice(mStream); } + +struct Sdl3Capture final : BackendBase { + explicit Sdl3Capture(gsl::not_null const device) : BackendBase{device} { } + ~Sdl3Capture() final; + + void audioCallback(SDL_AudioStream *stream, int additional_amount, int total_amount) noexcept; + + void open(std::string_view name) override; + void start() override; + void stop() override; + void captureSamples(std::span outbuffer) override; + auto availableSamples() -> std::size_t override; + + SDL_AudioDeviceID mDeviceID{0}; + SDL_AudioStream *mStream{nullptr}; + std::vector mBuffer; + RingBufferPtr mRing; +}; + +Sdl3Capture::~Sdl3Capture() +{ + if(mStream) + SDL_DestroyAudioStream(mStream); + mStream = nullptr; +} + + +auto Sdl3Capture::audioCallback(SDL_AudioStream *stream, int /*additional_amount*/, + int /*total_amount*/) noexcept -> void +try { + auto const avail = sys_int{SDL_GetAudioStreamAvailable(stream)}; + if(auto const uavail = avail.cast_to(); uavail != mBuffer.size()) + mBuffer.resize(uavail.c_val); + + auto const got = sys_int{SDL_GetAudioStreamData(stream, mBuffer.data(), avail.c_val)}; + if(got != avail) + mBuffer.resize(got.cast_to().c_val); + + std::ignore = mRing->write(mBuffer); +} +catch(std::exception &e) { + ERR("Caught exception in capture callback: {}", e.what()); +} + + +auto Sdl3Capture::open(std::string_view name) -> void +{ + const auto defaultDeviceName = getDefaultDeviceName(); + if(name.empty() || name == defaultDeviceName) + { + name = defaultDeviceName; + mDeviceID = DefaultCaptureDeviceID; + } + else + { + if(gCaptureDevices.empty()) + EnumerateDevices(SDL_GetAudioRecordingDevices, gCaptureDevices); + + const auto iter = std::ranges::find(gCaptureDevices, name, &DeviceEntry::mName); + if(iter == gCaptureDevices.end()) + throw al::backend_exception{al::backend_error::NoDevice, "No capture device named {}", + name}; + + mDeviceID = iter->mPhysDeviceID; + } + + auto want = SDL_AudioSpec{}; + want.freq = gsl::narrow(mDevice->mSampleRate); + switch(mDevice->FmtType) + { + case DevFmtUByte: want.format = SDL_AUDIO_U8; break; + case DevFmtByte: want.format = SDL_AUDIO_S8; break; + case DevFmtShort: want.format = SDL_AUDIO_S16; break; + case DevFmtInt: want.format = SDL_AUDIO_S32; break; + case DevFmtFloat: want.format = SDL_AUDIO_F32; break; + case DevFmtUShort: + case DevFmtUInt: + throw al::backend_exception{al::backend_error::DeviceError, + "Format not supported for capture: {}", DevFmtTypeString(mDevice->FmtType)}; + } + want.channels = gsl::narrow(mDevice->channelsFromFmt()); + + static constexpr auto callback = [](void *ptr, SDL_AudioStream *stream, int additional_amount, + int total_amount) noexcept + { + return static_cast(ptr)->audioCallback(stream, additional_amount, + total_amount); + }; + mStream = SDL_OpenAudioDeviceStream(mDeviceID, &want, callback, this); + if(not mStream) + throw al::backend_exception{al::backend_error::DeviceError, + "Failed to create capture stream: {}", SDL_GetError()}; + + setDefaultWFXChannelOrder(); + + /* Ensure a minimum ringbuffer size of 100ms. */ + mRing = RingBuffer::Create(std::max(mDevice->mBufferSize, mDevice->mSampleRate/10u), + mDevice->frameSizeFromFmt(), false); + + mDeviceName = name; +} + +void Sdl3Capture::start() +{ + if(not SDL_ResumeAudioStreamDevice(mStream)) + throw al::backend_exception{al::backend_error::DeviceError, + "Failed to start capture device: {}", SDL_GetError()}; +} + +void Sdl3Capture::stop() +{ + if(not SDL_PauseAudioStreamDevice(mStream)) + ERR("Failed to stop capture device: {}", SDL_GetError()); +} + +auto Sdl3Capture::availableSamples() -> std::size_t +{ return mRing->readSpace(); } + +void Sdl3Capture::captureSamples(std::span const outbuffer) +{ std::ignore = mRing->read(outbuffer); } + } // namespace auto SDL3BackendFactory::getFactory() -> BackendFactory& { - static SDL3BackendFactory factory{}; + static auto factory = SDL3BackendFactory{}; return factory; } @@ -352,23 +533,55 @@ auto SDL3BackendFactory::init() -> bool if(!SDL_InitSubSystem(SDL_INIT_AUDIO)) return false; TRACE("Current SDL3 audio driver: \"{}\"", SDL_GetCurrentAudioDriver()); + + if(not SDL_AddEventWatch(&EventHandler, nullptr)) + ERR("Failed to register SDL event handler: {}", SDL_GetError()); + return true; } auto SDL3BackendFactory::querySupport(BackendType const type) -> bool -{ return type == BackendType::Playback; } +{ return type == BackendType::Playback or type == BackendType::Capture; } + +auto SDL3BackendFactory::queryEventSupport(alc::EventType const event, BackendType /*backend*/) + -> alc::EventSupport +{ + switch(event) + { + case alc::EventType::DeviceAdded: + case alc::EventType::DeviceRemoved: + return alc::EventSupport::FullSupport; + + /* SDL3 doesn't report when the default device changes. This isn't too big + * of a deal since we always report a separate "Default Device" as the + * default, and SDL will automatically move between devices when using it. + */ + case alc::EventType::DefaultDeviceChanged: + break; + } + return alc::EventSupport::NoSupport; +} auto SDL3BackendFactory::enumerate(BackendType const type) -> std::vector { auto outnames = std::vector{}; - if(type != BackendType::Playback) - return outnames; - - EnumeratePlaybackDevices(); - outnames.reserve(gPlaybackDevices.size()+1); - outnames.emplace_back(getDefaultDeviceName()); - std::ranges::transform(gPlaybackDevices, std::back_inserter(outnames), &DeviceEntry::mName); + if(type == BackendType::Playback) + { + EnumerateDevices(SDL_GetAudioPlaybackDevices, gPlaybackDevices); + outnames.reserve(gPlaybackDevices.size()+1); + outnames.emplace_back(getDefaultDeviceName()); + std::ranges::transform(gPlaybackDevices, std::back_inserter(outnames), + &DeviceEntry::mName); + } + else if(type == BackendType::Capture) + { + EnumerateDevices(SDL_GetAudioRecordingDevices, gCaptureDevices); + outnames.reserve(gCaptureDevices.size()+1); + outnames.emplace_back(getDefaultDeviceName()); + std::ranges::transform(gCaptureDevices, std::back_inserter(outnames), + &DeviceEntry::mName); + } return outnames; } @@ -377,6 +590,8 @@ auto SDL3BackendFactory::createBackend(gsl::not_null const device, BackendType const type) -> BackendPtr { if(type == BackendType::Playback) - return BackendPtr{new Sdl3Backend{device}}; + return BackendPtr{new Sdl3Playback{device}}; + if(type == BackendType::Capture) + return BackendPtr{new Sdl3Capture{device}}; return nullptr; } diff --git a/3rdparty/openal/alc/backends/sdl3.h b/3rdparty/openal/alc/backends/sdl3.h index 5b79b4daaf5d..fe0ec1a02543 100644 --- a/3rdparty/openal/alc/backends/sdl3.h +++ b/3rdparty/openal/alc/backends/sdl3.h @@ -8,6 +8,8 @@ struct SDL3BackendFactory final : BackendFactory { auto querySupport(BackendType type) -> bool final; + auto queryEventSupport(alc::EventType event, BackendType backend) -> alc::EventSupport final; + auto enumerate(BackendType type) -> std::vector final; auto createBackend(gsl::not_null device, BackendType type) -> BackendPtr final; diff --git a/3rdparty/openal/alc/backends/sndio.cpp b/3rdparty/openal/alc/backends/sndio.cpp index 760731c8f847..f2f8525ca5c9 100644 --- a/3rdparty/openal/alc/backends/sndio.cpp +++ b/3rdparty/openal/alc/backends/sndio.cpp @@ -34,12 +34,17 @@ #include "althrd_setname.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "gsl/gsl" #include "ringbuffer.h" #include +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { @@ -83,7 +88,7 @@ SndioPlayback::~SndioPlayback() void SndioPlayback::mixerProc() { - auto const frameStep = usize{mFrameStep}; + auto const frameStep = std::size_t{mFrameStep}; auto const frameSize = frameStep * mDevice->bytesFromFmt(); SetRTPriority(); @@ -231,7 +236,7 @@ auto SndioPlayback::reset() -> bool mDevice->mUpdateSize = par.round; mDevice->mBufferSize = par.bufsz + par.round; - mBuffer.resize(usize{mDevice->mUpdateSize} * par.pchan*par.bps); + mBuffer.resize(std::size_t{mDevice->mUpdateSize} * par.pchan*par.bps); return true; } @@ -279,7 +284,7 @@ struct SndioCapture final : BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; sio_hdl *mSndHandle{nullptr}; @@ -448,7 +453,8 @@ void SndioCapture::open(std::string_view name) DevFmtTypeString(mDevice->FmtType), DevFmtChannelsString(mDevice->FmtChans), mDevice->mSampleRate, par.sig?'s':'u', par.bps*8, par.rchan, par.rate}; - mRing = RingBuffer::Create(mDevice->mBufferSize, usize{par.bps}*par.rchan, false); + mRing = RingBuffer::Create(mDevice->mBufferSize, std::size_t{par.bps}*par.rchan, + false); mDevice->mBufferSize = gsl::narrow_cast(mRing->writeSpace()); mDevice->mUpdateSize = par.round; @@ -486,7 +492,7 @@ void SndioCapture::stop() void SndioCapture::captureSamples(std::span const outbuffer) { std::ignore = mRing->read(outbuffer); } -auto SndioCapture::availableSamples() -> usize +auto SndioCapture::availableSamples() -> std::size_t { return mRing->readSpace(); } } // namespace diff --git a/3rdparty/openal/alc/backends/solaris.cpp b/3rdparty/openal/alc/backends/solaris.cpp index c56f98ec63a1..da90a6c3cb73 100644 --- a/3rdparty/openal/alc/backends/solaris.cpp +++ b/3rdparty/openal/alc/backends/solaris.cpp @@ -46,11 +46,16 @@ #include "althrd_setname.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "gsl/gsl" #include +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { @@ -94,8 +99,8 @@ int SolarisBackend::mixerProc() SetRTPriority(); althrd_setname(GetMixerThreadName()); - auto const frame_step = usize{mDevice->channelsFromFmt()}; - auto const frame_size = usize{mDevice->frameSizeFromFmt()}; + auto const frame_step = std::size_t{mDevice->channelsFromFmt()}; + auto const frame_size = std::size_t{mDevice->frameSizeFromFmt()}; while(!mKillNow.load(std::memory_order_acquire) && mDevice->Connected.load(std::memory_order_acquire)) @@ -133,7 +138,7 @@ int SolarisBackend::mixerProc() break; } - buffer = buffer.subspan(gsl::narrow(wrote)); + buffer = buffer.subspan(gsl::narrow(wrote)); } } @@ -231,7 +236,7 @@ bool SolarisBackend::reset() setDefaultChannelOrder(); - mBuffer.resize(mDevice->mUpdateSize * usize{frame_size}); + mBuffer.resize(mDevice->mUpdateSize * std::size_t{frame_size}); std::ranges::fill(mBuffer, std::byte{}); return true; diff --git a/3rdparty/openal/alc/backends/wasapi.cpp b/3rdparty/openal/alc/backends/wasapi.cpp index e8323da9174b..4a15be47f7fe 100644 --- a/3rdparty/openal/alc/backends/wasapi.cpp +++ b/3rdparty/openal/alc/backends/wasapi.cpp @@ -63,14 +63,12 @@ #include #include "alc/alconfig.h" -#include "alformat.hpp" #include "alnumeric.h" #include "alstring.h" #include "althrd_setname.h" #include "comptr.h" #include "core/converter.h" #include "core/device.h" -#include "core/logging.h" #include "gsl/gsl" #include "opthelpers.h" #include "ringbuffer.h" @@ -103,6 +101,12 @@ DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_FormFactor, 0x1da5d803, 0xd492, 0x4edd, 0x DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_GUID, 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23,0xe0, 0xc0,0xff,0xee,0x7f,0x0e, 4 ); #endif +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { #if ALSOFT_UWP @@ -247,7 +251,7 @@ class PropVariant { void setBlob(const std::span data) { - if constexpr(sizeof(usize) > sizeof(ULONG)) + if constexpr(sizeof(std::size_t) > sizeof(ULONG)) Expects(data.size() <= std::numeric_limits::max()); clear(); mProp.vt = VT_BLOB; @@ -365,7 +369,7 @@ auto GetDeviceNameAndGuid(const DeviceHandle &device) -> NameGUIDPair if(auto devIdStartEnd = wcschr(devIdStart, L'#')) { ret.mGuid = wstr_to_utf8(std::wstring_view{devIdStart, - gsl::narrow_cast(devIdStartEnd - devIdStart)}); + gsl::narrow_cast(devIdStartEnd - devIdStart)}); std::transform(ret.mGuid.begin(), ret.mGuid.end(), ret.mGuid.begin(), [](char ch) { return gsl::narrow_cast(std::toupper(ch)); }); } @@ -1094,11 +1098,11 @@ void TraceFormat(const std::string_view msg, const WAVEFORMATEX *format) } -template +template constexpr auto span_to_array(const std::span span, std::index_sequence) { return std::array{{span[I]...}}; } -template requires(N != std::dynamic_extent) +template requires(N != std::dynamic_extent) constexpr auto span_to_array(const std::span span) -> std::array { return span_to_array(span, std::make_index_sequence{}); } @@ -1106,7 +1110,7 @@ constexpr auto span_to_array(const std::span span) -> std::array * halving the volume. Essentially converting mono to stereo. */ template -void DuplicateSamples(std::span insamples, usize step) +void DuplicateSamples(std::span insamples, std::size_t step) { if constexpr(std::is_floating_point_v || std::is_signed_v) { @@ -1140,7 +1144,7 @@ void DuplicateSamples(std::span insamples, usize step) } void DuplicateSamples(std::span const insamples, DevFmtType const sampletype, - usize const step) + std::size_t const step) { switch(sampletype) { @@ -1305,7 +1309,7 @@ FORCE_ALIGN void WasapiPlayback::mixerProc(PlainDevice const &audio) if(mResampler) { auto dlock = std::lock_guard{mMutex}; - auto dst = std::span{buffer, usize{len}*frame_size}; + auto dst = std::span{buffer, std::size_t{len}*frame_size}; for(UINT32 done{0};done < len;) { if(mBufferFilled == 0) @@ -1318,7 +1322,7 @@ FORCE_ALIGN void WasapiPlayback::mixerProc(PlainDevice const &audio) const auto got = mResampler->convert(&resbufferptr, &mBufferFilled, dst.data(), len-done); - dst = dst.subspan(usize{got}*frame_size); + dst = dst.subspan(std::size_t{got}*frame_size); done += got; } mPadding.store(written + len, std::memory_order_relaxed); @@ -1332,8 +1336,8 @@ FORCE_ALIGN void WasapiPlayback::mixerProc(PlainDevice const &audio) if(mMonoUpsample) { - DuplicateSamples(std::span{buffer, usize{len}*frame_size}, mDevice->FmtType, - mFormat.Format.nChannels); + DuplicateSamples(std::span{buffer, std::size_t{len}*frame_size}, + mDevice->FmtType, mFormat.Format.nChannels); } hr = audio.mRender->ReleaseBuffer(len, 0); @@ -1418,7 +1422,7 @@ FORCE_ALIGN void WasapiPlayback::mixerProc(SpatialDevice const &audio) tmpbuffers.resize(buffers.size()); resbuffers.resize(buffers.size()); auto bufptr = mResampleBuffer.begin(); - for(usize i{0};i < tmpbuffers.size();++i) + for(auto i=0_uz;i < tmpbuffers.size();++i) { resbuffers[i] = std::to_address(bufptr); std::advance(bufptr, mDevice->mUpdateSize*sizeof(float)); @@ -1675,7 +1679,7 @@ void WasapiPlayback::finalizeFormat(WAVEFORMATEXTENSIBLE &OutputType) * supported. */ auto chansok = false; - if(mDevice->Flags.test(ChannelsRequest)) + if(mDevice->mFlags.test(DeviceFlag::ChannelsRequest)) { /* When requesting a channel configuration, make sure it fits the * mask's lsb (to ensure no gaps in the output channels). If there's no @@ -1866,10 +1870,10 @@ auto WasapiPlayback::initSpatial(DeviceHelper &helper, DeviceHandle &mmdev, Spat OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; /* Match the output rate if not requesting anything specific. */ - if(!mDevice->Flags.test(FrequencyRequest)) + if(!mDevice->mFlags.test(DeviceFlag::FrequencyRequest)) mDevice->mSampleRate = OutputType.Format.nSamplesPerSec; - auto getTypeMask = [](DevFmtChannels chans) noexcept + auto getTypeMask = [](DevFmtChannels const chans) noexcept { switch(chans) { @@ -1909,7 +1913,7 @@ auto WasapiPlayback::initSpatial(DeviceHelper &helper, DeviceHandle &mmdev, Spat mFormat = OutputType; mDevice->FmtType = DevFmtFloat; - mDevice->Flags.reset(DirectEar).set(Virtualization); + mDevice->mFlags.reset(DeviceFlag::DirectEar).set(DeviceFlag::Virtualization); if(streamParams.StaticObjectTypeMask == ChannelMask_Stereo) mDevice->FmtChans = DevFmtStereo; if(!GetConfigValueBool(mDevice->mDeviceName, "wasapi", "allow-resampler", true)) @@ -1945,7 +1949,7 @@ auto WasapiPlayback::initSpatial(DeviceHelper &helper, DeviceHandle &mmdev, Spat const auto channelCount = as_unsigned(std::popcount(flags)); mResampler = SampleConverter::Create(mDevice->FmtType, mDevice->FmtType, channelCount, mDevice->mSampleRate, mFormat.Format.nSamplesPerSec, Resampler::FastBSinc24); - mResampleBuffer.resize(usize{mDevice->mUpdateSize} * channelCount * + mResampleBuffer.resize(std::size_t{mDevice->mUpdateSize} * channelCount * mFormat.Format.wBitsPerSample / 8); TRACE("Created converter for {}/{} format, dst: {}hz ({}), src: {}hz ({})", @@ -1983,7 +1987,7 @@ auto WasapiPlayback::resetProxy(DeviceHelper &helper, DeviceHandle &mmdev, return S_OK; } - mDevice->Flags.reset(Virtualization); + mDevice->mFlags.reset(DeviceFlag::Virtualization); mMonoUpsample = false; mExclusiveMode = false; @@ -2018,9 +2022,9 @@ auto WasapiPlayback::resetProxy(DeviceHelper &helper, DeviceHandle &mmdev, /* Update the mDevice format for non-requested properties. */ auto isRear51 = false; - if(!mDevice->Flags.test(FrequencyRequest)) + if(!mDevice->mFlags.test(DeviceFlag::FrequencyRequest)) mDevice->mSampleRate = OutputType.Format.nSamplesPerSec; - if(!mDevice->Flags.test(ChannelsRequest)) + if(!mDevice->mFlags.test(DeviceFlag::ChannelsRequest)) { /* If not requesting a channel configuration, auto-select given what * fits the mask's lsb (to ensure no gaps in the output channels). If @@ -2190,9 +2194,9 @@ auto WasapiPlayback::resetProxy(DeviceHelper &helper, DeviceHandle &mmdev, #if !ALSOFT_UWP const auto formfactor = GetDeviceFormfactor(mmdev.get()); - mDevice->Flags.set(DirectEar, (formfactor == Headphones || formfactor == Headset)); + mDevice->mFlags.set(DeviceFlag::DirectEar, (formfactor==Headphones || formfactor==Headset)); #else - mDevice->Flags.set(DirectEar, false); + mDevice->mFlags.set(DeviceFlag::DirectEar, false); #endif setDefaultWFXChannelOrder(); @@ -2302,7 +2306,7 @@ auto WasapiPlayback::resetProxy(DeviceHelper &helper, DeviceHandle &mmdev, mResampler = SampleConverter::Create(mDevice->FmtType, mDevice->FmtType, mFormat.Format.nChannels, mDevice->mSampleRate, mFormat.Format.nSamplesPerSec, Resampler::FastBSinc24); - mResampleBuffer.resize(usize{mDevice->mUpdateSize} * mFormat.Format.nChannels * + mResampleBuffer.resize(std::size_t{mDevice->mUpdateSize} * mFormat.Format.nChannels * mFormat.Format.wBitsPerSample / 8); TRACE("Created converter for {}/{} format, dst: {}hz ({}), src: {}hz ({})", @@ -2378,7 +2382,7 @@ struct WasapiCapture final : BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; std::thread mProcThread; @@ -2468,10 +2472,10 @@ void WasapiCapture::recordProc(IAudioClient *client, IAudioCaptureClient *captur auto data = mRing->getWriteVector(); - auto dstframes = usize{}; + auto dstframes = std::size_t{}; if(mSampleConv) { - static constexpr auto lenlimit = usize{std::numeric_limits::max()}; + static constexpr auto lenlimit = i32::max().as().c_val; auto *srcdata = LPCVOID{rdata}; auto srcframes = unsigned{numsamples}; @@ -2492,10 +2496,10 @@ void WasapiCapture::recordProc(IAudioClient *client, IAudioCaptureClient *captur else { const auto framesize = mDevice->frameSizeFromFmt(); - auto dst = std::span{rdata, usize{numsamples}*framesize}; + auto dst = std::span{rdata, std::size_t{numsamples}*framesize}; auto len1 = data[0].size() / mRing->getElemSize(); auto len2 = data[1].size() / mRing->getElemSize(); - len1 = std::min(len1, usize{numsamples}); + len1 = std::min(len1, std::size_t{numsamples}); len2 = std::min(len2, numsamples-len1); memcpy(data[0].data(), dst.data(), std::min(data[0].size(), dst.size())); @@ -3013,7 +3017,7 @@ void WasapiCapture::stop() void WasapiCapture::captureSamples(std::span const outbuffer) { std::ignore = mRing->read(outbuffer); } -auto WasapiCapture::availableSamples() -> usize +auto WasapiCapture::availableSamples() -> std::size_t { return mRing->readSpace(); } } // namespace @@ -3114,10 +3118,9 @@ auto WasapiBackendFactory::queryEventSupport(alc::EventType const eventType, Bac case alc::EventType::DeviceRemoved: #if !ALSOFT_UWP return alc::EventSupport::FullSupport; -#endif - - case alc::EventType::Count: +#else break; +#endif } return alc::EventSupport::NoSupport; } diff --git a/3rdparty/openal/alc/backends/wave.cpp b/3rdparty/openal/alc/backends/wave.cpp index 46d0bdf41a0d..f195d0e7aa1c 100644 --- a/3rdparty/openal/alc/backends/wave.cpp +++ b/3rdparty/openal/alc/backends/wave.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -36,14 +37,17 @@ #include #include "alc/alconfig.h" -#include "alnumeric.h" #include "alstring.h" #include "althrd_setname.h" #include "core/device.h" -#include "core/logging.h" #include "filesystem.h" #include "gsl/gsl" -#include "strutils.hpp" + +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif namespace { @@ -151,8 +155,8 @@ void WaveBackend::mixerProc() althrd_setname(GetMixerThreadName()); - auto const frameStep = usize{mDevice->channelsFromFmt()}; - auto const frameSize = usize{mDevice->frameSizeFromFmt()}; + auto const frameStep = std::size_t{mDevice->channelsFromFmt()}; + auto const frameSize = std::size_t{mDevice->frameSizeFromFmt()}; auto done = 0_i64; auto start = std::chrono::steady_clock::now(); @@ -334,19 +338,19 @@ auto WaveBackend::reset() -> bool // 16-bit val, format type id (extensible: 0xFFFE) fwrite16le(0xFFFE_u16, mFile); // 16-bit val, channel count - fwrite16le(u16::make_from(channels), mFile); + fwrite16le(u16::from(channels), mFile); // 32-bit val, frequency fwrite32le(u32{mDevice->mSampleRate}, mFile); // 32-bit val, bytes per second fwrite32le(u32{mDevice->mSampleRate * channels * bytes}, mFile); // 16-bit val, frame size - fwrite16le(u16::make_from(channels * bytes), mFile); + fwrite16le(u16::from(channels * bytes), mFile); // 16-bit val, bits per sample - fwrite16le(u16::make_from(bytes * 8), mFile); + fwrite16le(u16::from(bytes * 8), mFile); // 16-bit val, extra byte count fwrite16le(22_u16, mFile); // 16-bit val, valid bits per sample - fwrite16le(u16::make_from(bytes * 8), mFile); + fwrite16le(u16::from(bytes * 8), mFile); // 32-bit val, channel mask fwrite32le(u32{chanmask}, mFile); // 16 byte GUID, sub-type format @@ -442,7 +446,7 @@ auto WaveBackend::reset() -> bool setDefaultWFXChannelOrder(); - mBuffer.resize(usize{mDevice->frameSizeFromFmt()} * mDevice->mUpdateSize); + mBuffer.resize(std::size_t{mDevice->frameSizeFromFmt()} * mDevice->mUpdateSize); return true; } @@ -474,9 +478,9 @@ void WaveBackend::stop() if(!mCAFOutput) { if(mFile.seekp(4)) // 'WAVE' header len - fwrite32le(u32::make_from(size-8), mFile); + fwrite32le(u32::from(size-8), mFile); if(mFile.seekp(mDataStart-4)) // 'data' header len - fwrite32le(u32::make_from(dataLen), mFile); + fwrite32le(u32::from(dataLen), mFile); } else { diff --git a/3rdparty/openal/alc/backends/winmm.cpp b/3rdparty/openal/alc/backends/winmm.cpp index c8d6d31cef1e..41088ffa5c3b 100644 --- a/3rdparty/openal/alc/backends/winmm.cpp +++ b/3rdparty/openal/alc/backends/winmm.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -33,17 +32,16 @@ #include #include #include +#include #include #include #include #include -#include "alformat.hpp" #include "alnumeric.h" #include "althrd_setname.h" #include "core/device.h" #include "core/helpers.h" -#include "core/logging.h" #include "gsl/gsl" #include "ringbuffer.h" #include "strutils.hpp" @@ -53,6 +51,12 @@ #define WAVE_FORMAT_IEEE_FLOAT 0x0003 #endif +#if HAVE_CXXMODULES +import logging; +#else +#include "core/logging.h" +#endif + namespace { std::vector PlaybackDevices; @@ -177,7 +181,7 @@ FORCE_ALIGN void WinMMPlayback::mixerProc() mWritable.wait(0, std::memory_order_acquire); auto todo = mWritable.load(std::memory_order_acquire); - auto widx = usize{mIdx}; + auto widx = std::size_t{mIdx}; while(todo > 0) { auto &waveHdr = mWaveBuffer[widx]; @@ -367,7 +371,7 @@ struct WinMMCapture final : public BackendBase { void start() override; void stop() override; void captureSamples(std::span outbuffer) override; - auto availableSamples() -> usize override; + auto availableSamples() -> std::size_t override; std::atomic mReadable{0u}; unsigned mIdx{0u}; @@ -414,7 +418,7 @@ void WinMMCapture::captureProc() mReadable.wait(0, std::memory_order_acquire); auto todo = mReadable.load(std::memory_order_acquire); - auto widx = usize{mIdx}; + auto widx = std::size_t{mIdx}; while(todo > 0) { auto &waveHdr = mWaveBuffer[widx]; @@ -502,7 +506,7 @@ void WinMMCapture::open(std::string_view name) // Allocate circular memory buffer for the captured audio // Make sure circular buffer is at least 100ms in size - auto const CapturedDataSize = std::max(mDevice->mBufferSize, + auto const CapturedDataSize = std::max(mDevice->mBufferSize, BufferSize*mWaveBuffer.size()); mRing = RingBuffer::Create(CapturedDataSize, mFormat.nBlockAlign, false); @@ -563,7 +567,7 @@ void WinMMCapture::stop() void WinMMCapture::captureSamples(std::span outbuffer) { std::ignore = mRing->read(outbuffer); } -auto WinMMCapture::availableSamples() -> usize +auto WinMMCapture::availableSamples() -> std::size_t { return mRing->readSpace(); } } // namespace diff --git a/3rdparty/openal/alc/context.cpp b/3rdparty/openal/alc/context.cpp index 43ab11560b26..b7b7b7347f51 100644 --- a/3rdparty/openal/alc/context.cpp +++ b/3rdparty/openal/alc/context.cpp @@ -1,12 +1,8 @@ #include "config.h" -#include "context.h" - #include #include -#include -#include #include #include #include @@ -24,26 +20,40 @@ #include "alc/alu.h" #include "alc/backends/base.h" #include "alnumeric.h" +#include "altypes.hpp" #include "atomic.h" #include "core/async_event.h" #include "core/devformat.h" #include "core/device.h" #include "core/effectslot.h" -#include "core/logging.h" #include "core/voice_change.h" #include "device.h" #include "flexarray.h" #include "fmt/format.h" #include "fmt/ranges.h" -#include "gsl/gsl" #include "ringbuffer.h" #include "vecmat.h" #if ALSOFT_EAX +#include + +#include "al/eax/api.h" #include "al/eax/call.h" #include "al/eax/globals.h" #endif // ALSOFT_EAX +#if HAVE_CXXMODULES +import alc.context; +import format.types; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "alformattypes.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif + namespace { using namespace std::string_view_literals; @@ -99,6 +109,35 @@ auto getContextExtensions() noexcept -> std::vector }); } +/* Thread-local context handling. This handles attempting to release the + * context which may have been left current when the thread is destroyed. + */ +class ThreadCtx { +public: + ThreadCtx() = default; + ThreadCtx(const ThreadCtx&) = delete; + auto operator=(const ThreadCtx&) -> ThreadCtx& = delete; + + ~ThreadCtx() + { + if(auto *ctx = std::exchange(al::Context::sLocalContext, nullptr)) + { + const auto result = ctx->releaseIfNoDelete(); + ERR("Context {} current for thread being destroyed{}!", voidp{ctx}, + result ? "" : ", leak detected"); + } + } + /* NOLINTBEGIN(readability-convert-member-functions-to-static) + * This should be non-static to invoke construction of the thread-local + * sThreadContext, so that it's destructor gets run at thread exit to + * clear sLocalContext (which isn't a member variable to make read + * access efficient). + */ + void set(al::Context *ctx) const noexcept { al::Context::sLocalContext = ctx; } + /* NOLINTEND(readability-convert-member-functions-to-static) */ +}; +thread_local ThreadCtx sThreadContext; + } // namespace @@ -107,17 +146,6 @@ namespace al { std::atomic Context::sGlobalContextLock{false}; std::atomic Context::sGlobalContext{nullptr}; -Context::ThreadCtx::~ThreadCtx() -{ - if(auto *ctx = std::exchange(sLocalContext, nullptr)) - { - const auto result = ctx->releaseIfNoDelete(); - ERR("Context {} current for thread being destroyed{}!", voidp{ctx}, - result ? "" : ", leak detected"); - } -} -thread_local Context::ThreadCtx Context::sThreadContext; - Effect Context::sDefaultEffect; @@ -148,9 +176,9 @@ Context::~Context() TRACE("Freeing context {}", voidp{this}); deinit(); - auto count = std::accumulate(mSourceList.cbegin(), mSourceList.cend(), 0_uz, - [](usize const cur, SourceSubList const &sublist) noexcept -> size_t - { return cur + (~sublist.mFreeMask).popcount().c_val; }); + auto count = std::accumulate(mSourceList.cbegin(), mSourceList.cend(), 0_usize, + [](usize const cur, SourceSubList const &sublist) noexcept -> usize + { return cur + (~sublist.mFreeMask).popcount(); }); if(count > 0) WARN("{} Source{} not deleted", count, (count==1)?"":"s"); mSourceList.clear(); @@ -161,9 +189,9 @@ Context::~Context() #endif // ALSOFT_EAX mDefaultSlot = nullptr; - count = std::accumulate(mEffectSlotList.cbegin(), mEffectSlotList.cend(), 0_uz, - [](size_t cur, const EffectSlotSubList &sublist) noexcept -> size_t - { return cur + (~sublist.mFreeMask).popcount().c_val; }); + count = std::accumulate(mEffectSlotList.cbegin(), mEffectSlotList.cend(), 0_usize, + [](usize const cur, const EffectSlotSubList &sublist) noexcept -> usize + { return cur + (~sublist.mFreeMask).popcount(); }); if(count > 0) WARN("{} AuxiliaryEffectSlot{} not deleted", count, (count==1)?"":"s"); mEffectSlotList.clear(); @@ -298,11 +326,23 @@ void Context::applyAllUpdates() mHoldUpdates.store(false, std::memory_order_release); } +void Context::setThreadContext(Context *context) noexcept +{ sThreadContext.set(context); } + } // namespace al #if ALSOFT_EAX namespace { +[[nodiscard]] inline +auto CompareGUID(AL_GUID const &lhs, AL_GUID const &rhs) noexcept -> std::strong_ordering +{ + auto const res = std::memcmp(&lhs, &rhs, sizeof(AL_GUID)); + if(res > 0) return std::strong_ordering::greater; + if(res < 0) return std::strong_ordering::less; + return std::strong_ordering::equal; +} + void ForEachSource(al::Context *context, std::invocable auto&& func) { std::ranges::for_each(context->mSourceList, [&func](SourceSubList &sublist) @@ -337,7 +377,7 @@ void Context::eaxUninitialize() noexcept mEaxFxSlots.uninitialize(); } -auto Context::eax_eax_set(const GUID *property_set_id, ALuint property_id, +auto Context::eax_eax_set(AL_GUID const *property_set_id, ALuint property_id, ALuint property_source_id, ALvoid *property_value, ALuint property_value_size) -> ALenum { const auto call = create_eax_call(EaxCallType::set, property_set_id, property_id, @@ -372,7 +412,7 @@ auto Context::eax_eax_set(const GUID *property_set_id, ALuint property_id, return AL_NO_ERROR; } -auto Context::eax_eax_get(const GUID* property_set_id, ALuint property_id, +auto Context::eax_eax_get(AL_GUID const *property_set_id, ALuint property_id, ALuint property_source_id, ALvoid *property_value, ALuint property_value_size) -> ALenum { const auto call = create_eax_call(EaxCallType::get, property_set_id, property_id, @@ -496,7 +536,7 @@ auto Context::eax_detect_speaker_configuration() const -> eax_ulong */ if(std::holds_alternative(mDevice->mPostProcess)) return SPEAKERS_7; - if(mDevice->Flags.test(DirectEar)) + if(mDevice->mFlags.test(DeviceFlag::DirectEar)) return HEADPHONES; return SPEAKERS_2; case DevFmtQuad: return SPEAKERS_4; @@ -731,7 +771,7 @@ void Context::eax4_defer_all(const EaxCall& call, Eax4State& state) auto &dst_d = state.d; dst_d = src; - if(dst_i.guidPrimaryFXSlotID != dst_d.guidPrimaryFXSlotID) + if(std::is_neq(CompareGUID(dst_i.guidPrimaryFXSlotID, dst_d.guidPrimaryFXSlotID))) mEaxDf.set(eax_primary_fx_slot_id_dirty_bit); if(dst_i.flDistanceFactor != dst_d.flDistanceFactor) @@ -781,7 +821,7 @@ void Context::eax5_defer_all(const EaxCall& call, Eax5State& state) auto &dst_d = state.d; dst_d = src; - if(dst_i.guidPrimaryFXSlotID != dst_d.guidPrimaryFXSlotID) + if(std::is_neq(CompareGUID(dst_i.guidPrimaryFXSlotID, dst_d.guidPrimaryFXSlotID))) mEaxDf.set(eax_primary_fx_slot_id_dirty_bit); if(dst_i.flDistanceFactor != dst_d.flDistanceFactor) diff --git a/3rdparty/openal/alc/context.cppm b/3rdparty/openal/alc/context.cppm new file mode 100644 index 000000000000..3f2fdac121e3 --- /dev/null +++ b/3rdparty/openal/alc/context.cppm @@ -0,0 +1,27 @@ +module; + +#include "context.hpp" + +export module alc.context; + +export { + +using ::ContextFlags; +using ::ContextFlagBitset; +using ::DebugLogEntry; + +namespace al { + +using al::ContextDeleter; +using al::Context; +using al::verify_context; + +} + +using ::ContextRef; +using ::GetContextRef; +using ::UpdateContextProps; + +using ::TrapALError; + +} \ No newline at end of file diff --git a/3rdparty/openal/alc/context.h b/3rdparty/openal/alc/context.hpp similarity index 89% rename from 3rdparty/openal/alc/context.h rename to 3rdparty/openal/alc/context.hpp index 7dc15f194163..2ab2e8a0809f 100644 --- a/3rdparty/openal/alc/context.h +++ b/3rdparty/openal/alc/context.hpp @@ -1,5 +1,5 @@ -#ifndef ALC_CONTEXT_H -#define ALC_CONTEXT_H +#ifndef ALC_CONTEXT_HPP +#define ALC_CONTEXT_HPP #include "config.h" @@ -204,35 +204,14 @@ struct Context final : ALCcontext, intrusive_ref, Contex void init(); - /* Thread-local current context. */ - static inline thread_local Context *sLocalContext{}; - - /* Thread-local context handling. This handles attempting to release the - * context which may have been left current when the thread is destroyed. - */ - class ThreadCtx { - public: - ThreadCtx() = default; - ThreadCtx(const ThreadCtx&) = delete; - auto operator=(const ThreadCtx&) -> ThreadCtx& = delete; - - ~ThreadCtx(); - /* NOLINTBEGIN(readability-convert-member-functions-to-static) - * This should be non-static to invoke construction of the thread-local - * sThreadContext, so that it's destructor gets run at thread exit to - * clear sLocalContext (which isn't a member variable to make read - * access efficient). - */ - void set(Context *ctx) const noexcept { sLocalContext = ctx; } - /* NOLINTEND(readability-convert-member-functions-to-static) */ - }; - static thread_local ThreadCtx sThreadContext; - friend ContextDeleter; public: + /* Thread-local current context. */ + static inline thread_local Context *sLocalContext{}; + static Context *getThreadContext() noexcept { return sLocalContext; } - static void setThreadContext(Context *context) noexcept { sThreadContext.set(context); } + static void setThreadContext(Context *context) noexcept; /* Default effect that applies to sources that don't have an effect on send 0. */ static Effect sDefaultEffect; @@ -243,11 +222,11 @@ struct Context final : ALCcontext, intrusive_ref, Contex void eaxUninitialize() noexcept; - ALenum eax_eax_set(const GUID *property_set_id, ALuint property_id, ALuint property_source_id, - ALvoid *property_value, ALuint property_value_size); + ALenum eax_eax_set(AL_GUID const *property_set_id, ALuint property_id, + ALuint property_source_id, ALvoid *property_value, ALuint property_value_size); - ALenum eax_eax_get(const GUID *property_set_id, ALuint property_id, ALuint property_source_id, - ALvoid *property_value, ALuint property_value_size); + ALenum eax_eax_get(AL_GUID const *property_set_id, ALuint property_id, + ALuint property_source_id, ALvoid *property_value, ALuint property_value_size); void eaxSetLastError() noexcept; @@ -302,7 +281,7 @@ struct Context final : ALCcontext, intrusive_ref, Contex }; struct Eax4PrimaryFxSlotIdValidator { - void operator()(const GUID& guidPrimaryFXSlotID) const + void operator()(AL_GUID const& guidPrimaryFXSlotID) const { if(guidPrimaryFXSlotID != EAX_NULL_GUID && guidPrimaryFXSlotID != EAXPROPERTYID_EAX40_FXSlot0 && @@ -359,7 +338,7 @@ struct Context final : ALCcontext, intrusive_ref, Contex }; struct Eax5PrimaryFxSlotIdValidator { - void operator()(const GUID& guidPrimaryFXSlotID) const + void operator()(AL_GUID const& guidPrimaryFXSlotID) const { if(guidPrimaryFXSlotID != EAX_NULL_GUID && guidPrimaryFXSlotID != EAXPROPERTYID_EAX50_FXSlot0 && @@ -472,7 +451,7 @@ struct Context final : ALCcontext, intrusive_ref, Contex * value, and updates a dirty flag. */ template - void eax_defer(const EaxCall &call, auto &state, usize const dirty_bit, auto member) + void eax_defer(const EaxCall &call, auto &state, std::size_t const dirty_bit, auto member) { static_assert(std::invocable); using TMemberResult = std::invoke_result_t; @@ -487,7 +466,7 @@ struct Context final : ALCcontext, intrusive_ref, Contex } void eax_context_commit_property(auto &state, std::bitset &dst_df, - usize const dirty_bit, std::invocable auto member) noexcept + std::size_t const dirty_bit, std::invocable auto member) noexcept { if(mEaxDf.test(dirty_bit)) { @@ -558,16 +537,20 @@ auto GetContextRef() noexcept -> ContextRef; void UpdateContextProps(al::Context *context); +namespace al { -inline constinit auto TrapALError = false; - +inline auto verify_context(ALCcontext *context) -> gsl::not_null +{ + /* TODO: A debug/non-optimized build should essentially do + * al::get_not_null(VerifyContext(context)) to ensure the ALCcontext handle + * is valid, not just non-null. + */ + /* NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast) */ + return gsl::make_not_null(static_cast(context)); +} -#if ALSOFT_EAX -auto AL_APIENTRY EAXSet(const GUID *property_set_id, ALuint property_id, - ALuint source_id, ALvoid *value, ALuint value_size) noexcept -> ALenum; +} -auto AL_APIENTRY EAXGet(const GUID *property_set_id, ALuint property_id, - ALuint source_id, ALvoid *value, ALuint value_size) noexcept -> ALenum; -#endif // ALSOFT_EAX +inline constinit auto TrapALError = false; -#endif /* ALC_CONTEXT_H */ +#endif /* ALC_CONTEXT_HPP */ diff --git a/3rdparty/openal/alc/device.cpp b/3rdparty/openal/alc/device.cpp index 639ce55df6af..83ebdaacd984 100644 --- a/3rdparty/openal/alc/device.cpp +++ b/3rdparty/openal/alc/device.cpp @@ -8,24 +8,30 @@ #endif #include -#include #include -#include #include #include "al/buffer.h" #include "al/effect.h" #include "al/filter.h" #include "alnumeric.h" +#include "altypes.hpp" #include "atomic.h" #include "backends/base.h" #include "core/devformat.h" #include "core/hrtf.h" -#include "core/logging.h" #include "core/mastering.h" #include "flexarray.h" #include "gsl/gsl" +#if HAVE_CXXMODULES +import format.types; +import logging; +#else +#include "alformattypes.hpp" +#include "core/logging.h" +#endif + namespace { @@ -50,21 +56,21 @@ Device::~Device() Backend = nullptr; - auto count = std::accumulate(BufferList.cbegin(), BufferList.cend(), 0_uz, + auto count = std::accumulate(BufferList.cbegin(), BufferList.cend(), 0_usize, [](usize const cur, const BufferSubList &sublist) noexcept -> usize - { return cur + (~sublist.mFreeMask).popcount().c_val; }); + { return cur + (~sublist.mFreeMask).popcount(); }); if(count > 0) WARN("{} Buffer{} not deleted", count, (count==1)?"":"s"); - count = std::accumulate(EffectList.cbegin(), EffectList.cend(), 0_uz, + count = std::accumulate(EffectList.cbegin(), EffectList.cend(), 0_usize, [](usize const cur, const EffectSubList &sublist) noexcept -> usize - { return cur + (~sublist.mFreeMask).popcount().c_val; }); + { return cur + (~sublist.mFreeMask).popcount(); }); if(count > 0) WARN("{} Effect{} not deleted", count, (count==1)?"":"s"); - count = std::accumulate(FilterList.cbegin(), FilterList.cend(), 0_uz, + count = std::accumulate(FilterList.cbegin(), FilterList.cend(), 0_usize, [](usize const cur, const FilterSubList &sublist) noexcept -> usize - { return cur + (~sublist.mFreeMask).popcount().c_val; }); + { return cur + (~sublist.mFreeMask).popcount(); }); if(count > 0) WARN("{} Filter{} not deleted", count, (count==1)?"":"s"); } diff --git a/3rdparty/openal/alc/effects/autowah.cpp b/3rdparty/openal/alc/effects/autowah.cpp index a5d932ed45ed..af316a94cb40 100644 --- a/3rdparty/openal/alc/effects/autowah.cpp +++ b/3rdparty/openal/alc/effects/autowah.cpp @@ -125,7 +125,7 @@ void AutowahState::update(const ContextBase *context, const EffectSlotBase *slot mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { mChans[idx].mTargetChannel = outchan.c_val; mChans[idx].mTargetGain = outgain; diff --git a/3rdparty/openal/alc/effects/chorus.cpp b/3rdparty/openal/alc/effects/chorus.cpp index 6de753eaf076..3484869906a7 100644 --- a/3rdparty/openal/alc/effects/chorus.cpp +++ b/3rdparty/openal/alc/effects/chorus.cpp @@ -138,7 +138,8 @@ void ChorusState::deviceUpdate(const DeviceBase *device, const BufferStorage*) static constexpr auto MaxDelay = std::max(ChorusMaxDelay, FlangerMaxDelay); const auto frequency = static_cast(device->mSampleRate); - const auto maxlen = usize{NextPowerOf2(float2uint(MaxDelay*2.0f*frequency) + 1u)} * NumLines; + const auto maxlen = std::size_t{NextPowerOf2(float2uint(MaxDelay*2.0f*frequency) + 1u)} + * NumLines; if(maxlen != mDelayBuffers.size()) decltype(mDelayBuffers)(maxlen).swap(mDelayBuffers); std::ranges::fill(mDelayBuffers, 0.0f); @@ -223,7 +224,7 @@ void ChorusState::update(const ContextBase *context, const EffectSlotBase *slot, mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { if(idx < mChans.size()) { @@ -389,7 +390,7 @@ void ChorusState::process(const size_t samplesToDo, { return sample + in*gain; }); } } - mOffset += samplesToDo; + mOffset += gsl::narrow_cast(samplesToDo); if(mUpsampler.has_value()) { diff --git a/3rdparty/openal/alc/effects/compressor.cpp b/3rdparty/openal/alc/effects/compressor.cpp index 6ef1cc8164f9..fe59806c8768 100644 --- a/3rdparty/openal/alc/effects/compressor.cpp +++ b/3rdparty/openal/alc/effects/compressor.cpp @@ -41,7 +41,6 @@ #include #include "alc/effects/base.h" -#include "alnumeric.h" #include "core/ambidefs.h" #include "core/bufferline.h" #include "core/device.h" @@ -109,7 +108,7 @@ void CompressorState::update(const ContextBase*, const EffectSlotBase *slot, mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { mChans[idx].mTarget = outchan.c_val; mChans[idx].mGain = outgain; diff --git a/3rdparty/openal/alc/effects/convolution.cpp b/3rdparty/openal/alc/effects/convolution.cpp index 05b1b3eabdfd..434cb0b8ab71 100644 --- a/3rdparty/openal/alc/effects/convolution.cpp +++ b/3rdparty/openal/alc/effects/convolution.cpp @@ -16,10 +16,10 @@ #include #include -#if HAVE_SSE_INTRINSICS -#include -#elif HAVE_NEON +#if HAVE_NEON #include +#elif HAVE_SSE_INTRINSICS +#include #endif #include "alcomplex.h" @@ -156,7 +156,20 @@ constexpr size_t ConvolveUpdateSamples{ConvolveUpdateSize / 2}; void apply_fir(std::span dst, std::span input, const std::span filter) { -#if HAVE_SSE_INTRINSICS +#if HAVE_NEON + std::ranges::generate(dst, [&input,filter] + { + auto r4 = vdupq_n_f32(0.0f); + for(size_t j{0};j < ConvolveUpdateSamples;j+=4) + r4 = vmlaq_f32(r4, vld1q_f32(&input[j]), vld1q_f32(&filter[j])); + input = input.subspan(1); + + r4 = vaddq_f32(r4, vrev64q_f32(r4)); + return vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0); + }); + +#elif HAVE_SSE_INTRINSICS + std::ranges::generate(dst, [&input,filter] { auto r4 = _mm_setzero_ps(); @@ -174,19 +187,6 @@ void apply_fir(std::span dst, std::span input, return _mm_cvtss_f32(r4); }); -#elif HAVE_NEON - - std::ranges::generate(dst, [&input,filter] - { - auto r4 = vdupq_n_f32(0.0f); - for(size_t j{0};j < ConvolveUpdateSamples;j+=4) - r4 = vmlaq_f32(r4, vld1q_f32(&input[j]), vld1q_f32(&filter[j])); - input = input.subspan(1); - - r4 = vaddq_f32(r4, vrev64q_f32(r4)); - return vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0); - }); - #else std::ranges::generate(dst, [&input,filter] @@ -532,7 +532,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlotBase * std::array coeffs{}; for(size_t c{0u};c < mChans.size();++c) { - auto const acn = usize{index_map[c].c_val}; + auto const acn = std::size_t{index_map[c].c_val}; auto const scale = scales[acn]; std::ranges::transform(mixmatrix[acn], coeffs.begin(), [scale](const float in) -> float diff --git a/3rdparty/openal/alc/effects/distortion.cpp b/3rdparty/openal/alc/effects/distortion.cpp index 0926470ea33d..976c5166d9e3 100644 --- a/3rdparty/openal/alc/effects/distortion.cpp +++ b/3rdparty/openal/alc/effects/distortion.cpp @@ -23,13 +23,13 @@ #include #include #include +#include #include #include #include #include #include "alc/effects/base.h" -#include "alnumeric.h" #include "core/ambidefs.h" #include "core/bufferline.h" #include "core/context.h" @@ -168,7 +168,7 @@ void DistortionState::update(const ContextBase *context, const EffectSlotBase *s mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain*props.Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { if(idx < mChans.size()) { diff --git a/3rdparty/openal/alc/effects/echo.cpp b/3rdparty/openal/alc/effects/echo.cpp index 3ebadb68bf98..17e166ecac62 100644 --- a/3rdparty/openal/alc/effects/echo.cpp +++ b/3rdparty/openal/alc/effects/echo.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/3rdparty/openal/alc/effects/equalizer.cpp b/3rdparty/openal/alc/effects/equalizer.cpp index 4d092f1d26a2..80671cf0c72d 100644 --- a/3rdparty/openal/alc/effects/equalizer.cpp +++ b/3rdparty/openal/alc/effects/equalizer.cpp @@ -157,7 +157,7 @@ void EqualizerState::update(const ContextBase *context, const EffectSlotBase *sl mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { mChans[idx].mTargetChannel = outchan.c_val; mChans[idx].mTargetGain = outgain; diff --git a/3rdparty/openal/alc/effects/fshifter.cpp b/3rdparty/openal/alc/effects/fshifter.cpp index 698d4dc51a29..50786f36a46d 100644 --- a/3rdparty/openal/alc/effects/fshifter.cpp +++ b/3rdparty/openal/alc/effects/fshifter.cpp @@ -43,6 +43,11 @@ #include "core/mixer/defs.h" #include "intrusive_ptr.h" +#if HAVE_CXXMODULES +import window.hann; +#else +#include "hann_window.hpp" +#endif struct BufferStorage; @@ -76,31 +81,13 @@ alignas(16) constexpr std::array, NumLines> A2B{{ using complex_d = std::complex; -constexpr auto HilSize = 1024_uz; -constexpr auto HilHalfSize = HilSize >> 1; -constexpr auto OversampleFactor = 4_uz; +constexpr auto HilSize = 1024u; +constexpr auto OversampleFactor = 4u; static_assert(HilSize%OversampleFactor == 0, "Factor must be a clean divisor of the size"); -constexpr auto HilStep{HilSize / OversampleFactor}; +constexpr auto HilStep = HilSize / OversampleFactor; -/* Define a Hann window, used to filter the HIL input and output. */ -struct Windower { - alignas(16) std::array mData{}; - - Windower() noexcept - { - static constexpr auto scale = std::numbers::pi / double{HilSize}; - /* Create lookup table of the Hann window for the desired size. */ - std::ranges::transform(std::views::iota(0u, unsigned{HilHalfSize}), mData.begin(), - [](unsigned const i) -> float - { - const auto val = std::sin((i+0.5) * scale); - return static_cast(val * val); - }); - std::ranges::copy(mData | std::views::take(HilHalfSize), mData.rbegin()); - } -}; -const Windower gWindow{}; +auto &gWindow = gHannWindow; struct FshifterState final : public EffectState { @@ -222,7 +209,7 @@ void FshifterState::update(const ContextBase *context, const EffectSlotBase *slo mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { if(idx < mChans.size()) { @@ -287,16 +274,16 @@ void FshifterState::process(const size_t samplesToDo, { /* Real signal windowing and store in Analytic buffer */ const auto [_, windowiter, analyticiter] = std::ranges::transform( - chandata.mInFIFO | std::views::drop(mPos), gWindow.mData, mAnalytic.begin(), + chandata.mInFIFO | std::views::drop(mPos), gWindow, mAnalytic.begin(), std::multiplies{}); std::ranges::transform(chandata.mInFIFO.begin(), chandata.mInFIFO.end(), windowiter, - gWindow.mData.end(), analyticiter, std::multiplies{}); + gWindow.end(), analyticiter, std::multiplies{}); /* Processing signal by Discrete Hilbert Transform (analytical signal). */ complex_hilbert(mAnalytic); /* Windowing and add to output accumulator */ - std::ranges::transform(mAnalytic, gWindow.mData, mAnalytic.begin(), + std::ranges::transform(mAnalytic, gWindow, mAnalytic.begin(), [](const complex_d &a, const double w) { return 2.0/OversampleFactor*w*a; }); const auto accumrange = chandata.mOutputAccum | std::views::drop(mPos); diff --git a/3rdparty/openal/alc/effects/modulator.cpp b/3rdparty/openal/alc/effects/modulator.cpp index 9723792061b3..bd481e275066 100644 --- a/3rdparty/openal/alc/effects/modulator.cpp +++ b/3rdparty/openal/alc/effects/modulator.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -32,7 +31,6 @@ #include #include "alc/effects/base.h" -#include "alnumeric.h" #include "core/ambidefs.h" #include "core/bufferline.h" #include "core/context.h" @@ -159,7 +157,7 @@ void ModulatorState::update(const ContextBase *context, const EffectSlotBase *sl mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { mChans[idx].mTargetChannel = outchan.c_val; mChans[idx].mTargetGain = outgain; diff --git a/3rdparty/openal/alc/effects/null.cpp b/3rdparty/openal/alc/effects/null.cpp index db57d4c8a2b9..a731459469a3 100644 --- a/3rdparty/openal/alc/effects/null.cpp +++ b/3rdparty/openal/alc/effects/null.cpp @@ -1,7 +1,6 @@ #include "config.h" -#include #include #include "base.h" diff --git a/3rdparty/openal/alc/effects/pshifter.cpp b/3rdparty/openal/alc/effects/pshifter.cpp index e5d05ecebf47..c359cccbf08f 100644 --- a/3rdparty/openal/alc/effects/pshifter.cpp +++ b/3rdparty/openal/alc/effects/pshifter.cpp @@ -41,8 +41,12 @@ #include "core/mixer/defs.h" #include "intrusive_ptr.h" #include "pffft.h" -#include "core/logging.h" -#include "fmt/ranges.h" + +#if HAVE_CXXMODULES +import window.hann; +#else +#include "hann_window.hpp" +#endif struct BufferStorage; struct ContextBase; @@ -53,39 +57,24 @@ namespace { /* To keep from being too intensive with these FFTs, only process up to second * order (9 channels) and upsample higher orders. */ -constexpr auto EffectMaxOrder = 2_uz; +constexpr auto EffectMaxOrder = 2u; constexpr auto UpsampleMatrix = std::span{AmbiScale::SecondOrderUp}; constexpr auto NumLines = AmbiChannelsFromOrder(EffectMaxOrder); using complex_f = std::complex; -constexpr auto StftSize = 1024_uz; -constexpr auto StftHalfSize = StftSize >> 1; -constexpr auto OversampleFactor = 8_uz; +constexpr auto StftSize = 1024u; +constexpr auto StftHalfSize = StftSize >> 1u; +constexpr auto OversampleFactor = 8u; + +static_assert(std::popcount(OversampleFactor) == 1, "Factor must be a power of two"); +constexpr auto OversampleMask = OversampleFactor - 1u; static_assert(StftSize%OversampleFactor == 0, "Factor must be a clean divisor of the size"); constexpr auto StftStep = StftSize / OversampleFactor; -/* Define a Hann window, used to filter the STFT input and output. */ -struct Windower { - alignas(16) std::array mData{}; - - Windower() noexcept - { - static constexpr auto scale = std::numbers::pi / double{StftSize}; - /* Create lookup table of the Hann window for the desired size. */ - std::ranges::transform(std::views::iota(0u, unsigned{StftHalfSize}), mData.begin(), - [](unsigned const i) -> float - { - const auto val = std::sin((i+0.5) * scale); - return static_cast(val * val); - }); - std::ranges::copy(mData | std::views::take(StftHalfSize), mData.rbegin()); - } -}; -const Windower gWindow{}; - +auto &gWindow = gHannWindow; struct FrequencyBin { float Magnitude; @@ -95,8 +84,8 @@ struct FrequencyBin { struct PshifterState final : EffectState { /* Effect parameters */ - usize mCount{}; - usize mPos{}; + std::size_t mCount{}; + std::size_t mPos{}; unsigned mPitchShiftI{}; float mPitchShift{}; @@ -192,7 +181,7 @@ void PshifterState::update(const ContextBase*, const EffectSlotBase *slot, mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { if(idx < mChans.size()) { @@ -259,10 +248,9 @@ void PshifterState::process(const size_t samplesToDo, * forward FFT to get the frequency-domain signal. */ const auto [_, windowiter, fftbufiter] = std::ranges::transform( - fifo | std::views::drop(mPos), gWindow.mData, mFftBuffer.begin(), + fifo | std::views::drop(mPos), gWindow, mFftBuffer.begin(), std::multiplies{}); + std::ranges::transform(fifo.begin(), fifo.end(), windowiter, gWindow.end(), fftbufiter, std::multiplies{}); - std::ranges::transform(fifo.begin(), fifo.end(), windowiter, gWindow.mData.end(), - fftbufiter, std::multiplies{}); mFft.transform_ordered(mFftBuffer.begin(), mFftBuffer.begin(), mFftWorkBuffer.begin(), PFFFT_FORWARD); @@ -289,7 +277,7 @@ void PshifterState::process(const size_t samplesToDo, * increments by 1/OversampleFactor for every frequency * bin. So, the offset wraps every 'OversampleFactor' bin. */ - auto const bin_offset = static_cast(k % OversampleFactor); + auto const bin_offset = static_cast(k & OversampleMask); auto tmp = (phase - mLastPhase[k]) - bin_offset*expected_cycles; /* Store the actual phase for the next update. */ mLastPhase[k] = phase; @@ -301,7 +289,7 @@ void PshifterState::process(const size_t samplesToDo, tmp *= std::numbers::inv_pi_v; auto const qpd = float2int(tmp); tmp -= static_cast(qpd + (qpd%2)); - tmp *= 0.5f * OversampleFactor; + tmp *= float{0.5f*OversampleFactor}; /* Compute the k-th partials' frequency bin target. We * don't need the "true frequency" since it's a linear @@ -331,16 +319,30 @@ void PshifterState::process(const size_t samplesToDo, for(auto k = 0_uz;k < StftHalfSize+1;++k) { /* Calculate the actual delta phase for this bin's target - * frequency bin, and accumulate it to get the actual bin - * phase. + * frequency bin. Subtract the bin index and convert the + * bin deviation to phase deviation, accounting for + * oversampling. Also add the expected phase cycle for this + * index, accounting for oversampling. + * + * tmp = (freqbin - k) * pi*2 / oversamplefactor + * tmp += (k&oversamplemask) * expected_cycles + * + * Equivalently: + * + * tmp = (freqbin-k)*expected_cycles + (k&oversamplemask)*expected_cycles + * = (freqbin - k + (k&oversamplemask)) * expected_cycles + * = (freqbin - (k - (k&oversamplemask))) * expected_cycles + * = (freqbin - (k & ~oversamplemask)) * expected_cycles */ - auto tmp = mSumPhase[k] + mSynthesisBuffer[k].FreqBin*expected_cycles; + auto const bin_offset = static_cast(k & ~std::size_t{OversampleMask}); + auto tmp = (mSynthesisBuffer[k].FreqBin-bin_offset) * expected_cycles; - /* Wrap between -pi and +pi for the sum. If mSumPhase is - * left to grow indefinitely, it will lose precision and - * produce less exact phase over time. + /* Accumulate the phase delta to get the actual bin phase, + * and wrap between -pi and +pi for the sum. If mSumPhase + * is left to accumulate indefinitely, it will grow and + * lose precision, producing less exact phase over time. */ - tmp *= std::numbers::inv_pi_v; + tmp = (tmp+mSumPhase[k]) * std::numbers::inv_pi_v; auto const qpd = float2int(tmp); tmp -= static_cast(qpd + (qpd%2)); mSumPhase[k] = tmp * std::numbers::pi_v; @@ -359,7 +361,7 @@ void PshifterState::process(const size_t samplesToDo, } else { - static constexpr auto bin_limit = size_t{ + static constexpr auto bin_limit = unsigned{ ((StftHalfSize+1)< usize + -> std::size_t { /* All line lengths are powers of 2, calculated from their lengths in * seconds, rounded up. @@ -287,7 +287,7 @@ struct DelayLineU { } static auto calcLineLength(float const length, float const frequency, unsigned const extra) - -> usize + -> std::size_t { auto samples = float2uint(std::ceil(length*frequency)); samples = NextPowerOf2(samples + extra); @@ -296,13 +296,14 @@ struct DelayLineU { } [[nodiscard]] - auto get(usize const chan) const noexcept + auto get(std::size_t const chan) const noexcept { const auto stride = mLine.size() / NUM_LINES; return mLine.subspan(chan*stride, stride); } - void write(usize offset, usize const c, std::span const in) const noexcept + void write(std::size_t offset, std::size_t const c, std::span const in) const + noexcept { const auto stride = mLine.size() / NUM_LINES; const auto output = mLine.subspan(c*stride, stride); @@ -329,8 +330,8 @@ struct DelayLineU { * the B-Format signal is negating W, applying a 180-degree phase shift and * moving each response to its spatially opposite location. */ - void writeReflected(usize offset, std::span const in, - usize const count) const noexcept + void writeReflected(std::size_t offset, std::span const in, + std::size_t const count) const noexcept { const auto stride = mLine.size() / NUM_LINES; offset &= stride-1; @@ -360,19 +361,19 @@ struct DelayLineU { struct VecAllpass { DelayLineI Delay; float Coeff{0.0f}; - std::array Offset{}; + std::array Offset{}; - void process(std::span samples, usize offset, float xCoeff, - float yCoeff, usize todo) const noexcept; + void process(std::span samples, std::size_t offset, float xCoeff, + float yCoeff, std::size_t todo) const noexcept; }; struct Allpass4 { DelayLineU Delay; float Coeff{0.0f}; - std::array Offset{}; + std::array Offset{}; - void process(std::span samples, usize offset, usize todo) - const noexcept; + void process(std::span samples, std::size_t offset, + std::size_t todo) const noexcept; }; struct T60Filter { @@ -399,7 +400,7 @@ struct EarlyReflections { * reflections. */ DelayLineU Delay; - std::array Offset{}; + std::array Offset{}; float Coeff{}; /* The gain for each output channel based on 3D panning. */ @@ -435,7 +436,7 @@ struct Modulation { void updateModulator(float modTime, float modDepth, float frequency); - auto calcDelays(usize todo) -> std::span; + auto calcDelays(std::size_t todo) -> std::span; void clear() noexcept { @@ -448,7 +449,7 @@ struct Modulation { struct LateReverb { /* A recursive delay line is used fill in the reverb tail. */ DelayLineU Delay; - std::array Offset{}; + std::array Offset{}; /* Attenuation to compensate for the modal density and decay rate of the * late lines. @@ -502,11 +503,11 @@ struct ReverbPipeline { DelayLineU mLateDelayIn; /* Tap points for early reflection input delay. */ - std::array, NUM_LINES> mEarlyDelayTap{}; + std::array, NUM_LINES> mEarlyDelayTap{}; std::array mEarlyDelayCoeff{}; /* Tap points for late reverb feed and delay. */ - std::array, NUM_LINES> mLateDelayTap{}; + std::array, NUM_LINES> mLateDelayTap{}; /* Coefficients for the all-pass and line scattering matrices. */ float mMixX{1.0f}; @@ -518,7 +519,7 @@ struct ReverbPipeline { std::array,2> mAmbiSplitter; - usize mFadeSampleCount{1}; + std::size_t mFadeSampleCount{1}; void updateDelayLine(float gain, float earlyDelay, float lateDelay, float density_mult, float frequency); @@ -526,10 +527,10 @@ struct ReverbPipeline { std::span LateReverbPan, float earlyGain, float lateGain, bool doUpmix, MixParams const *mainMix); - void processEarly(DelayLineU const &main_delay, usize offset, usize samplesToDo, + void processEarly(DelayLineU const &main_delay, std::size_t offset, std::size_t samplesToDo, std::span tempSamples, std::span outSamples); - void processLate(usize offset, usize samplesToDo, + void processLate(std::size_t offset, std::size_t samplesToDo, std::span tempSamples, std::span outSamples); @@ -584,7 +585,7 @@ struct ReverbState final : EffectState { std::array mPipelines; /* The current write offset for all delay lines. */ - usize mOffset{}; + std::size_t mOffset{}; /* Temporary storage used when processing. */ alignas(16) FloatBufferLine mTempLine{}; @@ -599,7 +600,7 @@ struct ReverbState final : EffectState { void MixOutPlain(ReverbPipeline &pipeline, std::span const samplesOut, - usize const todo) const + std::size_t const todo) const { /* When not upsampling, the panning gains convert to B-Format and pan * at the same time. @@ -620,7 +621,7 @@ struct ReverbState final : EffectState { } void MixOutAmbiUp(ReverbPipeline &pipeline, std::span const samplesOut, - usize const todo) + std::size_t const todo) { static constexpr auto DoMixRow = [](std::span const OutBuffer, const std::span Gains, @@ -680,7 +681,7 @@ struct ReverbState final : EffectState { } void mixOut(ReverbPipeline &pipeline, std::span const samplesOut, - usize const todo) + std::size_t const todo) { if(mUpmixOutput) MixOutAmbiUp(pipeline, samplesOut, todo); @@ -693,7 +694,7 @@ struct ReverbState final : EffectState { void deviceUpdate(DeviceBase const *device, BufferStorage const *buffer) override; void update(ContextBase const *context, EffectSlotBase const *slot, EffectProps const *props, EffectTarget target) override; - void process(usize samplesToDo, std::span samplesIn, + void process(std::size_t samplesToDo, std::span samplesIn, std::span samplesOut) override; }; @@ -726,7 +727,7 @@ void ReverbState::allocLines(float const frequency) const auto late_vecap_extra = float2uint(std::ceil(LATE_ALLPASS_LENGTHS.front() * multiplier * frequency)); - auto linelengths = std::array{}; + auto linelengths = std::array{}; auto oidx = 0_uz; auto totalSamples = 0_uz; @@ -1336,7 +1337,7 @@ void ReverbState::update(ContextBase const *const context, EffectSlotBase const /* Limit to 100,000 samples (a touch over 2 seconds at 48khz) to avoid * excessive double-processing. */ - pipeline.mFadeSampleCount = static_cast(std::min(decaySamples, 100'000.0f)); + pipeline.mFadeSampleCount = static_cast(std::min(decaySamples, 100'000.0f)); } @@ -1395,7 +1396,7 @@ auto VectorPartialScatter(std::array const &in, float const xC /* Applies the above to the given number of samples. */ void VectorScatter(float const xCoeff, float const yCoeff, - std::span const samples, usize const count) noexcept + std::span const samples, std::size_t const count) noexcept { ASSUME(count > 0); @@ -1415,7 +1416,7 @@ void VectorScatter(float const xCoeff, float const yCoeff, * channels (swapping 0<->3 and 1<->2). */ void VectorScatterRev(float const xCoeff, float const yCoeff, - std::span const samples, usize const count) noexcept + std::span const samples, std::size_t const count) noexcept { ASSUME(count > 0); @@ -1438,10 +1439,10 @@ void VectorScatterRev(float const xCoeff, float const yCoeff, * element with a scattering matrix (like the one above) and a diagonal * matrix of delay elements. */ -void VecAllpass::process(const std::span samples, usize offset, - float const xCoeff, float const yCoeff, usize const todo) const noexcept +void VecAllpass::process(const std::span samples, std::size_t offset, + float const xCoeff, float const yCoeff, std::size_t const todo) const noexcept { - const auto delaymask = usize{Delay.mLine.size()/NUM_LINES - 1_uz}; + const auto delaymask = std::size_t{Delay.mLine.size()/NUM_LINES - 1_uz}; const auto delaybuf = Delay.mLine; const auto feedCoeff = Coeff; @@ -1449,9 +1450,9 @@ void VecAllpass::process(const std::span samples, us for(auto base = 0_uz;base < todo;) { - auto vap_offset = std::array{}; + auto vap_offset = std::array{}; std::ranges::transform(Offset, vap_offset.begin(), - [offset,delaymask](usize const delay) noexcept -> usize + [offset,delaymask](std::size_t const delay) noexcept -> std::size_t { return (offset-delay) & delaymask; }); offset &= delaymask; @@ -1494,8 +1495,8 @@ void VecAllpass::process(const std::span samples, us /* This applies a more typical all-pass to each line, without the scattering * matrix. */ -void Allpass4::process(std::span const samples, usize const offset, - usize const todo) const noexcept +void Allpass4::process(std::span const samples, + std::size_t const offset, std::size_t const todo) const noexcept { const auto delay = Delay; const auto feedCoeff = Coeff; @@ -1544,8 +1545,8 @@ void Allpass4::process(std::span const samples, usi * Finally, the early response is reflected, scattered (based on diffusion), * and fed into the late reverb section of the main delay line. */ -void ReverbPipeline::processEarly(DelayLineU const &main_delay, usize offset, - usize const samplesToDo, std::span const tempSamples, +void ReverbPipeline::processEarly(DelayLineU const &main_delay, std::size_t offset, + std::size_t const samplesToDo, std::span const tempSamples, std::span const outSamples) { const auto early_delay = mEarly.Delay; @@ -1609,7 +1610,7 @@ void ReverbPipeline::processEarly(DelayLineU const &main_delay, usize offset, for(const auto j : std::views::iota(0_uz, NUM_LINES)) { const auto delaybuf = early_delay.get(j); - auto delay_tap = usize{offset - mEarly.Offset[j]}; + auto delay_tap = std::size_t{offset - mEarly.Offset[j]}; auto out = outSamples[j].begin() + base; auto tmp = std::span{tempSamples[j]}.first(todo); while(!tmp.empty()) @@ -1637,7 +1638,7 @@ void ReverbPipeline::processEarly(DelayLineU const &main_delay, usize offset, */ VectorScatter(mixX, mixY, tempSamples, todo); std::ignore = std::ranges::mismatch(std::views::iota(0_uz, NUM_LINES), tempSamples, - [late_in=mLateDelayIn,offset,todo](usize const idx, ReverbUpdateSpan const tmpline) + [late_in=mLateDelayIn,offset,todo](std::size_t const idx, ReverbUpdateSpan const tmpline) { late_in.write(offset, idx, tmpline.first(todo)); return true; @@ -1648,7 +1649,7 @@ void ReverbPipeline::processEarly(DelayLineU const &main_delay, usize offset, } } -auto Modulation::calcDelays(usize const todo) -> std::span +auto Modulation::calcDelays(std::size_t const todo) -> std::span { auto idx = Index; const auto step = Step; @@ -1682,7 +1683,7 @@ auto Modulation::calcDelays(usize const todo) -> std::span * Finally, the lines are reversed (so they feed their opposite directions) * and scattered with the FDN matrix before re-feeding the delay lines. */ -void ReverbPipeline::processLate(usize offset, usize const samplesToDo, +void ReverbPipeline::processLate(std::size_t offset, std::size_t const samplesToDo, std::span const tempSamples, std::span const outSamples) { @@ -1708,16 +1709,16 @@ void ReverbPipeline::processLate(usize offset, usize const samplesToDo, { const auto input = late_delay.get(j); const auto midGain = mLate.T60[j].mMidGain; - auto late_feedb_tap = usize{offset - mLate.Offset[j]}; + auto late_feedb_tap = std::size_t{offset - mLate.Offset[j]}; std::ranges::transform(delays, tempSamples[j].begin(), - [input,midGain,&late_feedb_tap](usize const idelay) -> float + [input,midGain,&late_feedb_tap](std::size_t const idelay) -> float { /* Calculate the read sample offset and sub-sample offset * between it and the next sample. */ const auto delay = late_feedb_tap - (idelay>>gCubicTable.sTableBits); - const auto delayoffset = usize{idelay & gCubicTable.sTableMask}; + const auto delayoffset = std::size_t{idelay & gCubicTable.sTableMask}; ++late_feedb_tap; /* Get the samples around the delayed offset, interpolated for @@ -1743,8 +1744,8 @@ void ReverbPipeline::processLate(usize offset, usize const samplesToDo, for(const auto j : std::views::iota(0_uz, NUM_LINES)) { const auto input = in_delay.get(j); - auto late_delay_tap0 = usize{offset - mLateDelayTap[j][0]}; - auto late_delay_tap1 = usize{offset - mLateDelayTap[j][1]}; + auto late_delay_tap0 = std::size_t{offset - mLateDelayTap[j][0]}; + auto late_delay_tap1 = std::size_t{offset - mLateDelayTap[j][1]}; mLateDelayTap[j][0] = mLateDelayTap[j][1]; const auto densityGain = mLate.DensityGain; const auto densityStep = late_delay_tap0 != late_delay_tap1 @@ -1788,7 +1789,7 @@ void ReverbPipeline::processLate(usize offset, usize const samplesToDo, /* Finally, scatter and bounce the results to refeed the feedback buffer. */ VectorScatterRev(mixX, mixY, tempSamples, todo); std::ignore = std::ranges::mismatch(std::views::iota(0_uz, NUM_LINES), tempSamples, - [late_delay,offset,todo](usize const idx, ReverbUpdateLine const &tmpline) + [late_delay,offset,todo](std::size_t const idx, ReverbUpdateLine const &tmpline) { late_delay.write(offset, idx, std::span{tmpline}.first(todo)); return true; @@ -1799,7 +1800,7 @@ void ReverbPipeline::processLate(usize offset, usize const samplesToDo, } } -void ReverbState::process(usize const samplesToDo, +void ReverbState::process(std::size_t const samplesToDo, std::span const samplesIn, std::span const samplesOut) { const auto offset = mOffset; diff --git a/3rdparty/openal/alc/effects/vmorpher.cpp b/3rdparty/openal/alc/effects/vmorpher.cpp index a7f11e9d0607..5da9f3f4dc48 100644 --- a/3rdparty/openal/alc/effects/vmorpher.cpp +++ b/3rdparty/openal/alc/effects/vmorpher.cpp @@ -60,7 +60,7 @@ namespace { constexpr auto MaxUpdateSamples = 256_uz; constexpr auto NumFormants = 4_uz; constexpr auto RcpQFactor = 1.0f / 5.0f; -enum : size_t { +enum : std::size_t { VowelAIndex, VowelBIndex, NumFilters @@ -268,7 +268,7 @@ void VmorpherState::update(const ContextBase *context, const EffectSlotBase *slo mOutTarget = target.Main->Buffer; target.Main->setAmbiMixParams(slot->Wet, slot->Gain, - [this](usize const idx, u8 const outchan, float const outgain) + [this](std::size_t const idx, u8 const outchan, float const outgain) { mChans[idx].mTargetChannel = outchan.c_val; mChans[idx].mTargetGain = outgain; diff --git a/3rdparty/openal/alc/events.cpp b/3rdparty/openal/alc/events.cpp index 70c22fe473fe..c286ad2cdc01 100644 --- a/3rdparty/openal/alc/events.cpp +++ b/3rdparty/openal/alc/events.cpp @@ -6,15 +6,30 @@ #include #include -#include "alformat.hpp" #include "alnumeric.h" -#include "core/logging.h" #include "device.h" +#include "opthelpers.h" + +#if HAVE_CXXMODULES +import gsl; +import logging; +#else +#include "core/logging.h" #include "gsl/gsl" +#endif namespace { +#if defined(__linux__) && !defined(AL_LIBTYPE_STATIC) && HAS_ATTRIBUTE(gnu::alias) +#define DefineAlcAlias(X) extern "C" DECL_HIDDEN [[gnu::alias(#X)]] decltype(X) X##_; +#else +#define DefineAlcAlias(X) +#endif + +using EventBitSet = al::bitset; +auto gEventsEnabled = EventBitSet{0}; + auto EnumFromEventType(const alc::EventType type) -> ALCenum { switch(type) @@ -22,7 +37,6 @@ auto EnumFromEventType(const alc::EventType type) -> ALCenum case alc::EventType::DefaultDeviceChanged: return ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT; case alc::EventType::DeviceAdded: return ALC_EVENT_TYPE_DEVICE_ADDED_SOFT; case alc::EventType::DeviceRemoved: return ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT; - case alc::EventType::Count: break; } throw std::runtime_error{al::format("Invalid EventType: {}", int{al::to_underlying(type)})}; } @@ -31,28 +45,28 @@ auto EnumFromEventType(const alc::EventType type) -> ALCenum namespace alc { -auto GetEventType(ALCenum type) -> std::optional +auto GetEventType(ALCenum const type) -> std::optional { switch(type) { - case ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT: return alc::EventType::DefaultDeviceChanged; - case ALC_EVENT_TYPE_DEVICE_ADDED_SOFT: return alc::EventType::DeviceAdded; - case ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT: return alc::EventType::DeviceRemoved; + case ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT: return EventType::DefaultDeviceChanged; + case ALC_EVENT_TYPE_DEVICE_ADDED_SOFT: return EventType::DeviceAdded; + case ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT: return EventType::DeviceRemoved; } return std::nullopt; } -void Event(EventType eventType, DeviceType deviceType, ALCdevice *device, std::string_view message) - noexcept +void Event(EventType const eventType, DeviceType const deviceType, ALCdevice *const device, + std::string_view const message) noexcept { auto eventlock = std::unique_lock{EventMutex}; - if(EventCallback && EventsEnabled.test(al::to_underlying(eventType))) + if(EventCallback && gEventsEnabled.test(eventType)) EventCallback(EnumFromEventType(eventType), al::to_underlying(deviceType), device, /* NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage) */ - gsl::narrow_cast(message.size()), message.data(), EventUserPtr); + al::saturate_cast(message.size()), message.data(), EventUserPtr); } -} // namespace alc +} /* namespace alc */ FORCE_ALIGN auto ALC_APIENTRY alcEventControlSOFT(ALCsizei count, const ALCenum *events, ALCboolean enable) noexcept -> ALCboolean @@ -75,14 +89,14 @@ FORCE_ALIGN auto ALC_APIENTRY alcEventControlSOFT(ALCsizei count, const ALCenum return ALC_FALSE; } - auto eventSet = alc::EventBitSet{0}; + auto eventSet = EventBitSet{}; auto eventrange = std::views::counted(events, count); - const auto invalidevent = std::ranges::find_if_not(eventrange, [&eventSet](ALCenum type) + const auto invalidevent = std::ranges::find_if_not(eventrange, [&eventSet](ALCenum const type) { const auto etype = alc::GetEventType(type); if(!etype) return false; - eventSet.set(al::to_underlying(*etype)); + eventSet.set(*etype); return true; }); if(invalidevent != eventrange.end()) @@ -93,10 +107,11 @@ FORCE_ALIGN auto ALC_APIENTRY alcEventControlSOFT(ALCsizei count, const ALCenum } auto eventlock = std::unique_lock{alc::EventMutex}; - if(enable) alc::EventsEnabled |= eventSet; - else alc::EventsEnabled &= ~eventSet; + if(enable) gEventsEnabled |= eventSet; + else gEventsEnabled &= ~eventSet; return ALC_TRUE; } +DefineAlcAlias(alcEventControlSOFT) FORCE_ALIGN void ALC_APIENTRY alcEventCallbackSOFT(ALCEVENTPROCTYPESOFT callback, void *userParam) noexcept { @@ -104,3 +119,4 @@ FORCE_ALIGN void ALC_APIENTRY alcEventCallbackSOFT(ALCEVENTPROCTYPESOFT callback alc::EventCallback = callback; alc::EventUserPtr = userParam; } +DefineAlcAlias(alcEventCallbackSOFT) diff --git a/3rdparty/openal/alc/events.h b/3rdparty/openal/alc/events.h index 3a36245d714e..f3a2dcd1c3c0 100644 --- a/3rdparty/openal/alc/events.h +++ b/3rdparty/openal/alc/events.h @@ -4,12 +4,12 @@ #include "inprogext.h" #include "opthelpers.h" -#include #include #include #include #include "altypes.hpp" +#include "bitset.hpp" namespace alc { @@ -18,10 +18,10 @@ enum class EventType : u8::value_t { DeviceAdded, DeviceRemoved, - Count + MaxValue = DeviceRemoved }; -std::optional GetEventType(ALCenum type); +std::optional GetEventType(ALCenum type); enum class EventSupport : ALCenum { FullSupport = ALC_EVENT_SUPPORTED_SOFT, @@ -33,9 +33,6 @@ enum class DeviceType : ALCenum { Capture = ALC_CAPTURE_DEVICE_SOFT, }; -using EventBitSet = std::bitset; -inline EventBitSet EventsEnabled{0}; - inline std::mutex EventMutex; inline ALCEVENTPROCTYPESOFT EventCallback{}; diff --git a/3rdparty/openal/alc/export_list.h b/3rdparty/openal/alc/export_list.h index 9dbf9ea6391f..b4f53e9f9d21 100644 --- a/3rdparty/openal/alc/export_list.h +++ b/3rdparty/openal/alc/export_list.h @@ -11,17 +11,393 @@ #include "AL/alext.h" #include "inprogext.h" +#include "opthelpers.h" #if ALSOFT_EAX -#include "context.h" +#include "al/eax/api.h" #include "al/eax/x_ram.h" #endif +#if defined(__linux__) && !defined(AL_LIBTYPE_STATIC) && HAS_ATTRIBUTE(gnu::alias) +#define GetFuncPtr(x) reinterpret_cast(&x##_) +#define DeclareFuncAlias(x) extern "C" DECL_HIDDEN decltype(x) x##_ + +DeclareFuncAlias(alcCreateContext); +DeclareFuncAlias(alcMakeContextCurrent); +DeclareFuncAlias(alcProcessContext); +DeclareFuncAlias(alcSuspendContext); +DeclareFuncAlias(alcDestroyContext); +DeclareFuncAlias(alcGetCurrentContext); +DeclareFuncAlias(alcGetContextsDevice); +DeclareFuncAlias(alcOpenDevice); +DeclareFuncAlias(alcCloseDevice); +DeclareFuncAlias(alcGetError); +DeclareFuncAlias(alcIsExtensionPresent); +DeclareFuncAlias(alcGetProcAddress); +DeclareFuncAlias(alcGetEnumValue); +DeclareFuncAlias(alcGetString); +DeclareFuncAlias(alcGetIntegerv); +DeclareFuncAlias(alcCaptureOpenDevice); +DeclareFuncAlias(alcCaptureCloseDevice); +DeclareFuncAlias(alcCaptureStart); +DeclareFuncAlias(alcCaptureStop); +DeclareFuncAlias(alcCaptureSamples); + +DeclareFuncAlias(alcSetThreadContext); +DeclareFuncAlias(alcGetThreadContext); + +DeclareFuncAlias(alcLoopbackOpenDeviceSOFT); +DeclareFuncAlias(alcIsRenderFormatSupportedSOFT); +DeclareFuncAlias(alcRenderSamplesSOFT); + +DeclareFuncAlias(alcDevicePauseSOFT); +DeclareFuncAlias(alcDeviceResumeSOFT); + +DeclareFuncAlias(alcGetStringiSOFT); +DeclareFuncAlias(alcResetDeviceSOFT); + +DeclareFuncAlias(alcGetInteger64vSOFT); + +DeclareFuncAlias(alcReopenDeviceSOFT); + +DeclareFuncAlias(alcEventIsSupportedSOFT); +DeclareFuncAlias(alcEventControlSOFT); +DeclareFuncAlias(alcEventCallbackSOFT); + +DeclareFuncAlias(alEnable); +DeclareFuncAlias(alDisable); +DeclareFuncAlias(alIsEnabled); +DeclareFuncAlias(alGetString); +DeclareFuncAlias(alGetBooleanv); +DeclareFuncAlias(alGetIntegerv); +DeclareFuncAlias(alGetFloatv); +DeclareFuncAlias(alGetDoublev); +DeclareFuncAlias(alGetBoolean); +DeclareFuncAlias(alGetInteger); +DeclareFuncAlias(alGetFloat); +DeclareFuncAlias(alGetDouble); +DeclareFuncAlias(alGetError); +DeclareFuncAlias(alIsExtensionPresent); +DeclareFuncAlias(alGetProcAddress); +DeclareFuncAlias(alGetEnumValue); +DeclareFuncAlias(alListenerf); +DeclareFuncAlias(alListener3f); +DeclareFuncAlias(alListenerfv); +DeclareFuncAlias(alListeneri); +DeclareFuncAlias(alListener3i); +DeclareFuncAlias(alListeneriv); +DeclareFuncAlias(alGetListenerf); +DeclareFuncAlias(alGetListener3f); +DeclareFuncAlias(alGetListenerfv); +DeclareFuncAlias(alGetListeneri); +DeclareFuncAlias(alGetListener3i); +DeclareFuncAlias(alGetListeneriv); +DeclareFuncAlias(alGenSources); +DeclareFuncAlias(alDeleteSources); +DeclareFuncAlias(alIsSource); +DeclareFuncAlias(alSourcef); +DeclareFuncAlias(alSource3f); +DeclareFuncAlias(alSourcefv); +DeclareFuncAlias(alSourcei); +DeclareFuncAlias(alSource3i); +DeclareFuncAlias(alSourceiv); +DeclareFuncAlias(alGetSourcef); +DeclareFuncAlias(alGetSource3f); +DeclareFuncAlias(alGetSourcefv); +DeclareFuncAlias(alGetSourcei); +DeclareFuncAlias(alGetSource3i); +DeclareFuncAlias(alGetSourceiv); +DeclareFuncAlias(alSourcePlayv); +DeclareFuncAlias(alSourceStopv); +DeclareFuncAlias(alSourceRewindv); +DeclareFuncAlias(alSourcePausev); +DeclareFuncAlias(alSourcePlay); +DeclareFuncAlias(alSourceStop); +DeclareFuncAlias(alSourceRewind); +DeclareFuncAlias(alSourcePause); +DeclareFuncAlias(alSourceQueueBuffers); +DeclareFuncAlias(alSourceUnqueueBuffers); +DeclareFuncAlias(alGenBuffers); +DeclareFuncAlias(alDeleteBuffers); +DeclareFuncAlias(alIsBuffer); +DeclareFuncAlias(alBufferData); +DeclareFuncAlias(alBufferf); +DeclareFuncAlias(alBuffer3f); +DeclareFuncAlias(alBufferfv); +DeclareFuncAlias(alBufferi); +DeclareFuncAlias(alBuffer3i); +DeclareFuncAlias(alBufferiv); +DeclareFuncAlias(alGetBufferf); +DeclareFuncAlias(alGetBuffer3f); +DeclareFuncAlias(alGetBufferfv); +DeclareFuncAlias(alGetBufferi); +DeclareFuncAlias(alGetBuffer3i); +DeclareFuncAlias(alGetBufferiv); +DeclareFuncAlias(alDopplerFactor); +DeclareFuncAlias(alDopplerVelocity); +DeclareFuncAlias(alSpeedOfSound); +DeclareFuncAlias(alDistanceModel); + +DeclareFuncAlias(alGenFilters); +DeclareFuncAlias(alDeleteFilters); +DeclareFuncAlias(alIsFilter); +DeclareFuncAlias(alFilteri); +DeclareFuncAlias(alFilteriv); +DeclareFuncAlias(alFilterf); +DeclareFuncAlias(alFilterfv); +DeclareFuncAlias(alGetFilteri); +DeclareFuncAlias(alGetFilteriv); +DeclareFuncAlias(alGetFilterf); +DeclareFuncAlias(alGetFilterfv); +DeclareFuncAlias(alGenEffects); +DeclareFuncAlias(alDeleteEffects); +DeclareFuncAlias(alIsEffect); +DeclareFuncAlias(alEffecti); +DeclareFuncAlias(alEffectiv); +DeclareFuncAlias(alEffectf); +DeclareFuncAlias(alEffectfv); +DeclareFuncAlias(alGetEffecti); +DeclareFuncAlias(alGetEffectiv); +DeclareFuncAlias(alGetEffectf); +DeclareFuncAlias(alGetEffectfv); +DeclareFuncAlias(alGenAuxiliaryEffectSlots); +DeclareFuncAlias(alDeleteAuxiliaryEffectSlots); +DeclareFuncAlias(alIsAuxiliaryEffectSlot); +DeclareFuncAlias(alAuxiliaryEffectSloti); +DeclareFuncAlias(alAuxiliaryEffectSlotiv); +DeclareFuncAlias(alAuxiliaryEffectSlotf); +DeclareFuncAlias(alAuxiliaryEffectSlotfv); +DeclareFuncAlias(alGetAuxiliaryEffectSloti); +DeclareFuncAlias(alGetAuxiliaryEffectSlotiv); +DeclareFuncAlias(alGetAuxiliaryEffectSlotf); +DeclareFuncAlias(alGetAuxiliaryEffectSlotfv); + +DeclareFuncAlias(alDeferUpdatesSOFT); +DeclareFuncAlias(alProcessUpdatesSOFT); + +DeclareFuncAlias(alSourcedSOFT); +DeclareFuncAlias(alSource3dSOFT); +DeclareFuncAlias(alSourcedvSOFT); +DeclareFuncAlias(alGetSourcedSOFT); +DeclareFuncAlias(alGetSource3dSOFT); +DeclareFuncAlias(alGetSourcedvSOFT); +DeclareFuncAlias(alSourcei64SOFT); +DeclareFuncAlias(alSource3i64SOFT); +DeclareFuncAlias(alSourcei64vSOFT); +DeclareFuncAlias(alGetSourcei64SOFT); +DeclareFuncAlias(alGetSource3i64SOFT); +DeclareFuncAlias(alGetSourcei64vSOFT); + +DeclareFuncAlias(alGetStringiSOFT); + +DeclareFuncAlias(alBufferStorageSOFT); +DeclareFuncAlias(alMapBufferSOFT); +DeclareFuncAlias(alUnmapBufferSOFT); +DeclareFuncAlias(alFlushMappedBufferSOFT); + +DeclareFuncAlias(alEventControlSOFT); +DeclareFuncAlias(alEventCallbackSOFT); +DeclareFuncAlias(alGetPointerSOFT); +DeclareFuncAlias(alGetPointervSOFT); + +DeclareFuncAlias(alBufferCallbackSOFT); +DeclareFuncAlias(alGetBufferPtrSOFT); +DeclareFuncAlias(alGetBuffer3PtrSOFT); +DeclareFuncAlias(alGetBufferPtrvSOFT); + +DeclareFuncAlias(alSourcePlayAtTimeSOFT); +DeclareFuncAlias(alSourcePlayAtTimevSOFT); + +DeclareFuncAlias(alBufferSubDataSOFT); + +DeclareFuncAlias(alBufferDataStatic); + +DeclareFuncAlias(alDebugMessageCallbackEXT); +DeclareFuncAlias(alDebugMessageInsertEXT); +DeclareFuncAlias(alDebugMessageControlEXT); +DeclareFuncAlias(alPushDebugGroupEXT); +DeclareFuncAlias(alPopDebugGroupEXT); +DeclareFuncAlias(alGetDebugMessageLogEXT); +DeclareFuncAlias(alObjectLabelEXT); +DeclareFuncAlias(alGetObjectLabelEXT); +DeclareFuncAlias(alGetPointerEXT); +DeclareFuncAlias(alGetPointervEXT); + +DeclareFuncAlias(alcGetProcAddress2); +DeclareFuncAlias(alEnableDirect); +DeclareFuncAlias(alDisableDirect); +DeclareFuncAlias(alIsEnabledDirect); +DeclareFuncAlias(alDopplerFactorDirect); +DeclareFuncAlias(alSpeedOfSoundDirect); +DeclareFuncAlias(alDistanceModelDirect); +DeclareFuncAlias(alGetStringDirect); +DeclareFuncAlias(alGetBooleanvDirect); +DeclareFuncAlias(alGetIntegervDirect); +DeclareFuncAlias(alGetFloatvDirect); +DeclareFuncAlias(alGetDoublevDirect); +DeclareFuncAlias(alGetBooleanDirect); +DeclareFuncAlias(alGetIntegerDirect); +DeclareFuncAlias(alGetFloatDirect); +DeclareFuncAlias(alGetDoubleDirect); + +DeclareFuncAlias(alGetErrorDirect); +DeclareFuncAlias(alIsExtensionPresentDirect); +DeclareFuncAlias(alGetProcAddressDirect); +DeclareFuncAlias(alGetEnumValueDirect); + +DeclareFuncAlias(alListeneriDirect); +DeclareFuncAlias(alListener3iDirect); +DeclareFuncAlias(alListenerivDirect); +DeclareFuncAlias(alListenerfDirect); +DeclareFuncAlias(alListener3fDirect); +DeclareFuncAlias(alListenerfvDirect); +DeclareFuncAlias(alGetListeneriDirect); +DeclareFuncAlias(alGetListener3iDirect); +DeclareFuncAlias(alGetListenerivDirect); +DeclareFuncAlias(alGetListenerfDirect); +DeclareFuncAlias(alGetListener3fDirect); +DeclareFuncAlias(alGetListenerfvDirect); + +DeclareFuncAlias(alGenBuffersDirect); +DeclareFuncAlias(alDeleteBuffersDirect); +DeclareFuncAlias(alIsBufferDirect); +DeclareFuncAlias(alBufferDataDirect); +DeclareFuncAlias(alBufferiDirect); +DeclareFuncAlias(alBuffer3iDirect); +DeclareFuncAlias(alBufferivDirect); +DeclareFuncAlias(alBufferfDirect); +DeclareFuncAlias(alBuffer3fDirect); +DeclareFuncAlias(alBufferfvDirect); +DeclareFuncAlias(alGetBufferiDirect); +DeclareFuncAlias(alGetBuffer3iDirect); +DeclareFuncAlias(alGetBufferivDirect); +DeclareFuncAlias(alGetBufferfDirect); +DeclareFuncAlias(alGetBuffer3fDirect); +DeclareFuncAlias(alGetBufferfvDirect); + +DeclareFuncAlias(alGenSourcesDirect); +DeclareFuncAlias(alDeleteSourcesDirect); +DeclareFuncAlias(alIsSourceDirect); +DeclareFuncAlias(alSourcePlayDirect); +DeclareFuncAlias(alSourceStopDirect); +DeclareFuncAlias(alSourcePauseDirect); +DeclareFuncAlias(alSourceRewindDirect); +DeclareFuncAlias(alSourcePlayvDirect); +DeclareFuncAlias(alSourceStopvDirect); +DeclareFuncAlias(alSourcePausevDirect); +DeclareFuncAlias(alSourceRewindvDirect); +DeclareFuncAlias(alSourceiDirect); +DeclareFuncAlias(alSource3iDirect); +DeclareFuncAlias(alSourceivDirect); +DeclareFuncAlias(alSourcefDirect); +DeclareFuncAlias(alSource3fDirect); +DeclareFuncAlias(alSourcefvDirect); +DeclareFuncAlias(alGetSourceiDirect); +DeclareFuncAlias(alGetSource3iDirect); +DeclareFuncAlias(alGetSourceivDirect); +DeclareFuncAlias(alGetSourcefDirect); +DeclareFuncAlias(alGetSource3fDirect); +DeclareFuncAlias(alGetSourcefvDirect); +DeclareFuncAlias(alSourceQueueBuffersDirect); +DeclareFuncAlias(alSourceUnqueueBuffersDirect); + +DeclareFuncAlias(alGenFiltersDirect); +DeclareFuncAlias(alDeleteFiltersDirect); +DeclareFuncAlias(alIsFilterDirect); +DeclareFuncAlias(alFilteriDirect); +DeclareFuncAlias(alFilterivDirect); +DeclareFuncAlias(alFilterfDirect); +DeclareFuncAlias(alFilterfvDirect); +DeclareFuncAlias(alGetFilteriDirect); +DeclareFuncAlias(alGetFilterivDirect); +DeclareFuncAlias(alGetFilterfDirect); +DeclareFuncAlias(alGetFilterfvDirect); +DeclareFuncAlias(alGenEffectsDirect); +DeclareFuncAlias(alDeleteEffectsDirect); +DeclareFuncAlias(alIsEffectDirect); +DeclareFuncAlias(alEffectiDirect); +DeclareFuncAlias(alEffectivDirect); +DeclareFuncAlias(alEffectfDirect); +DeclareFuncAlias(alEffectfvDirect); +DeclareFuncAlias(alGetEffectiDirect); +DeclareFuncAlias(alGetEffectivDirect); +DeclareFuncAlias(alGetEffectfDirect); +DeclareFuncAlias(alGetEffectfvDirect); +DeclareFuncAlias(alGenAuxiliaryEffectSlotsDirect); +DeclareFuncAlias(alDeleteAuxiliaryEffectSlotsDirect); +DeclareFuncAlias(alIsAuxiliaryEffectSlotDirect); +DeclareFuncAlias(alAuxiliaryEffectSlotiDirect); +DeclareFuncAlias(alAuxiliaryEffectSlotivDirect); +DeclareFuncAlias(alAuxiliaryEffectSlotfDirect); +DeclareFuncAlias(alAuxiliaryEffectSlotfvDirect); +DeclareFuncAlias(alGetAuxiliaryEffectSlotiDirect); +DeclareFuncAlias(alGetAuxiliaryEffectSlotivDirect); +DeclareFuncAlias(alGetAuxiliaryEffectSlotfDirect); +DeclareFuncAlias(alGetAuxiliaryEffectSlotfvDirect); + +DeclareFuncAlias(alDeferUpdatesDirectSOFT); +DeclareFuncAlias(alProcessUpdatesDirectSOFT); +DeclareFuncAlias(alGetStringiDirectSOFT); + +DeclareFuncAlias(alBufferDataStaticDirect); +DeclareFuncAlias(alBufferCallbackDirectSOFT); +DeclareFuncAlias(alBufferSubDataDirectSOFT); +DeclareFuncAlias(alBufferStorageDirectSOFT); +DeclareFuncAlias(alMapBufferDirectSOFT); +DeclareFuncAlias(alUnmapBufferDirectSOFT); +DeclareFuncAlias(alFlushMappedBufferDirectSOFT); + +DeclareFuncAlias(alSourcei64DirectSOFT); +DeclareFuncAlias(alSource3i64DirectSOFT); +DeclareFuncAlias(alSourcei64vDirectSOFT); +DeclareFuncAlias(alSourcedDirectSOFT); +DeclareFuncAlias(alSource3dDirectSOFT); +DeclareFuncAlias(alSourcedvDirectSOFT); +DeclareFuncAlias(alGetSourcei64DirectSOFT); +DeclareFuncAlias(alGetSource3i64DirectSOFT); +DeclareFuncAlias(alGetSourcei64vDirectSOFT); +DeclareFuncAlias(alGetSourcedDirectSOFT); +DeclareFuncAlias(alGetSource3dDirectSOFT); +DeclareFuncAlias(alGetSourcedvDirectSOFT); +DeclareFuncAlias(alSourcePlayAtTimeDirectSOFT); +DeclareFuncAlias(alSourcePlayAtTimevDirectSOFT); + +DeclareFuncAlias(alEventControlDirectSOFT); +DeclareFuncAlias(alEventCallbackDirectSOFT); + +DeclareFuncAlias(alDebugMessageCallbackDirectEXT); +DeclareFuncAlias(alDebugMessageInsertDirectEXT); +DeclareFuncAlias(alDebugMessageControlDirectEXT); +DeclareFuncAlias(alPushDebugGroupDirectEXT); +DeclareFuncAlias(alPopDebugGroupDirectEXT); +DeclareFuncAlias(alGetDebugMessageLogDirectEXT); +DeclareFuncAlias(alObjectLabelDirectEXT); +DeclareFuncAlias(alGetObjectLabelDirectEXT); +DeclareFuncAlias(alGetPointerDirectEXT); +DeclareFuncAlias(alGetPointervDirectEXT); + +#if ALSOFT_EAX +DeclareFuncAlias(EAXGet); +DeclareFuncAlias(EAXSet); +DeclareFuncAlias(EAXGetBufferMode); +DeclareFuncAlias(EAXSetBufferMode); +DeclareFuncAlias(EAXGetDirect); +DeclareFuncAlias(EAXSetDirect); +DeclareFuncAlias(EAXGetBufferModeDirect); +DeclareFuncAlias(EAXSetBufferModeDirect); +#endif +#undef DeclareFuncAlias + +#else + +#define GetFuncPtr(x) reinterpret_cast(&x) +#endif + struct FuncExport { std::string_view funcName; void *address; }; -#define DECL(x) FuncExport{#x, reinterpret_cast(&x)} +#define DECL(x) FuncExport{#x, GetFuncPtr(x)} inline const auto alcFunctions = std::to_array({ /* NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast) */ DECL(alcCreateContext), @@ -380,7 +756,7 @@ inline const auto alcFunctions = std::to_array({ DECL(alGetPointervDirectEXT), /* Extra functions */ - DECL(alsoft_set_log_callback), + FuncExport{"alsoft_set_log_callback", reinterpret_cast(&alsoft_set_log_callback)}, }); #if ALSOFT_EAX inline const auto eaxFunctions = std::array{ @@ -396,6 +772,7 @@ inline const auto eaxFunctions = std::array{ /* NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast) */ }; #endif +#undef GetFuncPtr #undef DECL struct EnumExport { diff --git a/3rdparty/openal/alc/panning.cpp b/3rdparty/openal/alc/panning.cpp index 23a358dee840..c9c6f1835c0d 100644 --- a/3rdparty/openal/alc/panning.cpp +++ b/3rdparty/openal/alc/panning.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -40,9 +39,9 @@ #include "AL/alext.h" -#include "alc/context.h" #include "alnumeric.h" #include "alstring.h" +#include "altypes.hpp" #include "alu.h" #include "core/ambdec.h" #include "core/ambidefs.h" @@ -56,16 +55,25 @@ #include "core/filters/splitter.h" #include "core/front_stablizer.h" #include "core/hrtf.h" -#include "core/logging.h" #include "core/mixer/hrtfdefs.h" #include "core/tsmefilter.hpp" #include "core/uhjfilter.h" #include "device.h" #include "flexarray.h" -#include "gsl/gsl" #include "intrusive_ptr.h" #include "opthelpers.h" -#include "vector.h" + +#if HAVE_CXXMODULES +import alc.context; +import format.types; +import gsl; +import logging; +#else +#include "alc/context.hpp" +#include "alformattypes.hpp" +#include "core/logging.h" +#include "gsl/gsl" +#endif namespace { @@ -149,7 +157,8 @@ auto GetScalingName(DevAmbiScaling const scaling) noexcept -> std::string_view [[nodiscard]] -auto CreateStablizer(usize const outchans, unsigned const srate) -> std::unique_ptr +auto CreateStablizer(std::size_t const outchans, unsigned const srate) + -> std::unique_ptr { auto stablizer = FrontStablizer::Create(outchans); @@ -162,7 +171,8 @@ auto CreateStablizer(usize const outchans, unsigned const srate) -> std::unique_ return stablizer; } -void AllocChannels(al::Device *const device, usize const main_chans, usize const real_chans) +void AllocChannels(al::Device *const device, std::size_t const main_chans, + std::size_t const real_chans) { TRACE("Channel config, Main: {}, Real: {}", main_chans, real_chans); @@ -194,10 +204,10 @@ enum SpatialMode : bool { Periphonic /* 3D */ }; -template +template struct DecoderConfig; -template +template struct DecoderConfig { u8 mOrder{}; SpatialMode m3DMode{}; @@ -207,7 +217,7 @@ struct DecoderConfig { std::array mCoeffs{}; }; -template +template struct DecoderConfig { u8 mOrder{}; SpatialMode m3DMode{}; @@ -230,7 +240,7 @@ struct DecoderConfig { std::span mOrderGainLF; std::span mCoeffsLF; - template + template auto operator=(const DecoderConfig &rhs) & noexcept -> DecoderConfig& { mOrder = rhs.mOrder; @@ -244,7 +254,7 @@ struct DecoderConfig { return *this; } - template + template auto operator=(const DecoderConfig &rhs) & noexcept -> DecoderConfig& { mOrder = rhs.mOrder; @@ -307,7 +317,7 @@ void InitDistanceComp(al::Device *const device, std::span const c for(auto chidx = 0_uz;chidx < channels.size();++chidx) { const auto ch = channels[chidx]; - const auto idx = usize{device->RealOut.ChannelIndex[ch].c_val}; + const auto idx = device->RealOut.ChannelIndex[ch].as().c_val; if(idx == InvalidChannelIndex) continue; @@ -388,9 +398,9 @@ auto MakeDecoderView(al::Device const *const device, AmbDecConf const *const con { auto ret = DecoderView{}; - decoder.mOrder = (conf->ChanMask > Ambi3OrderMask) ? u8::make_from(4) : (conf->ChanMask > Ambi2OrderMask) - ? u8::make_from(3) : (conf->ChanMask > Ambi1OrderMask) - ? u8::make_from(2) : u8::make_from(1); + decoder.mOrder = (conf->ChanMask > Ambi3OrderMask) ? 4_u8 : + (conf->ChanMask > Ambi2OrderMask) ? 3_u8 : + (conf->ChanMask > Ambi1OrderMask) ? 2_u8 : 1_u8; decoder.m3DMode = (conf->ChanMask&AmbiPeriphonicMask) ? Periphonic : Pantaphonic; switch(conf->CoeffScale) @@ -751,14 +761,15 @@ auto InitPanning(al::Device *const device, bool const hqdec=false, bool const st } } - const auto ambicount = usize{(decoder.m3DMode == Periphonic) - ? AmbiChannelsFromOrder(decoder.mOrder.c_val) : Ambi2DChannelsFromOrder(decoder.mOrder.c_val)}; + const auto ambicount = (decoder.m3DMode == Periphonic) + ? AmbiChannelsFromOrder(decoder.mOrder.c_val) + : Ambi2DChannelsFromOrder(decoder.mOrder.c_val); const auto dual_band = hqdec && !decoder.mCoeffsLF.empty(); auto chancoeffs = std::vector{}; auto chancoeffslf = std::vector{}; for(const auto i : std::views::iota(0_uz, decoder.mChannels.size())) { - const auto idx = usize{device->RealOut.ChannelIndex[decoder.mChannels[i]].c_val}; + const auto idx = device->RealOut.ChannelIndex[decoder.mChannels[i]].as().c_val; if(idx == InvalidChannelIndex) { ERR("Failed to find {} channel in device", @@ -803,7 +814,7 @@ auto InitPanning(al::Device *const device, bool const hqdec=false, bool const st /* Only enable the stablizer if the decoder does not output to the * front-center channel. */ - const auto cidx = usize{device->RealOut.ChannelIndex[FrontCenter].c_val}; + const auto cidx = device->RealOut.ChannelIndex[FrontCenter].as().c_val; auto hasfc = false; if(cidx < chancoeffs.size()) { @@ -1297,7 +1308,7 @@ void aluInitRenderer(al::Device *const device, int const hrtf_id, * the device is headphones, try to enable it. */ if(stereomode.value_or(StereoEncoding::Default) == StereoEncoding::Hrtf - || (!stereomode && device->Flags.test(DirectEar))) + || (!stereomode && device->mFlags.test(DeviceFlag::DirectEar))) { if(device->mHrtfList.empty()) device->enumerateHrtfs(); @@ -1368,10 +1379,10 @@ void aluInitRenderer(al::Device *const device, int const hrtf_id, std::tie(proc, ftype) = init_encoder(UhjEncoderIIR::Tag{}); break; case UhjQualityType::FIR256: - std::tie(proc, ftype) = init_encoder(UhjEncoder::Tag{}); + std::tie(proc, ftype) = init_encoder(UhjEncoder256::Tag{}); break; case UhjQualityType::FIR512: - std::tie(proc, ftype) = init_encoder(UhjEncoder::Tag{}); + std::tie(proc, ftype) = init_encoder(UhjEncoder512::Tag{}); break; } Ensures(proc != nullptr); @@ -1391,10 +1402,10 @@ void aluInitRenderer(al::Device *const device, int const hrtf_id, std::tie(proc, ftype) = init_encoder(TsmeEncoderIIR::Tag{}); break; case TsmeQualityType::FIR256: - std::tie(proc, ftype) = init_encoder(TsmeEncoder::Tag{}); + std::tie(proc, ftype) = init_encoder(TsmeEncoder256::Tag{}); break; case TsmeQualityType::FIR512: - std::tie(proc, ftype) = init_encoder(TsmeEncoder::Tag{}); + std::tie(proc, ftype) = init_encoder(TsmeEncoder512::Tag{}); break; } Ensures(proc != nullptr); diff --git a/3rdparty/openal/cmake/bin2h.script.cmake b/3rdparty/openal/cmake/bin2h.script.cmake index ecf487dd5db5..92943f597bd0 100644 --- a/3rdparty/openal/cmake/bin2h.script.cmake +++ b/3rdparty/openal/cmake/bin2h.script.cmake @@ -9,4 +9,7 @@ file(READ "${INPUT_FILE}" indata HEX) string(REGEX REPLACE "(..)" " static_cast\(0x\\1\),\n" output "${indata}") # Write the list of hex chars to the output file -file(WRITE "${OUTPUT_FILE}" "${output}") +file(WRITE "${OUTPUT_FILE}" "#pragma once + +char ${VARNAME}[] = { +${output}};") diff --git a/3rdparty/openal/common/alcomplex.cpp b/3rdparty/openal/common/alcomplex.cpp index 9031ae885592..c7ae3f7b6bdf 100644 --- a/3rdparty/openal/common/alcomplex.cpp +++ b/3rdparty/openal/common/alcomplex.cpp @@ -9,7 +9,7 @@ #include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "gsl/gsl" @@ -19,7 +19,7 @@ using u16x2 = std::array; using complex_d = std::complex; [[nodiscard]] -constexpr auto BitReverseCounter(usize const log2_size) noexcept -> usize +constexpr auto BitReverseCounter(std::size_t const log2_size) noexcept -> std::size_t { /* Some magic math that calculates the number of swaps needed for a * sequence of bit-reversed indices when index < reversed_index. @@ -28,7 +28,7 @@ constexpr auto BitReverseCounter(usize const log2_size) noexcept -> usize } -template +template struct BitReverser { static_assert(N <= sizeof(u16)*8, "Too many bits for the bit-reversal table."); @@ -52,8 +52,8 @@ struct BitReverser { if(idx < revidx) { - mData[ret_i][0] = u16::make_from(idx); - mData[ret_i][1] = u16::make_from(revidx); + mData[ret_i][0] = u16::from(idx); + mData[ret_i][1] = u16::from(revidx); ++ret_i; } } @@ -113,7 +113,7 @@ void complex_fft(std::span> const buffer, double const sign /* Get the number of bits used for indexing. Simplifies bit-reversal and * the main loop count. */ - if(auto const log2_size = gsl::narrow_cast(std::countr_zero(fftsize)); + if(auto const log2_size = gsl::narrow_cast(std::countr_zero(fftsize)); log2_size < gBitReverses.size()) [[likely]] { for(auto &rev : gBitReverses[log2_size]) diff --git a/3rdparty/openal/common/alformattypes.cppm b/3rdparty/openal/common/alformattypes.cppm new file mode 100644 index 000000000000..82f2b3b4bf5c --- /dev/null +++ b/3rdparty/openal/common/alformattypes.cppm @@ -0,0 +1,33 @@ +module; + +#include "alformat.hpp" +#include "altypes.hpp" + +export module format.types; + +namespace al { + +template +struct strict_formatter : formatter { + using fmttype_t = typename SelfType::fmttype_t; + + auto format(SelfType const &obj, auto& ctx) const + { return formatter::format(al::convert_to(obj.c_val), ctx); } +}; + +} + +export { + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; + template struct al::formatter : al::strict_formatter { }; +} diff --git a/3rdparty/openal/common/alformattypes.hpp b/3rdparty/openal/common/alformattypes.hpp new file mode 100644 index 000000000000..719102647d87 --- /dev/null +++ b/3rdparty/openal/common/alformattypes.hpp @@ -0,0 +1,32 @@ +#ifndef AL_FORMATTYPES_HPP +#define AL_FORMATTYPES_HPP + +#include "alformat.hpp" +#include "altypes.hpp" + +namespace al { + +template +struct strict_formatter : formatter { + using fmttype_t = typename SelfType::fmttype_t; + + auto format(SelfType const &obj, auto& ctx) const + { return formatter::format(al::convert_to(obj.c_val), ctx); } +}; + +} + +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; +template struct al::formatter : al::strict_formatter { }; + +#endif /* AL_FORMATTYPES_HPP */ diff --git a/3rdparty/openal/common/alnumeric.h b/3rdparty/openal/common/alnumeric.h index 9a26a4a002f7..39c5f261869d 100644 --- a/3rdparty/openal/common/alnumeric.h +++ b/3rdparty/openal/common/alnumeric.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -20,7 +19,6 @@ #include #endif -#include "altypes.hpp" #include "gsl/gsl" #include "opthelpers.h" @@ -28,8 +26,8 @@ namespace al { #if HAS_BUILTIN(__builtin_add_overflow) -template [[nodiscard]] -constexpr auto add_sat(T const lhs, T const rhs) noexcept -> T +template [[nodiscard]] constexpr +auto add_sat(T const lhs, T const rhs) noexcept -> T { T res; if(!__builtin_add_overflow(lhs, rhs, &res)) @@ -69,12 +67,12 @@ constexpr auto add_sat(T lhs, T rhs) noexcept -> T } #endif -template [[nodiscard]] -constexpr auto saturate_cast(T val) noexcept -> R +template [[nodiscard]] constexpr +auto saturate_cast(T val) noexcept -> R { if constexpr(std::numeric_limits::digits < std::numeric_limits::digits) { - if constexpr(std::is_signed_v && std::is_signed_v) + if constexpr(std::signed_integral && std::signed_integral) { if(val < std::numeric_limits::min()) return std::numeric_limits::min(); @@ -82,7 +80,7 @@ constexpr auto saturate_cast(T val) noexcept -> R if(val > T{std::numeric_limits::max()}) return std::numeric_limits::max(); } - if constexpr(std::is_unsigned_v && std::is_signed_v) + if constexpr(std::unsigned_integral && std::signed_integral) { if(val < 0) return R{0}; @@ -93,27 +91,17 @@ constexpr auto saturate_cast(T val) noexcept -> R } /* namespace al */ -template requires (sizeof(R) == 2) [[nodiscard]] -constexpr auto bit_pack(std::byte const hi, std::byte const lo) noexcept -> R -{ - using unsigned_t = std::make_unsigned_t; - auto ret = static_cast((to_integer(hi)<<8) - | to_integer(lo)); - return std::bit_cast(ret); -} - - -template [[nodiscard]] -constexpr auto as_unsigned(T value) noexcept +template [[nodiscard]] constexpr +auto as_unsigned(T value) noexcept { return static_cast>(value); } -template [[nodiscard]] -constexpr auto as_signed(T value) noexcept +template [[nodiscard]] constexpr +auto as_signed(T value) noexcept { return static_cast>(value); } -[[nodiscard]] -constexpr auto GetCounterSuffix(usize const count) noexcept -> std::string_view +[[nodiscard]] constexpr +auto GetCounterSuffix(std::size_t const count) noexcept -> std::string_view { using namespace std::string_view_literals; return (((count%100)/10) == 1) ? "th"sv : @@ -123,14 +111,14 @@ constexpr auto GetCounterSuffix(usize const count) noexcept -> std::string_view } -[[nodiscard]] -constexpr auto lerpf(float const val1, float const val2, float const mu) noexcept -> float +[[nodiscard]] constexpr +auto lerpf(float const val1, float const val2, float const mu) noexcept -> float { return val1 + (val2-val1)*mu; } /** Find the next power-of-2 for non-power-of-2 numbers. */ -[[nodiscard]] -constexpr auto NextPowerOf2(unsigned value) noexcept -> unsigned +[[nodiscard]] constexpr +auto NextPowerOf2(unsigned value) noexcept -> unsigned { if(value > 0) { @@ -148,16 +136,16 @@ constexpr auto NextPowerOf2(unsigned value) noexcept -> unsigned * If the value is not already a multiple of r, round toward zero to the next * multiple. */ -template [[nodiscard]] -constexpr auto RoundToZero(T value, std::type_identity_t r) noexcept -> T +template [[nodiscard]] constexpr +auto RoundToZero(T value, std::type_identity_t r) noexcept -> T { return value - (value%r); } /** * If the value is not already a multiple of r, round away from zero to the * next multiple. */ -template [[nodiscard]] -constexpr auto RoundFromZero(T value, std::type_identity_t r) noexcept -> T +template [[nodiscard]] constexpr +auto RoundFromZero(T value, std::type_identity_t r) noexcept -> T { if(value >= 0) return RoundToZero(value + r-1, r); @@ -171,8 +159,8 @@ constexpr auto RoundFromZero(T value, std::type_identity_t r) noexcept -> T * change it on its own threads. On some systems, a truncating conversion may * always be the fastest method. */ -[[nodiscard]] -inline auto fastf2i(float const f) noexcept -> int +[[nodiscard]] inline +auto fastf2i(float const f) noexcept -> int { #if HAVE_SSE_INTRINSICS return _mm_cvt_ss2si(_mm_set_ss(f)); @@ -196,16 +184,16 @@ inline auto fastf2i(float const f) noexcept -> int return gsl::narrow_cast(f); #endif } -[[nodiscard]] -inline auto fastf2u(float const f) noexcept -> unsigned +[[nodiscard]] inline +auto fastf2u(float const f) noexcept -> unsigned { return gsl::narrow_cast(fastf2i(f)); } /** * Converts float-to-int using standard behavior (truncation). Out of range * values are clamped. */ -[[nodiscard]] -inline auto float2int(float const f) noexcept -> int +[[nodiscard]] constexpr +auto float2int(float const f) noexcept -> int { /* We can't rely on SSE or the compiler generated conversion if we want * clamping behavior with overflow and underflow. @@ -231,8 +219,8 @@ inline auto float2int(float const f) noexcept -> int * Converts float-to-uint using standard behavior (truncation). Out of range * values are clamped. */ -[[nodiscard]] -inline auto float2uint(float const f) noexcept -> unsigned +[[nodiscard]] constexpr +auto float2uint(float const f) noexcept -> unsigned { const auto conv_i = std::bit_cast(f); @@ -256,8 +244,8 @@ inline auto float2uint(float const f) noexcept -> unsigned * rounding mode. This is essentially an inlined version of rintf, although * makes fewer promises (e.g. -0 or -0.25 rounded to 0 may result in +0). */ -[[nodiscard]] -inline auto fast_roundf(float f) noexcept -> float +[[nodiscard]] inline +auto fast_roundf(float f) noexcept -> float { #if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) \ && !defined(__SSE_MATH__) @@ -314,8 +302,8 @@ inline auto fast_roundf(float f) noexcept -> float // Converts level (mB) to gain. -[[nodiscard]] -inline auto level_mb_to_gain(float const x) -> float +[[nodiscard]] constexpr +auto level_mb_to_gain(float const x) -> float { if(x <= -10'000.0f) return 0.0f; @@ -323,8 +311,8 @@ inline auto level_mb_to_gain(float const x) -> float } // Converts gain to level (mB). -[[nodiscard]] -inline auto gain_to_level_mb(float const x) -> float +[[nodiscard]] constexpr +auto gain_to_level_mb(float const x) -> float { if(x <= 1e-05f) return -10'000.0f; diff --git a/3rdparty/openal/common/altypes.cpp b/3rdparty/openal/common/altypes.cpp new file mode 100644 index 000000000000..29448ff746e9 --- /dev/null +++ b/3rdparty/openal/common/altypes.cpp @@ -0,0 +1,31 @@ + +#include "altypes.hpp" +#include "alformat.hpp" + +namespace al { + +[[noreturn]] +auto throw_narrowing_error(std::string_view const prefix, long long const value, + std::string_view const type) -> void +{ + throw narrowing_error{al::format("{}: {} narrowed converting to type {}", prefix, value, + type)}; +} + +[[noreturn]] +auto throw_narrowing_error(std::string_view const prefix, unsigned long long const value, + std::string_view const type) -> void +{ + throw narrowing_error{al::format("{}: {} narrowed converting to type {}", prefix, value, + type)}; +} + +[[noreturn]] +auto throw_narrowing_error(std::string_view const prefix, long double const value, + std::string_view const type) -> void +{ + throw narrowing_error{al::format("{}: {} narrowed converting to type {}", prefix, value, + type)}; +} + +} /* namespace al */ diff --git a/3rdparty/openal/common/altypes.hpp b/3rdparty/openal/common/altypes.hpp index ae6e44c325ee..8cfbb5da6f27 100644 --- a/3rdparty/openal/common/altypes.hpp +++ b/3rdparty/openal/common/altypes.hpp @@ -1,101 +1,202 @@ #ifndef AL_TYPES_HPP #define AL_TYPES_HPP +#include #include #include #include #include #include +#include #include +#include #include -#include "alformat.hpp" -#include "altypes.hpp" #include "opthelpers.h" -#include "gsl/gsl" +struct i8; +struct u8; +struct i16; +struct u16; +struct i32; +struct u32; +struct i64; +struct u64; +struct f32; +struct f64; +struct isize; +struct usize; + +namespace al { + +struct narrowing_error : std::runtime_error { + using std::runtime_error::runtime_error; +}; + +[[noreturn]] +auto throw_narrowing_error(std::string_view prefix, long long value, std::string_view type) + -> void; +[[noreturn]] +auto throw_narrowing_error(std::string_view prefix, unsigned long long value, + std::string_view type) -> void; +[[noreturn]] +auto throw_narrowing_error(std::string_view prefix, long double value, std::string_view type) + -> void; + + +template +concept dependent_false = false; + +template [[nodiscard]] consteval +auto get_type_name() -> std::string_view +{ + using namespace std::string_view_literals; + if constexpr(std::same_as) + return "int8_t"sv; + else if constexpr(std::same_as) + return "uint8_t"sv; + else if constexpr(std::same_as) + return "int16_t"sv; + else if constexpr(std::same_as) + return "uint16_t"sv; + else if constexpr(std::same_as) + return "int32_t"sv; + else if constexpr(std::same_as) + return "uint32_t"sv; + else if constexpr(std::same_as) + return "int64_t"sv; + else if constexpr(std::same_as) + return "uint64_t"sv; + else if constexpr(std::same_as) + return "float"sv; + else if constexpr(std::same_as) + return "double"sv; + /* In case some built-in types aren't aliased to the above: */ + else if constexpr(std::same_as) + return "short"sv; + else if constexpr(std::same_as) + return "unsigned short"sv; + else if constexpr(std::same_as) + return "int"sv; + else if constexpr(std::same_as) + return "unsigned int"sv; + else if constexpr(std::same_as) + return "long"sv; + else if constexpr(std::same_as) + return "unsigned long"sv; + else if constexpr(std::same_as) + return "long long"sv; + else if constexpr(std::same_as) + return "unsigned long long"sv; + else + { + static_assert(dependent_false, "Unexpected type"); + return ""sv; + } +} + +template +struct make_strict { }; + +template<> struct make_strict { using type = i8; }; +template<> struct make_strict { using type = u8; }; +template<> struct make_strict { using type = i16; }; +template<> struct make_strict { using type = u16; }; +template<> struct make_strict { using type = i32; }; +template<> struct make_strict { using type = u32; }; +template<> struct make_strict { using type = i64; }; +template<> struct make_strict { using type = u64; }; +template<> struct make_strict { using type = f32; }; +template<> struct make_strict { using type = f64; }; + +template +using make_strict_t = typename make_strict::type; + +} /* namespace al */ + +using sys_int = al::make_strict_t; +using sys_uint = al::make_strict_t; + namespace al { /* A "weak number" is a standard number type. They are prone to implicit - * conversions, unexpected type promotions, and signedness mismatches + * conversions, unexpected type promotions, and signedness mismatches, * producing unexpected results. */ template concept weak_number = std::integral or std::floating_point; -/* Unlike standard C++, this considers integers to larger floating point types - * to be non-narrowing, e.g. int16 -> float(32) and int32 -> double(64) are - * fine since all platforms we currently care about won't lose precision. - */ -template -concept might_narrow = sizeof(T) < sizeof(U) - or (std::unsigned_integral and std::signed_integral) - or (std::integral and std::floating_point) - or (sizeof(T) == sizeof(U) - and ((std::signed_integral and std::unsigned_integral) - or (std::floating_point and std::integral))); +/* Determine if a number of type From can't narrow when converted to type To. */ +template +concept not_narrowing = std::same_as + or (std::numeric_limits::digits <= std::numeric_limits::digits + and not (std::floating_point and std::integral) + and not (std::signed_integral and std::unsigned_integral)); template -concept has_common = not might_narrow or not might_narrow; +concept has_common = not_narrowing or not_narrowing; -template [[nodiscard]] constexpr -auto convert_to(U const &value) noexcept(not might_narrow) -> T +template [[nodiscard]] constexpr +auto convert_to(From const &value) noexcept(not_narrowing) -> To { - if constexpr(not might_narrow) - return static_cast(value); + if constexpr(not_narrowing) + return static_cast(value); else { - if constexpr(std::signed_integral and std::unsigned_integral) + using cast_type = std::conditional_t, long double, + std::conditional_t, unsigned long long, long long>>; + + if constexpr(std::signed_integral and std::unsigned_integral) { - if(U{std::numeric_limits::max()} < value) - throw std::out_of_range{"Too large unsigned to signed"}; + if(From{std::numeric_limits::max()} < value) + throw_narrowing_error("convert_to", cast_type{value}, get_type_name()); } - else if constexpr(std::unsigned_integral and std::signed_integral) + else if constexpr(std::unsigned_integral and std::signed_integral) { - if(value < U{0}) - throw std::out_of_range{"Negative signed to unsigned"}; + if(value < From{0}) + throw_narrowing_error("convert_to", cast_type{value}, get_type_name()); } - auto const ret = static_cast(value); - if(static_cast(ret) != value) - throw std::out_of_range{"Conversion narrowed"}; + auto const ret = static_cast(value); + if(static_cast(ret) != value) + throw_narrowing_error("convert_to", cast_type{value}, get_type_name()); return ret; } } -/* A "strong number" is a numeric type derived from the number class below. It +/* A "strict number" is a numeric type derived from the number class below. It * has stronger protections from implicit conversions and automatic type * promotions. */ template -concept strong_number = requires { T::is_strong_number_type; } +concept strict_number = requires { T::is_strict_number_type; } and std::derived_from; template -concept strong_integral = strong_number and std::integral; +concept strict_integral = strict_number and std::integral; template -concept strong_signed_integral = strong_number and std::signed_integral; +concept strict_signed_integral = strict_number and std::signed_integral; template -concept strong_unsigned_integral = strong_number +concept strict_unsigned_integral = strict_number and std::unsigned_integral; template -concept strong_floating_point = strong_number and std::floating_point; +concept strict_floating_point = strict_number and std::floating_point; /* Determines whether a weak number of type T can be used for an operation on a - * strong number's underlying type U. This is intended to restrict otherwise + * strict number's underlying type U. This is intended to restrict otherwise * valid numeric constants that could be confusing. For example: * * auto var = u8{...}; * auto var_doubled = var * 2; * - * Here 2 is a "weak" int, which is required to convert to a "strong" u8. This + * Here 2 is a "weak" int, which is required to convert to a "strict" u8. This * would be a narrowing conversion (usually), but 2 is a constant value that * can be represented in an u8. This effectively results in: * @@ -106,7 +207,7 @@ concept strong_floating_point = strong_number and std::floating_point and std::floating_point -concept compatible_constant = (std::integral and std::integral) - or (std::floating_point and (std::integral or sizeof(U) >= sizeof(T))); +template +concept compatible_constant = (std::integral and std::integral) + or (std::floating_point + and (std::integral or sizeof(ConstType) <= sizeof(VarType))); + + +/* Models a weak number type that can be converted to the given strict number + * type without narrowing. + */ +template +concept compatible_weak_number = weak_number and strict_number + and not_narrowing; /* This ConstantNum class is a wrapper to handle various operations with @@ -142,31 +252,22 @@ struct ConstantNum { }; -struct UInt; - - namespace detail_ { template struct signed_difference { using type = void; }; -template requires(std::integral) +template struct signed_difference { using type = std::make_signed_t; }; } -/* Strong numbers are implemented using CRTP to act as a mixin of sorts. */ +/* Strict numbers are implemented using CRTP to act as a mixin of sorts. */ template - requires(not std::is_const_v and not std::is_volatile_v) class number_base { - friend SelfType; + static_assert(not std::is_const_v and not std::is_volatile_v); - /* Force printing smaller types as (unsigned) int. Always treat these as - * numeric values even when backed by character types. - */ - using fmttype_t = std::conditional_t, unsigned, - std::conditional_t, int, - ValueType>>; + friend SelfType; /* Defaulted constructor/destructor/copy assignment functions, which will be * inherited by the parent type. Allows the type to be trivial. @@ -178,7 +279,7 @@ class number_base { auto operator=(number_base const &rhs) & noexcept LIFETIMEBOUND -> number_base& = default; public: - static constexpr auto is_strong_number_type = true; + static constexpr auto is_strict_number_type = true; using value_t = ValueType; using self_t = SelfType; @@ -201,8 +302,8 @@ class number_base { * integer *with a width larger than any standard integer type*. * * Here, we define a difference_type type that is the standard signed - * integral type this strong number models, which satisfies the definition. - * Although subtracting two strong numbers does not result in this type, + * integral type this strict number models, which satisfies the definition. + * Although subtracting two strict numbers does not result in this type, * and I don't know of any standard mechanism to generate or apply this * difference type from/to the incrementable object(s). That makes it feel * like we follow the technical requirements but not the intended @@ -224,11 +325,19 @@ class number_base { */ using difference_type = typename detail_::signed_difference::type; + /* Force printing smaller types as (unsigned) int. Always treat these as + * numeric values even when backed by character types. + */ + using fmttype_t = std::conditional_t, unsigned, + std::conditional_t, int, + ValueType>>; + + ValueType c_val; /* Implicit constructor from non-narrowing weak number types. */ - template requires(not might_narrow) force_inline constexpr - explicit(false) number_base(U const &value) noexcept : c_val{convert_to(value)} { } + template requires(not_narrowing) force_inline constexpr + explicit(false) number_base(U const &value) noexcept : c_val{static_cast(value)} { } /* Implicit constructor from narrowing weak number types. Required to be * compile-time so the provided value can be checked for narrowing. @@ -237,7 +346,9 @@ class number_base { number_base(ConstantNum const &value) noexcept : c_val{value.c_val} { } template force_inline static constexpr - auto make_from(U const &value) noexcept(not might_narrow) -> SelfType + auto from(U const &value) + noexcept(not_narrowing or std::floating_point) + -> SelfType { /* Converting to a floating point type isn't checked here because it's * nearly impossible to otherwise ensure a large enough integer or @@ -251,6 +362,12 @@ class number_base { return SelfType{convert_to(value)}; } + [[nodiscard]] force_inline static constexpr + auto bit_pack(std::byte const value) noexcept -> SelfType requires(sizeof(value_t) == 1) + { + return std::bit_cast(value); + } + [[nodiscard]] force_inline static constexpr auto bit_pack(std::byte const hi, std::byte const lo) noexcept -> SelfType requires(sizeof(value_t) == 2) @@ -260,12 +377,35 @@ class number_base { return std::bit_cast(ret); } - /* Conversion operator to other strong number types. Only valid for + [[nodiscard]] force_inline static constexpr + auto bit_pack(std::byte const hi, std::byte const midhi, std::byte const midlo, + std::byte const lo) noexcept -> SelfType requires(sizeof(value_t) == 4) + { + auto const ret = (to_integer(hi)<<24) + | (to_integer(midhi)<<16) | (to_integer(midlo)<<8) + | to_integer(lo); + return std::bit_cast(ret); + } + + [[nodiscard]] force_inline static constexpr + auto bit_pack(std::byte const hi, std::byte const mid6, std::byte const mid5, + std::byte const mid4, std::byte const mid3, std::byte const mid2, std::byte const mid1, + std::byte const lo) noexcept -> SelfType requires(sizeof(value_t) == 8) + { + auto const ret = (to_integer(hi)<<56) + | (to_integer(mid6)<<48) | (to_integer(mid5)<<40) + | (to_integer(mid4)<<32) | (to_integer(mid3)<<24) + | (to_integer(mid2)<<16) | (to_integer(mid1)<<8) + | to_integer(lo); + return std::bit_cast(ret); + } + + /* Conversion operator to other strict number types. Only valid for * non-narrowing conversions. */ - template requires(not might_narrow) + template requires(not_narrowing) force_inline constexpr explicit - operator U() noexcept { return U{convert_to(c_val)}; } + operator U() noexcept { return U{static_cast(c_val)}; } template U> [[nodiscard]] force_inline constexpr explicit operator U() noexcept { return static_cast(c_val); } @@ -273,26 +413,29 @@ class number_base { [[nodiscard]] force_inline constexpr explicit operator bool() noexcept requires(std::integral) { return c_val != ValueType{0}; } - /* Non-narrowing conversion method. */ - template requires(not might_narrow) + /* .as() is a non-narrowing conversion method. Non-narrowing type + * conversions are simply cast to the target type, while potentially + * narrowing conversions are checked at compile-time and will cause a + * compilation failure if the value is either not known at compile-time, or + * can't fit the target type. + */ + template requires(not_narrowing) [[nodiscard]] force_inline constexpr - auto as() const noexcept -> U { return U{convert_to(c_val)}; } + auto as() const noexcept -> U { return U{static_cast(c_val)}; } - template [[nodiscard]] consteval + template [[nodiscard]] consteval auto as() const noexcept -> U { return U{convert_to(c_val)}; } - /* Potentially narrowing conversion method. Throws if the converted value - * narrows. + /* Potentially narrowing conversion method. Throws a narrowing_error + * exception if the converted value narrows. */ - template [[nodiscard]] force_inline constexpr + template [[nodiscard]] force_inline constexpr auto cast_to() const - noexcept(not might_narrow + noexcept(not_narrowing or std::floating_point) -> U { - /* Like make_from, converting to a floating point type isn't checked - * here. - */ + /* Like from(), converting to a floating point type isn't checked here. */ if constexpr(std::floating_point) return U{static_cast(c_val)}; else @@ -300,23 +443,23 @@ class number_base { } /* "Raw" conversion method, essentially applying a static_cast to the - * underlying type. + * underlying type without checking for narrowing. */ - template [[nodiscard]] force_inline constexpr + template [[nodiscard]] force_inline constexpr auto reinterpret_as() const noexcept -> U { return U{static_cast(c_val)}; } /* Saturating cast, applying a standard cast except out of range source * values are clamped to the output range. */ - template [[nodiscard]] constexpr + template [[nodiscard]] constexpr auto saturate_as() const noexcept -> U { - if constexpr(strong_integral) + if constexpr(strict_integral) { if constexpr(std::floating_point) { - if constexpr(strong_signed_integral) + if constexpr(strict_unsigned_integral) { /* fp -> unsigned integral */ if(signbit()) @@ -338,7 +481,7 @@ class number_base { /* integral -> integral */ if constexpr(U::digits < std::numeric_limits::digits) { - if constexpr(strong_signed_integral and std::signed_integral) + if constexpr(strict_signed_integral and std::signed_integral) { if(c_val < U::min().template as().c_val) return U::min(); @@ -346,7 +489,7 @@ class number_base { if(c_val > U::max().template as().c_val) return U::max(); } - if constexpr(strong_signed_integral and std::signed_integral) + if constexpr(strict_unsigned_integral and std::signed_integral) { if(c_val < 0) return U{0}; @@ -362,9 +505,11 @@ class number_base { } [[nodiscard]] force_inline constexpr - auto popcount() const noexcept -> UInt requires(std::integral); + auto popcount() const noexcept -> sys_uint requires(std::integral); + [[nodiscard]] force_inline constexpr + auto countl_zero() const noexcept -> sys_uint requires(std::integral); [[nodiscard]] force_inline constexpr - auto countr_zero() const noexcept -> UInt requires(std::integral); + auto countr_zero() const noexcept -> sys_uint requires(std::integral); [[nodiscard]] force_inline constexpr auto abs() const noexcept -> SelfType { return SelfType{std::abs(c_val)}; } @@ -476,7 +621,7 @@ class number_base { * skipping whole numbers (where nexttoward(x, 0) == x-1 and * nexttoward(x, inf) == x+2). */ - template [[nodiscard]] static consteval + template [[nodiscard]] static consteval auto fplimit() noexcept -> R { constexpr auto halflimit = std::uint64_t{1} << (digits-1); @@ -484,15 +629,6 @@ class number_base { static_assert(res < R::infinity().c_val); return R{res}; } - - template - struct formatter : al::formatter { - auto format(SelfType const &obj, auto& ctx) const - { - return al::formatter::format(al::convert_to(obj.c_val), - ctx); - } - }; }; } /* namespace al */ @@ -500,10 +636,10 @@ class number_base { /* Prefix and postfix increment and decrement operators. Only valid for * integral types. */ -template force_inline constexpr +template force_inline constexpr auto operator++(T &self LIFETIMEBOUND) noexcept -> T& { ++self.c_val; return self; } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator++(T &self, int) noexcept -> T { auto const old = self; @@ -511,10 +647,10 @@ auto operator++(T &self, int) noexcept -> T return old; } -template force_inline constexpr +template force_inline constexpr auto operator--(T &self LIFETIMEBOUND) noexcept -> T& { --self.c_val; return self; } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator--(T &self, int) noexcept -> T { auto const old = self; @@ -525,44 +661,56 @@ auto operator--(T &self, int) noexcept -> T /* No automatic type promotion for our unary ops. Unary - is only valid for * signed types. */ -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator+(T const &value) noexcept -> T { return value; } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator-(T const &value) noexcept -> T { static_assert(std::is_signed_v, "Unary operator- is only valid for signed types"); return T{static_cast(-value.c_val)}; } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator~(T const &value) noexcept -> T { return T{static_cast(~value.c_val)}; } /* Our binary ops only promote to the larger of the two operands, when the * conversion can't narrow (e.g. i8 + i16 = i16, while u32 + i16 = error). - * If one operand is a constant, it must fit the type of the other operand, and - * the result won't be promoted. + * If one operand is a weak number type, it must be convertible to the other + * operand's type without narrowing. If one operand is a constant, the value + * must fit the other operand's type, and the result won't be promoted. */ #define DECL_BINARY(op) \ -template [[nodiscard]] force_inline \ +template [[nodiscard]] force_inline \ constexpr auto operator op(T const &lhs, U const &rhs) noexcept \ { \ static_assert(al::has_common, \ "Incompatible operands"); \ - if constexpr(not al::might_narrow) \ + if constexpr(al::not_narrowing) \ return T{static_cast(lhs.c_val op rhs.c_val)}; \ - else if constexpr(not al::might_narrow) \ + else if constexpr(al::not_narrowing) \ return U{static_cast(lhs.c_val op rhs.c_val)}; \ else \ return T{}; \ } \ -template [[nodiscard]] force_inline constexpr \ + \ +template [[nodiscard]] force_inline constexpr \ +auto operator op(T const &lhs, al::compatible_weak_number auto const &rhs) \ + noexcept -> T \ +{ return T{static_cast(lhs.c_val op rhs)}; } \ +template [[nodiscard]] force_inline constexpr \ +auto operator op(al::compatible_weak_number auto const &lhs, T const &rhs) \ + noexcept -> T \ +{ return T{static_cast(lhs op rhs.c_val)}; } \ + \ +template [[nodiscard]] force_inline constexpr \ auto operator op(T const &lhs, al::ConstantNum const &rhs) noexcept -> T \ { return T{static_cast(lhs.c_val op rhs.c_val)}; } \ -template [[nodiscard]] force_inline constexpr \ +template [[nodiscard]] force_inline constexpr \ auto operator op(al::ConstantNum const &lhs, T const &rhs) noexcept -> T \ { return T{static_cast(lhs.c_val op rhs.c_val)}; } + DECL_BINARY(+) DECL_BINARY(-) DECL_BINARY(*) @@ -572,64 +720,72 @@ DECL_BINARY(|) DECL_BINARY(&) DECL_BINARY(^) #undef DECL_BINARY -/* Binary ops >> and << between strong number types. Note that the right-side + +/* Binary ops >> and << between strict number types. Note that the right-side * operand type doesn't influence the return type, as this is only modifying - * the left-side operand value. + * the left-side operand value (e.g. 1_u8 << 1_u32 == 2_u8). */ -#define DECL_BINARY(op) \ -template [[nodiscard]] force_inline \ -constexpr auto operator op(T const &lhs, U const &rhs) noexcept -> T \ -{ return T{static_cast(lhs.c_val op rhs.c_val)}; } -DECL_BINARY(>>) -DECL_BINARY(<<) -#undef DECL_BINARY +template [[nodiscard]] force_inline constexpr +auto operator>>(T const &lhs, al::strict_number auto const &rhs) noexcept -> T +{ return T{static_cast(lhs.c_val >> rhs.c_val)}; } -/* Binary ops >> and << between a strong number type and weak integer. +template [[nodiscard]] force_inline constexpr +auto operator<<(T const &lhs, al::strict_number auto const &rhs) noexcept -> T +{ return T{static_cast(lhs.c_val << rhs.c_val)}; } + +/* Binary ops >> and << between a strict number type and weak integer. * Unlike the other operations, these don't require the weak integer to be * constant because the result type is always the same as the left-side * operand. */ -#define DECL_BINARY(op) \ -template [[nodiscard]] force_inline \ -constexpr auto operator op(T const &lhs, U const &rhs) noexcept -> T \ -{ return T{static_cast(lhs.c_val op rhs)}; } -DECL_BINARY(>>) -DECL_BINARY(<<) -#undef DECL_BINARY +template [[nodiscard]] force_inline constexpr +auto operator>>(T const &lhs, std::integral auto const &rhs) noexcept -> T +{ return T{static_cast(lhs.c_val >> rhs)}; } + +template [[nodiscard]] force_inline constexpr +auto operator<<(T const &lhs, std::integral auto const &rhs) noexcept -> T +{ return T{static_cast(lhs.c_val << rhs)}; } -/* Increment/decrement a strong integral using its difference type. */ -template U> [[nodiscard]] - force_inline constexpr -auto operator+(T const &lhs, U const &rhs) noexcept -> T +/* Increment/decrement a strict unsigned integral using its signed difference + * type. + */ +template [[nodiscard]] force_inline constexpr +auto operator+(T const &lhs, std::same_as auto const &rhs) noexcept + -> T { return T{static_cast(lhs.c_val + static_cast(rhs))}; } -template U> [[nodiscard]] - force_inline constexpr -auto operator+(U const &lhs, T const &rhs) noexcept -> T +template [[nodiscard]] force_inline constexpr +auto operator+(std::same_as auto const &lhs, T const &rhs) noexcept + -> T { return T{static_cast(static_cast(lhs) + rhs.c_val)}; } -template U> [[nodiscard]] - force_inline constexpr -auto operator-(T const &lhs, U const &rhs) noexcept -> T +template [[nodiscard]] force_inline constexpr +auto operator-(T const &lhs, std::same_as auto const &rhs) noexcept + -> T { return T{static_cast(lhs.c_val - static_cast(rhs))}; } /* Our binary assignment ops only promote the rhs value to the lhs type when - * the conversion can't lose information, and produces an error otherwise. + * the conversion can't narrow, and produces an error otherwise. */ #define DECL_BINASSIGN(op) \ -template force_inline constexpr \ +template force_inline constexpr \ auto operator op(T &lhs LIFETIMEBOUND, U const &rhs) noexcept -> T& \ { \ - static_assert(not al::might_narrow, \ + static_assert(al::not_narrowing,\ "Incompatible right side operand"); \ lhs.c_val op static_cast(rhs.c_val); \ return lhs; \ } \ -template force_inline constexpr \ -auto operator op(T &lhs LIFETIMEBOUND, al::ConstantNum const &rhs) \ - noexcept -> T& \ +template force_inline constexpr \ +auto operator op(T &lhs LIFETIMEBOUND, \ + al::compatible_weak_number auto const &rhs) noexcept -> T& \ +{ lhs.c_val op rhs; return lhs; } \ +template force_inline constexpr \ +auto operator op(T &lhs LIFETIMEBOUND, \ + al::ConstantNum const &rhs) noexcept -> T& \ { lhs.c_val op rhs.c_val; return lhs; } + DECL_BINASSIGN(+=) DECL_BINASSIGN(-=) DECL_BINASSIGN(*=) @@ -639,41 +795,45 @@ DECL_BINASSIGN(|=) DECL_BINASSIGN(&=) DECL_BINASSIGN(^=) #undef DECL_BINASSIGN + /* Binary assignment ops >>= and <<=. Integer constants for the right side * operand must fit an uint8 type. */ #define DECL_BINASSIGN(op) \ -template force_inline constexpr \ -auto operator op(T &lhs LIFETIMEBOUND, U const &rhs) noexcept -> T& \ +template force_inline constexpr \ +auto operator op(T &lhs LIFETIMEBOUND, \ + al::strict_number auto const &rhs) noexcept -> T& \ { lhs.c_val op rhs.c_val; return lhs; } \ -template force_inline constexpr \ -auto operator op(T &lhs LIFETIMEBOUND, al::ConstantNum const &rhs) \ - noexcept -> T& \ +template force_inline constexpr \ +auto operator op(T &lhs LIFETIMEBOUND, \ + al::ConstantNum const &rhs) noexcept -> T& \ { lhs.c_val op static_cast(rhs.c_val); return lhs; } DECL_BINASSIGN(>>=) DECL_BINASSIGN(<<=) #undef DECL_BINASSIGN -/* Offset a strong integral using its difference type. */ -#define DECL_BINASSIGN(op) \ -template U> \ - force_inline constexpr \ -auto operator op(T &lhs LIFETIMEBOUND, U const &rhs) noexcept -> T& \ -{ lhs.c_val op static_cast(rhs); return lhs; } -DECL_BINASSIGN(+=) -DECL_BINASSIGN(-=) -#undef DECL_BINASSIGN +/* Offset a strict unsigned integral using its signed difference type. */ +template force_inline constexpr +auto operator+=(T &lhs LIFETIMEBOUND, std::same_as auto const &rhs) + noexcept -> T& +{ lhs.c_val += static_cast(rhs); return lhs; } + +template force_inline constexpr +auto operator-=(T &lhs LIFETIMEBOUND, std::same_as auto const &rhs) + noexcept -> T& +{ lhs.c_val -= static_cast(rhs); return lhs; } -/* Three-way comparison operator between strong number types, from which other + +/* Three-way comparison operator between strict number types, from which other * comparison operators are synthesized. Implicitly handles signedness * differences and floating point precision. */ -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator<=>(T const &lhs, U const &rhs) noexcept { - if constexpr(not al::might_narrow) + if constexpr(al::not_narrowing) return lhs.c_val <=> static_cast(rhs.c_val); - else if constexpr(not al::might_narrow) + else if constexpr(al::not_narrowing) return static_cast(lhs.c_val) <=> rhs.c_val; else if constexpr(std::signed_integral and std::unsigned_integral) @@ -724,45 +884,45 @@ auto operator<=>(T const &lhs, U const &rhs) noexcept } } -/* Three-way comparison operator between a strong number type and weak number +/* Three-way comparison operator between a strict number type and weak number * type, from which other comparison operators are synthesized. Only valid when * one is compatible with the other. */ -template requires(al::has_common) +template requires(al::has_common) [[nodiscard]] force_inline constexpr auto operator<=>(T const &lhs, U const &rhs) noexcept { - if constexpr(not al::might_narrow) + if constexpr(al::not_narrowing) return lhs.c_val <=> static_cast(rhs); - else if constexpr(not al::might_narrow) + else if constexpr(al::not_narrowing) return static_cast(lhs.c_val) <=> rhs; } -/* Three-way comparison operator between a strong number type and numeric +/* Three-way comparison operator between a strict number type and numeric * constant, from which other comparison operators are synthesized. Only valid - * when the numeric constant fits the strong number type. + * when the numeric constant fits the strict number type. */ -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator<=>(T const &lhs, al::ConstantNum const &rhs) noexcept { return lhs.c_val <=> rhs.c_val; } /* FIXME: Why do I have to define these manually instead of the compiler * implicitly generating them from operator<=> like the others??? */ -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator==(T const &lhs, U const &rhs) noexcept -> bool { return (lhs <=> rhs) == 0; } -template requires(al::has_common) +template requires(al::has_common) [[nodiscard]] force_inline constexpr auto operator==(T const &lhs, U const &rhs) noexcept -> bool { return (lhs <=> rhs) == 0; } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto operator==(T const &lhs, al::ConstantNum const &rhs) noexcept -> bool { return (lhs <=> rhs) == 0; } #define DECL_NUMBERTYPE(SelfType, ValueType) \ -struct SelfType : al::number_base { \ +struct [[nodiscard]] SelfType : al::number_base { \ using number_base::number_base; \ \ constexpr SelfType() noexcept = default; \ @@ -773,9 +933,9 @@ struct SelfType : al::number_base { \ auto operator=(SelfType const &rhs) & noexcept LIFETIMEBOUND \ -> SelfType& = default; \ \ - template \ + template \ requires(not std::is_base_of_v \ - and not al::might_narrow) \ + and al::not_narrowing) \ force_inline constexpr \ auto operator=(U const &rhs) & noexcept LIFETIMEBOUND -> SelfType& \ { \ @@ -783,7 +943,7 @@ struct SelfType : al::number_base { \ return *this; \ } \ \ - template requires(not al::might_narrow) \ + template requires(al::not_narrowing) \ force_inline constexpr \ auto operator=(U const &rhs) & noexcept LIFETIMEBOUND -> SelfType& \ { \ @@ -811,132 +971,215 @@ DECL_NUMBERTYPE(u64, std::uint64_t) DECL_NUMBERTYPE(f32, float) DECL_NUMBERTYPE(f64, double) -using isize = std::make_signed_t; -using usize = std::size_t; +DECL_NUMBERTYPE(isize, std::make_signed_t); +DECL_NUMBERTYPE(usize, std::size_t); +#undef DECL_NUMBERTYPE namespace al { -DECL_NUMBERTYPE(UInt, unsigned) -#undef DECL_NUMBERTYPE +template [[nodiscard]] force_inline +constexpr auto number_base::popcount() const noexcept -> sys_uint + requires(std::integral) +{ + using unsigned_t = std::make_unsigned_t; + return sys_uint{static_cast(std::popcount(static_cast(c_val)))}; +} -template - requires(not std::is_const_v and not std::is_volatile_v) [[nodiscard]] force_inline -constexpr auto number_base::popcount() const noexcept -> UInt - requires(std::integral) +template [[nodiscard]] force_inline +constexpr auto number_base::countl_zero() const noexcept -> sys_uint + requires(std::integral) { - using unsigned_t = std::make_unsigned_t; - return UInt{static_cast(std::popcount(static_cast(c_val)))}; + using unsigned_t = std::make_unsigned_t; + return sys_uint{static_cast(std::countl_zero(static_cast(c_val)))}; } -template - requires(not std::is_const_v and not std::is_volatile_v) [[nodiscard]] force_inline -constexpr auto number_base::countr_zero() const noexcept -> UInt - requires(std::integral) +template [[nodiscard]] force_inline +constexpr auto number_base::countr_zero() const noexcept -> sys_uint + requires(std::integral) { - using unsigned_t = std::make_unsigned_t; - return UInt{static_cast(std::countr_zero(static_cast(c_val)))}; + using unsigned_t = std::make_unsigned_t; + return sys_uint{static_cast(std::countr_zero(static_cast(c_val)))}; } } /* namespace al */ -template struct al::formatter : i8::formatter { }; -template struct al::formatter : u8::formatter { }; -template struct al::formatter : i16::formatter { }; -template struct al::formatter : u16::formatter { }; -template struct al::formatter : i32::formatter { }; -template struct al::formatter : u32::formatter { }; -template struct al::formatter : i64::formatter { }; -template struct al::formatter : u64::formatter { }; -template struct al::formatter : f32::formatter { }; -template struct al::formatter : f64::formatter { }; -template struct al::formatter : al::UInt::formatter { }; [[nodiscard]] consteval -auto operator ""_i8(unsigned long long const n) noexcept { return i8::make_from(n); } +auto operator ""_i8(unsigned long long const n) noexcept { return i8::from(n); } [[nodiscard]] consteval -auto operator ""_u8(unsigned long long const n) noexcept { return u8::make_from(n); } +auto operator ""_u8(unsigned long long const n) noexcept { return u8::from(n); } [[nodiscard]] consteval -auto operator ""_i16(unsigned long long const n) noexcept { return i16::make_from(n); } +auto operator ""_i16(unsigned long long const n) noexcept { return i16::from(n); } [[nodiscard]] consteval -auto operator ""_u16(unsigned long long const n) noexcept { return u16::make_from(n); } +auto operator ""_u16(unsigned long long const n) noexcept { return u16::from(n); } [[nodiscard]] consteval -auto operator ""_i32(unsigned long long const n) noexcept { return i32::make_from(n); } +auto operator ""_i32(unsigned long long const n) noexcept { return i32::from(n); } [[nodiscard]] consteval -auto operator ""_u32(unsigned long long const n) noexcept { return u32::make_from(n); } +auto operator ""_u32(unsigned long long const n) noexcept { return u32::from(n); } [[nodiscard]] consteval -auto operator ""_i64(unsigned long long const n) noexcept { return i64::make_from(n); } +auto operator ""_i64(unsigned long long const n) noexcept { return i64::from(n); } [[nodiscard]] consteval -auto operator ""_u64(unsigned long long const n) noexcept { return u64::make_from(n); } +auto operator ""_u64(unsigned long long const n) noexcept { return u64::from(n); } [[nodiscard]] consteval -auto operator ""_f32(long double const n) noexcept { return f32::make_from(n); } +auto operator ""_f32(long double const n) noexcept { return f32::from(n); } [[nodiscard]] consteval -auto operator ""_f64(long double const n) noexcept { return f64::make_from(n); } +auto operator ""_f64(long double const n) noexcept { return f64::from(n); } [[nodiscard]] consteval -auto operator ""_z(unsigned long long const n) noexcept { return gsl::narrow(n); } +auto operator ""_isize(unsigned long long const n) noexcept { return isize::from(n); } +[[nodiscard]] consteval +auto operator ""_usize(unsigned long long const n) noexcept { return usize::from(n); } + [[nodiscard]] consteval -auto operator ""_uz(unsigned long long const n) noexcept { return gsl::narrow(n); } +auto operator ""_z(unsigned long long const n) noexcept +{ return al::convert_to(n); } [[nodiscard]] consteval -auto operator ""_zu(unsigned long long const n) noexcept { return gsl::narrow(n); } +auto operator ""_uz(unsigned long long const n) noexcept { return al::convert_to(n); } +[[nodiscard]] consteval +auto operator ""_zu(unsigned long long const n) noexcept { return al::convert_to(n); } + +namespace std { -template [[nodiscard]] force_inline constexpr +/* Declare the common type between strict number types, where one fits the + * other. Note that the result must be order invariant, that is, if + * common_type_t results in A, then common_type_t must also result + * in A. Similarly, if common_type_t results in C, then + * common_type_t must also result in C. Consequently, since isize and + * usize may be interconvertible with other types, these base specializations + * will never result in isize or usize. + */ +template + requires(not std::derived_from and not std::derived_from + and al::not_narrowing) +struct common_type { using type = T; }; + +template + requires(not std::derived_from and not std::derived_from + and al::not_narrowing + and not al::not_narrowing) +struct common_type { using type = U; }; + +/* Declare the common type between signed and unsigned strict number types, + * where a larger signed type is needed. + */ +template<> struct common_type { using type = i16; }; +template<> struct common_type { using type = i32; }; +template<> struct common_type { using type = i64; }; +template<> struct common_type { using type = i32; }; +template<> struct common_type { using type = i64; }; +template<> struct common_type { using type = i64; }; + +template<> struct common_type { using type = i16; }; +template<> struct common_type { using type = i32; }; +template<> struct common_type { using type = i64; }; +template<> struct common_type { using type = i32; }; +template<> struct common_type { using type = i64; }; +template<> struct common_type { using type = i64; }; + +/* Declare the common type between equal-sized strict integer and floating + * point types, where a larger floating point type is needed. + */ +template<> struct common_type { using type = f64; }; +template<> struct common_type { using type = f64; }; +template<> struct common_type { using type = f64; }; +template<> struct common_type { using type = f64; }; + +/* Declare the common type between strict integer types where isize or usize is + * the appropriate result type. + */ +template requires(sizeof(T) < sizeof(isize) or std::same_as) +struct common_type { using type = isize; }; +template requires(sizeof(T) < sizeof(isize)) +struct common_type { using type = isize; }; + +template requires(sizeof(T) < sizeof(usize) or std::same_as) +struct common_type { using type = usize; }; +template requires(sizeof(T) < sizeof(usize)) +struct common_type { using type = usize; }; + +/* Declare the common type between a strict and weak number type, ensuring the + * appropriate strict number type is provided. + */ +template +struct common_type : common_type> { }; + +template +struct common_type : common_type, U> { }; + +} /* namespace std */ + + +template [[nodiscard]] force_inline constexpr +auto popcount(T const &x) noexcept -> sys_uint { return x.popcount(); } + +template [[nodiscard]] force_inline constexpr +auto countl_zero(T const &x) noexcept -> sys_uint { return x.countl_zero(); } + +template [[nodiscard]] force_inline constexpr +auto countr_zero(T const &x) noexcept -> sys_uint { return x.countr_zero(); } + +template [[nodiscard]] force_inline constexpr auto abs(T const &x) noexcept -> T { return x.abs(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto ceil(T const &x) noexcept -> T { return x.ceil(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto floor(T const &x) noexcept -> T { return x.floor(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto sqrt(T const &x) noexcept -> T { return x.sqrt(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto cbrt(T const &x) noexcept -> T { return x.cbrt(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto sin(T const &x) noexcept -> T { return x.sin(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto asin(T const &x) noexcept -> T { return x.asin(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto cos(T const &x) noexcept -> T { return x.cos(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto acos(T const &x) noexcept -> T { return x.acos(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto atan2(T const &y, T const &x) noexcept -> T { return T{std::atan2(y.c_val, x.c_val)}; } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto pow(T const &x, T const &y) noexcept -> T { return T{std::pow(x.c_val, y.c_val)}; } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto log(T const &x) noexcept -> T { return x.log(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto log2(T const &x) noexcept -> T { return x.log2(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto log10(T const &x) noexcept -> T { return x.log10(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto exp(T const &x) noexcept -> T { return x.exp(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto exp2(T const &x) noexcept -> T { return x.exp2(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto round(T const &x) noexcept -> T { return x.round(); } -template [[nodiscard]] force_inline constexpr +template [[nodiscard]] force_inline constexpr auto lerp(T const &a, T const &b, T const &t) noexcept -> T { return T{std::lerp(a.c_val, b.c_val, t.c_val)}; } +[[nodiscard]] constexpr +auto lerpf(f32 const val1, f32 const val2, f32 const mu) noexcept -> f32 +{ return val1 + (val2-val1)*mu; } + #endif /* AL_TYPES_HPP */ diff --git a/3rdparty/openal/common/atomic.h b/3rdparty/openal/common/atomic.h index 630547157269..84d2e22e3fd8 100644 --- a/3rdparty/openal/common/atomic.h +++ b/3rdparty/openal/common/atomic.h @@ -2,10 +2,9 @@ #define AL_ATOMIC_H #include -#include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "gsl/gsl" #ifdef __APPLE__ @@ -78,95 +77,110 @@ template auto atomic_wait(std::atomic &aval, T const value, std::memory_order const order = std::memory_order_seq_cst) noexcept -> void { + if constexpr(requires { aval.wait(value, order); }) + aval.wait(value, order); + else + { #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED < 110000 - static_assert(sizeof(aval) == sizeof(T)); + static_assert(sizeof(aval) == sizeof(T)); - if(sizeof(T) == sizeof(std::uint32_t) && __ulock_wait != nullptr) - { - while(aval.load(order) == value) - __ulock_wait(UL_COMPARE_AND_WAIT, &aval, value, 0); - } + if(sizeof(T) == sizeof(std::uint32_t) && __ulock_wait != nullptr) + { + while(aval.load(order) == value) + __ulock_wait(UL_COMPARE_AND_WAIT, &aval, value, 0); + } #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 - else if(sizeof(T) == sizeof(std::uint64_t) && __ulock_wait != nullptr) - { - while(aval.load(order) == value) - __ulock_wait(UL_COMPARE_AND_WAIT64, &aval, value, 0); - } + else if(sizeof(T) == sizeof(std::uint64_t) && __ulock_wait != nullptr) + { + while(aval.load(order) == value) + __ulock_wait(UL_COMPARE_AND_WAIT64, &aval, value, 0); + } #endif - else - { - auto lock = std::unique_lock{gAtomicWaitMutex}; - ++gAtomicWaitCounter; - while(aval.load(order) == value) - gAtomicWaitCondVar.wait(lock); - --gAtomicWaitCounter; - } + else + { + auto lock = std::unique_lock{gAtomicWaitMutex}; + ++gAtomicWaitCounter; + while(aval.load(order) == value) + gAtomicWaitCondVar.wait(lock); + --gAtomicWaitCounter; + } #else - aval.wait(value, order); + static_assert(dependent_false, "No atomic wait function available"); #endif + } } template auto atomic_notify_one(std::atomic &aval) noexcept -> void { + if constexpr(requires { aval.notify_one(); }) + aval.notify_one(); + else + { #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED < 110000 - static_assert(sizeof(aval) == sizeof(T)); + static_assert(sizeof(aval) == sizeof(T)); - if(sizeof(T) == sizeof(std::uint32_t) && __ulock_wake != nullptr) - __ulock_wake(UL_COMPARE_AND_WAIT, &aval, 0); + if(sizeof(T) == sizeof(std::uint32_t) && __ulock_wake != nullptr) + __ulock_wake(UL_COMPARE_AND_WAIT, &aval, 0); #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 - else if(sizeof(T) == sizeof(std::uint64_t) && __ulock_wake != nullptr) - __ulock_wake(UL_COMPARE_AND_WAIT64, &aval, 0); + else if(sizeof(T) == sizeof(std::uint64_t) && __ulock_wake != nullptr) + __ulock_wake(UL_COMPARE_AND_WAIT64, &aval, 0); #endif - else - { - auto lock = std::unique_lock{gAtomicWaitMutex}; - auto const numwaits = gAtomicWaitCounter; - lock.unlock(); - if(numwaits > 0) + else { - /* notify_all since we can't guarantee notify_one will wake a - * waiter waiting on this particular object. With notify_all, we - * just act as if all waiters were spuriously woken up and they'll - * recheck. - */ - gAtomicWaitCondVar.notify_all(); + auto lock = std::unique_lock{gAtomicWaitMutex}; + auto const numwaits = gAtomicWaitCounter; + lock.unlock(); + if(numwaits > 0) + { + /* notify_all since we can't guarantee notify_one will wake a + * waiter waiting on this particular object. With notify_all, + * we just act as if all waiters were spuriously woken up and + * they'll recheck. + */ + gAtomicWaitCondVar.notify_all(); + } } - } #else - aval.notify_one(); + static_assert(dependent_false, "No atomic notify_one function available"); #endif + } } template auto atomic_notify_all(std::atomic &aval) noexcept -> void { + if constexpr(requires { aval.notify_all(); }) + aval.notify_all(); + else + { #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED < 110000 - static_assert(sizeof(aval) == sizeof(T)); + static_assert(sizeof(aval) == sizeof(T)); - if(sizeof(T) == sizeof(std::uint32_t) && __ulock_wake != nullptr) - __ulock_wake(UL_COMPARE_AND_WAIT | ULF_WAKE_ALL, &aval, 0); + if(sizeof(T) == sizeof(std::uint32_t) && __ulock_wake != nullptr) + __ulock_wake(UL_COMPARE_AND_WAIT | ULF_WAKE_ALL, &aval, 0); #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 - else if(sizeof(T) == sizeof(std::uint64_t) && __ulock_wake != nullptr) - __ulock_wake(UL_COMPARE_AND_WAIT64 | ULF_WAKE_ALL, &aval, 0); + else if(sizeof(T) == sizeof(std::uint64_t) && __ulock_wake != nullptr) + __ulock_wake(UL_COMPARE_AND_WAIT64 | ULF_WAKE_ALL, &aval, 0); #endif - else - { - auto lock = std::unique_lock{gAtomicWaitMutex}; - auto const numwaits = gAtomicWaitCounter; - lock.unlock(); - if(numwaits > 0) - gAtomicWaitCondVar.notify_all(); - } + else + { + auto lock = std::unique_lock{gAtomicWaitMutex}; + auto const numwaits = gAtomicWaitCounter; + lock.unlock(); + if(numwaits > 0) + gAtomicWaitCondVar.notify_all(); + } #else - aval.notify_all(); + static_assert(dependent_false, "No atomic notify_all function available"); #endif + } } template> diff --git a/3rdparty/openal/common/bitset.hpp b/3rdparty/openal/common/bitset.hpp new file mode 100644 index 000000000000..5d5b18d21e93 --- /dev/null +++ b/3rdparty/openal/common/bitset.hpp @@ -0,0 +1,144 @@ +#ifndef COMMON_BITSET_HPP +#define COMMON_BITSET_HPP + +#include +#include +#include + +#include "opthelpers.h" + + +namespace al { + +namespace detail_ { + void test_int_conversion(...); + void test_int_conversion(int) = delete; +} + +template +concept scoped_enum = std::is_enum_v and requires { detail_::test_int_conversion(T{}); }; + +/* The given enum type's "MaxValue" enumeration specifies the largest index + * that will be used for the bitset. + */ +template +class bitset { + using UnderlyingType = std::make_unsigned_t>; + static constexpr auto Count = static_cast(EnumType::MaxValue) + 1u; + + using BitsetType = std::bitset; + BitsetType mBits; + + force_inline explicit constexpr + bitset(BitsetType const &rhs) noexcept : mBits(rhs) { } + +public: + using reference = typename BitsetType::reference; + + constexpr bitset() noexcept = default; + constexpr bitset(bitset const &rhs) noexcept = default; + constexpr ~bitset() noexcept = default; + + force_inline explicit constexpr bitset(unsigned long long const arg) noexcept : mBits{arg} { } + + template force_inline explicit constexpr + bitset(std::basic_string const& str, + typename std::basic_string::size_type const pos=0, + typename std::basic_string::size_type const + n=std::basic_string::npos, + CharT const zero=CharT{'0'}, CharT const one=CharT{'1'}) : mBits{str, pos, n, zero, one} + { } + + template force_inline explicit constexpr + bitset(std::basic_string_view const str, std::size_t const pos=0, + std::size_t const n=static_cast(-1), CharT const zero=CharT{'0'}, + CharT const one=CharT{'1'}) : mBits{str, pos, n, zero, one} + { } + + template force_inline explicit constexpr + bitset(CharT const *const str, std::size_t const n=static_cast(-1), + CharT const zero=CharT{'0'}, CharT const one=CharT{'1'}) : mBits{str, n, zero, one} + { } + + + [[nodiscard]] force_inline constexpr + auto get_bitset() const noexcept LIFETIMEBOUND -> BitsetType const& { return mBits; } + + [[nodiscard]] force_inline explicit constexpr + operator bool() const noexcept { return bool{mBits}; } + + + force_inline constexpr + auto set(EnumType const e, bool s=true) noexcept LIFETIMEBOUND -> bitset& + { mBits.set(static_cast(e), s); return *this; } + + force_inline constexpr + auto reset(EnumType const e) noexcept LIFETIMEBOUND -> bitset& + { mBits.reset(static_cast(e)); return *this; } + + force_inline constexpr + auto reset() noexcept LIFETIMEBOUND -> bitset& { mBits.reset(); return *this; } + + [[nodiscard]] force_inline constexpr + auto test(EnumType const e) const noexcept -> bool + { return mBits.test(static_cast(e)); } + + [[nodiscard]] force_inline constexpr auto any() const noexcept -> bool { return mBits.any(); } + [[nodiscard]] force_inline constexpr auto all() const noexcept -> bool { return mBits.all(); } + [[nodiscard]] force_inline constexpr + auto none() const noexcept -> bool { return mBits.none(); } + + [[nodiscard]] force_inline constexpr + auto flip() const noexcept LIFETIMEBOUND -> bitset& { mBits.flip(); return *this; } + [[nodiscard]] force_inline constexpr + auto flip(EnumType const e) const noexcept LIFETIMEBOUND -> bitset& + { mBits.flip(static_cast(e)); return *this; } + + [[nodiscard]] force_inline constexpr + auto count() const noexcept -> std::size_t { return mBits.count(); } + [[nodiscard]] force_inline constexpr + auto size() const noexcept -> std::size_t { return mBits.size(); } + + [[nodiscard]] force_inline constexpr + auto operator[](EnumType const e) noexcept -> decltype(auto) + { return mBits[static_cast(e)]; } + + [[nodiscard]] force_inline constexpr + auto operator[](EnumType const e) const noexcept -> decltype(auto) + { return mBits[static_cast(e)]; } + + [[nodiscard]] force_inline constexpr + auto operator~() const noexcept -> bitset { return bitset{~mBits}; } + + force_inline constexpr + auto operator|=(bitset const &rhs LIFETIMEBOUND) noexcept -> bitset& + { mBits |= rhs.mBits; return *this; } + + force_inline constexpr + auto operator&=(bitset const &rhs LIFETIMEBOUND) noexcept -> bitset& + { mBits &= rhs.mBits; return *this; } + + force_inline constexpr + auto operator^=(bitset const &rhs LIFETIMEBOUND) noexcept -> bitset& + { mBits ^= rhs.mBits; return *this; } + + [[nodiscard]] force_inline friend constexpr + auto operator|(bitset const &lhs, bitset const &rhs) noexcept -> bitset + { return bitset{lhs.mBits | rhs.mBits}; } + + [[nodiscard]] force_inline friend constexpr + auto operator&(bitset const &lhs, bitset const &rhs) noexcept -> bitset + { return bitset{lhs.mBits & rhs.mBits}; } + + [[nodiscard]] force_inline friend constexpr + auto operator^(bitset const &lhs, bitset const &rhs) noexcept -> bitset + { return bitset{lhs.mBits ^ rhs.mBits}; } + + [[nodiscard]] force_inline friend constexpr + auto operator==(bitset const &lhs, bitset const &rhs) noexcept -> bool + { return lhs.mBits() == rhs.mBits(); } +}; + +} /* namespace al */ + +#endif /* COMMON_BITSET_HPP */ diff --git a/3rdparty/openal/common/dynload.cpp b/3rdparty/openal/common/dynload.cpp index e7a6dd5eb616..fd10626d8605 100644 --- a/3rdparty/openal/common/dynload.cpp +++ b/3rdparty/openal/common/dynload.cpp @@ -3,6 +3,8 @@ #include "dynload.h" +#if HAVE_DYNLOAD + #ifdef _WIN32 #include @@ -77,3 +79,5 @@ auto GetSymbol(void *const handle, gsl::czstring const name) -> al::expected @@ -10,8 +12,6 @@ #include "expected.hpp" #include "gsl/gsl" -#define HAVE_DYNLOAD 1 - #include "dlopennote.h" [[nodiscard]] @@ -20,9 +20,7 @@ void CloseLib(void *handle); [[nodiscard]] auto GetSymbol(void *handle, gsl::czstring name) -> al::expected; -#else - -#define HAVE_DYNLOAD 0 +#endif #endif diff --git a/3rdparty/openal/common/flexarray.h b/3rdparty/openal/common/flexarray.h index e19e869df3e3..184988788c28 100644 --- a/3rdparty/openal/common/flexarray.h +++ b/3rdparty/openal/common/flexarray.h @@ -16,7 +16,7 @@ namespace al { /* Storage for flexible array data. This is trivially destructible if type T is * trivially destructible. */ -template> +template struct alignas(alignment) FlexArrayStorage : std::span { /* NOLINTBEGIN(bugprone-sizeof-expression) clang-tidy warns about the * sizeof(T) being suspicious when T is a pointer type, which it will be @@ -34,26 +34,9 @@ struct alignas(alignment) FlexArrayStorage : std::span { : std::span{::new(static_cast(this+1)) T[size], size} { } /* NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic) */ - ~FlexArrayStorage() = default; - - FlexArrayStorage(const FlexArrayStorage&) = delete; - FlexArrayStorage& operator=(const FlexArrayStorage&) = delete; -}; - -template -struct alignas(alignment) FlexArrayStorage : std::span { - static constexpr size_t Sizeof(size_t count, size_t base=0u) noexcept - { return sizeof(FlexArrayStorage) + sizeof(T)*count + base; } - - /* NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) */ - explicit FlexArrayStorage(size_t size) noexcept(std::is_nothrow_constructible_v) - : std::span{::new(static_cast(this+1)) T[size], size} - { } - /* NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic) */ - ~FlexArrayStorage() { std::destroy(this->begin(), this->end()); } - - FlexArrayStorage(const FlexArrayStorage&) = delete; - FlexArrayStorage& operator=(const FlexArrayStorage&) = delete; + ~FlexArrayStorage() requires(std::is_trivially_destructible_v) = default; + ~FlexArrayStorage() requires(not std::is_trivially_destructible_v) + { std::destroy(this->begin(), this->end()); } }; /* A flexible array type. Used either standalone or at the end of a parent @@ -92,6 +75,9 @@ struct FlexArray { { } ~FlexArray() = default; + FlexArray(const FlexArray&) = delete; + auto operator=(const FlexArray&) -> FlexArray& = delete; + [[nodiscard]] auto size() const noexcept -> index_type { return mStore.size(); } [[nodiscard]] auto empty() const noexcept -> bool { return mStore.empty(); } diff --git a/3rdparty/openal/common/hann_window.hpp b/3rdparty/openal/common/hann_window.hpp new file mode 100644 index 000000000000..315d79901538 --- /dev/null +++ b/3rdparty/openal/common/hann_window.hpp @@ -0,0 +1,32 @@ +#ifndef AL_HANN_WINDOW_HPP +#define AL_HANN_WINDOW_HPP + +#include +#include +#include +#include +#include + + +/* Define a Hann window, used to filter the STFT input and output. */ +template +struct MakeHannWindow : std::array { + MakeHannWindow() noexcept + { + static constexpr auto scale = std::numbers::pi / double{N+1}; + /* Create lookup table of the Hann window for the desired size. */ + auto const end = std::ranges::transform(std::views::iota(0u, unsigned{N/2}), this->begin(), + [](unsigned const i) -> float + { + const auto val = std::sin((i+1.0) * scale); + return static_cast(val * val); + }).out; + std::ranges::copy(this->begin(), end, this->rbegin()); + } +}; + + +template alignas(16) inline +auto const gHannWindow = MakeHannWindow{}; + +#endif /* AL_HANN_WINDOW_HPP */ diff --git a/3rdparty/openal/common/intrusive_ptr.h b/3rdparty/openal/common/intrusive_ptr.h index b147a382f998..2dc4db51e8c2 100644 --- a/3rdparty/openal/common/intrusive_ptr.h +++ b/3rdparty/openal/common/intrusive_ptr.h @@ -2,9 +2,9 @@ #define INTRUSIVE_PTR_H #include -#include #include #include +#include #include #include "gsl/gsl" @@ -24,7 +24,7 @@ class intrusive_ref : protected D { unsigned int inc_ref() noexcept { return mRef.fetch_add(1, std::memory_order_acq_rel)+1; } unsigned int dec_ref() noexcept { - auto ref = mRef.fetch_sub(1, std::memory_order_acq_rel)-1; + auto const ref = mRef.fetch_sub(1, std::memory_order_acq_rel)-1; if(ref == 0) [[unlikely]] D::operator()(static_cast>(this)); return ref; @@ -106,47 +106,26 @@ class intrusive_ptr { constexpr auto release() noexcept -> T* { return std::exchange(mPtr, nullptr); } constexpr void swap(intrusive_ptr &rhs) noexcept { std::swap(mPtr, rhs.mPtr); } -}; - -template -void swap(intrusive_ptr &lhs, intrusive_ptr &rhs) noexcept { lhs.swap(rhs); } - -template requires std::three_way_comparable_with [[nodiscard]] -constexpr auto operator<=>(const intrusive_ptr &lhs, std::nullptr_t) noexcept -{ return std::compare_three_way{}(lhs.get(), nullptr); } - -template [[nodiscard]] -constexpr auto operator==(const intrusive_ptr &lhs, std::nullptr_t) noexcept -{ return !lhs; } -template [[nodiscard]] -constexpr auto operator!=(const intrusive_ptr &lhs, std::nullptr_t) noexcept -{ return !(lhs == nullptr); } + [[nodiscard]] constexpr auto operator<=>(std::nullptr_t) const noexcept { return mPtr <=> nullptr; } + [[nodiscard]] constexpr auto operator==(std::nullptr_t) const noexcept { return mPtr == nullptr; } + [[nodiscard]] constexpr auto operator!=(std::nullptr_t) const noexcept { return mPtr != nullptr; } -template requires std::three_way_comparable_with [[nodiscard]] -constexpr auto operator<=>(std::nullptr_t, const intrusive_ptr &rhs) noexcept -{ return std::compare_three_way{}(nullptr, rhs.get()); } + template requires requires(T *t, U *u) { t <=> u; } [[nodiscard]] constexpr + auto operator<=>(const intrusive_ptr &rhs) const noexcept + { return mPtr <=> rhs.get(); } -template [[nodiscard]] -constexpr auto operator==(std::nullptr_t, const intrusive_ptr &rhs) noexcept -{ return !rhs; } + template requires requires(T *t, U *u) { t <=> u; } [[nodiscard]] constexpr + auto operator==(const intrusive_ptr &rhs) const noexcept -> bool + { return mPtr == rhs.get(); } -template [[nodiscard]] -constexpr auto operator!=(std::nullptr_t, const intrusive_ptr &rhs) noexcept -{ return !(rhs == nullptr); } - - -template requires std::three_way_comparable_with [[nodiscard]] -constexpr auto operator<=>(const intrusive_ptr &lhs, const intrusive_ptr& rhs) noexcept -{ return std::compare_three_way{}(lhs.get(), rhs.get()); } - -template requires std::equality_comparable_with [[nodiscard]] -constexpr auto operator==(const intrusive_ptr &lhs, const intrusive_ptr& rhs) noexcept -{ return lhs.get() == rhs.get(); } + template requires requires(T *t, U *u) { t <=> u; } [[nodiscard]] constexpr + auto operator!=(const intrusive_ptr &rhs) const noexcept -> bool + { return mPtr != rhs.get(); } +}; -template requires std::equality_comparable_with [[nodiscard]] -constexpr auto operator!=(const intrusive_ptr &lhs, const intrusive_ptr& rhs) noexcept -{ return !(lhs == rhs); } +template +void swap(intrusive_ptr &lhs, intrusive_ptr &rhs) noexcept { lhs.swap(rhs); } } // namespace al diff --git a/3rdparty/openal/common/opthelpers.h b/3rdparty/openal/common/opthelpers.h index 6f3ba7de23fa..9787d8e37185 100644 --- a/3rdparty/openal/common/opthelpers.h +++ b/3rdparty/openal/common/opthelpers.h @@ -62,6 +62,10 @@ #define LIFETIMEBOUND #endif +// Axmol spec: The attribute is non-standard and may not provide functional benefit here, +// so disabling it avoids compatibility issues without affecting behavior. +#define NONBLOCKING + namespace al { template diff --git a/3rdparty/openal/common/pffft.cpp b/3rdparty/openal/common/pffft.cpp index 58cc7bd7e335..77a9273901bc 100644 --- a/3rdparty/openal/common/pffft.cpp +++ b/3rdparty/openal/common/pffft.cpp @@ -62,9 +62,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -73,7 +71,7 @@ #include #include "almalloc.h" -#include "alnumeric.h" +#include "altypes.hpp" #include "fmt/core.h" #include "fmt/ranges.h" #include "gsl/gsl" @@ -148,55 +146,10 @@ force_inline void vtranspose4(v4sf &x0, v4sf &x1, v4sf &x2, v4sf &x3) noexcept x3 = vec_mergel(y1, y3); } -/* - * SSE1 support macros - */ -#elif defined(__x86_64__) || defined(__SSE__) || defined(_M_X64) || \ - (defined(_M_IX86_FP) && _M_IX86_FP >= 1) - -#include -using v4sf = __m128; -/* 4 floats by simd vector -- this is pretty much hardcoded in the preprocess/ - * finalize functions anyway so you will have to work if you want to enable AVX - * with its 256-bit vectors. - */ -constexpr auto SimdSize = 4u; -force_inline auto vzero() noexcept -> v4sf { return _mm_setzero_ps(); } -force_inline auto vmul(v4sf a, v4sf b) noexcept -> v4sf { return _mm_mul_ps(a, b); } -force_inline auto vadd(v4sf a, v4sf b) noexcept -> v4sf { return _mm_add_ps(a, b); } -force_inline auto vmadd(v4sf a, v4sf b, v4sf c) noexcept -> v4sf -{ return _mm_add_ps(_mm_mul_ps(a,b), c); } -force_inline auto vsub(v4sf a, v4sf b) noexcept -> v4sf { return _mm_sub_ps(a, b); } -force_inline auto ld_ps1(float a) noexcept -> v4sf { return _mm_set1_ps(a); } - -force_inline auto vset4(float a, float b, float c, float d) noexcept -> v4sf -{ return _mm_setr_ps(a, b, c, d); } -force_inline auto vinsert0(const v4sf v, const float a) noexcept -> v4sf -{ return _mm_move_ss(v, _mm_set_ss(a)); } -force_inline auto vextract0(v4sf v) noexcept -> float -{ return _mm_cvtss_f32(v); } - -force_inline auto vswaphl(v4sf a, v4sf b) noexcept -> v4sf -{ return _mm_shuffle_ps(b, a, _MM_SHUFFLE(3,2,1,0)); } - -force_inline void interleave2(const v4sf in1, const v4sf in2, v4sf &out1, v4sf &out2) noexcept -{ - out1 = _mm_unpacklo_ps(in1, in2); - out2 = _mm_unpackhi_ps(in1, in2); -} -force_inline void uninterleave2(v4sf in1, v4sf in2, v4sf &out1, v4sf &out2) noexcept -{ - out1 = _mm_shuffle_ps(in1, in2, _MM_SHUFFLE(2,0,2,0)); - out2 = _mm_shuffle_ps(in1, in2, _MM_SHUFFLE(3,1,3,1)); -} - -force_inline void vtranspose4(v4sf &x0, v4sf &x1, v4sf &x2, v4sf &x3) noexcept -{ _MM_TRANSPOSE4_PS(x0, x1, x2, x3); } - /* * ARM NEON support macros */ -#elif defined(__ARM_NEON) || defined(__aarch64__) || defined(__arm64) || defined(_M_ARM64) +#elif defined(__ARM_NEON) || defined(__aarch64__) || defined(__arm64) || defined(_M_ARM64) || defined(_M_ARM64EC) #include using v4sf = float32x4_t; @@ -256,6 +209,51 @@ force_inline void vtranspose4(v4sf &x0, v4sf &x1, v4sf &x2, v4sf &x3) noexcept x3 = u1_.val[1]; } +/* + * SSE1 support macros + */ +#elif defined(__x86_64__) || defined(__SSE__) || defined(_M_X64) || \ + (defined(_M_IX86_FP) && _M_IX86_FP >= 1) + +#include +using v4sf = __m128; +/* 4 floats by simd vector -- this is pretty much hardcoded in the preprocess/ + * finalize functions anyway so you will have to work if you want to enable AVX + * with its 256-bit vectors. + */ +constexpr auto SimdSize = 4u; +force_inline auto vzero() noexcept -> v4sf { return _mm_setzero_ps(); } +force_inline auto vmul(v4sf a, v4sf b) noexcept -> v4sf { return _mm_mul_ps(a, b); } +force_inline auto vadd(v4sf a, v4sf b) noexcept -> v4sf { return _mm_add_ps(a, b); } +force_inline auto vmadd(v4sf a, v4sf b, v4sf c) noexcept -> v4sf +{ return _mm_add_ps(_mm_mul_ps(a,b), c); } +force_inline auto vsub(v4sf a, v4sf b) noexcept -> v4sf { return _mm_sub_ps(a, b); } +force_inline auto ld_ps1(float a) noexcept -> v4sf { return _mm_set1_ps(a); } + +force_inline auto vset4(float a, float b, float c, float d) noexcept -> v4sf +{ return _mm_setr_ps(a, b, c, d); } +force_inline auto vinsert0(const v4sf v, const float a) noexcept -> v4sf +{ return _mm_move_ss(v, _mm_set_ss(a)); } +force_inline auto vextract0(v4sf v) noexcept -> float +{ return _mm_cvtss_f32(v); } + +force_inline auto vswaphl(v4sf a, v4sf b) noexcept -> v4sf +{ return _mm_shuffle_ps(b, a, _MM_SHUFFLE(3,2,1,0)); } + +force_inline void interleave2(const v4sf in1, const v4sf in2, v4sf &out1, v4sf &out2) noexcept +{ + out1 = _mm_unpacklo_ps(in1, in2); + out2 = _mm_unpackhi_ps(in1, in2); +} +force_inline void uninterleave2(v4sf in1, v4sf in2, v4sf &out1, v4sf &out2) noexcept +{ + out1 = _mm_shuffle_ps(in1, in2, _MM_SHUFFLE(2,0,2,0)); + out2 = _mm_shuffle_ps(in1, in2, _MM_SHUFFLE(3,1,3,1)); +} + +force_inline void vtranspose4(v4sf &x0, v4sf &x1, v4sf &x2, v4sf &x3) noexcept +{ _MM_TRANSPOSE4_PS(x0, x1, x2, x3); } + /* * Generic GCC vector macros */ @@ -1388,31 +1386,30 @@ auto decompose(unsigned const n, const std::span ifac, void rffti1_ps(unsigned const n, float *wa, std::span const ifac) { - static constexpr std::array ntryh{4u, 2u, 3u, 5u}; + static constexpr auto ntryh = std::array{4u, 2u, 3u, 5u}; - const auto nf = usize{decompose(n, ifac, ntryh)}; - const auto argh = 2.0*std::numbers::pi / n; - auto is = 0_uz; - auto nfm1 = nf - 1_uz; - auto l1 = 1_uz; + auto const nfm1 = usize{decompose(n, ifac, ntryh)} - 1; + auto const argh = 2.0_f64*std::numbers::pi / n; + auto is = 0_usize; + auto l1 = 1_usize; for(auto k1 = 0_uz;k1 < nfm1;++k1) { - const auto ip = size_t{ifac[k1+2]}; + const auto ip = usize{ifac[k1+2]}; const auto l2 = l1 * ip; const auto ido = n / l2; const auto ipm = ip - 1; - auto ld = 0_uz; + auto ld = 0_usize; for(auto j = 0_uz;j < ipm;++j) { - auto i = is; + auto i = is.c_val; ld += l1; - const auto argld = gsl::narrow_cast(ld)*argh; + const auto argld = ld.reinterpret_as() * argh; auto fi = 0.0; for(auto ii = 2_uz;ii < ido;ii += 2) { fi += 1.0; - wa[i++] = gsl::narrow_cast(std::cos(fi*argld)); - wa[i++] = gsl::narrow_cast(std::sin(fi*argld)); + wa[i++] = cos(fi*argld).cast_to().c_val; + wa[i++] = sin(fi*argld).cast_to().c_val; } is += ido; } @@ -1425,30 +1422,30 @@ void cffti1_ps(unsigned const n, float *wa, std::span const ifac) static constexpr auto ntryh = std::array{5u, 3u, 4u, 2u}; const auto nf = usize{decompose(n, ifac, ntryh)}; - const auto argh = 2.0*std::numbers::pi / n; + const auto argh = 2.0_f64*std::numbers::pi / n; auto i = 1_uz; - auto l1 = 1_uz; + auto l1 = 1_usize; for(auto k1 = 0_uz;k1 < nf;++k1) { - const auto ip = size_t{ifac[k1+2]}; + const auto ip = usize{ifac[k1+2]}; const auto l2 = l1 * ip; const auto ido = n / l2; const auto idot = ido + ido + 2_uz; const auto ipm = ip - 1_uz; - auto ld = 0_uz; + auto ld = 0_usize; for(auto j = 0_uz;j < ipm;++j) { - auto i1 = i; + auto const i1 = i; wa[i-1] = 1.0f; wa[i] = 0.0f; ld += l1; - const auto argld = gsl::narrow_cast(ld)*argh; + const auto argld = ld.reinterpret_as()*argh; auto fi = 0.0; for(auto ii = 3_uz;ii < idot;ii += 2) { fi += 1.0; - wa[++i] = gsl::narrow_cast(std::cos(fi*argld)); - wa[++i] = gsl::narrow_cast(std::sin(fi*argld)); + wa[++i] = cos(fi*argld).reinterpret_as().c_val; + wa[++i] = sin(fi*argld).reinterpret_as().c_val; } if(ip > 5) { diff --git a/3rdparty/openal/common/phase_shifter.h b/3rdparty/openal/common/phase_shifter.hpp similarity index 90% rename from 3rdparty/openal/common/phase_shifter.h rename to 3rdparty/openal/common/phase_shifter.hpp index e562fb4e2e60..adc7711e06f5 100644 --- a/3rdparty/openal/common/phase_shifter.h +++ b/3rdparty/openal/common/phase_shifter.hpp @@ -1,12 +1,12 @@ -#ifndef PHASE_SHIFTER_H -#define PHASE_SHIFTER_H +#ifndef PHASE_SHIFTER_HPP +#define PHASE_SHIFTER_HPP #include "config_simd.h" -#if HAVE_SSE_INTRINSICS -#include -#elif HAVE_NEON +#if HAVE_NEON #include +#elif HAVE_SSE_INTRINSICS +#include #endif #include @@ -17,7 +17,7 @@ #include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "gsl/gsl" #include "opthelpers.h" @@ -31,7 +31,9 @@ class PhaseShifterT { static_assert(FilterSize >= 16, "FilterSize needs to be at least 16"); static_assert((FilterSize&(FilterSize-1)) == 0, "FilterSize needs to be power-of-two"); - alignas(16) std::array mCoeffs{}; + static constexpr auto sFilterHalfSize = unsigned{FilterSize/2}; + + alignas(16) std::array mCoeffs{}; #if HAVE_NEON static auto load4(float32_t a, float32_t b, float32_t c, float32_t d) -> float32x4_t @@ -63,24 +65,76 @@ class PhaseShifterT { * calculated coefficients are in reverse to make applying in the time- * domain more efficient. */ - for(const auto i : std::views::iota(0_uz, FilterSize/2)) + for(const auto i : std::views::iota(0_uz, sFilterHalfSize)) { - const auto k = gsl::narrow_cast(i*2 + 1) - int{FilterSize/2}; + const auto k = gsl::narrow_cast(i*2 + 1) - int{sFilterHalfSize}; - /* Calculate the Blackman window value for this coefficient. */ - const auto w = 2.0*std::numbers::pi/double{FilterSize} - * gsl::narrow_cast(i*2 + 1); + /* Calculate the Blackman-Nuttall window value for this + * coefficient. + */ + const auto w = 2.0*std::numbers::pi/double{sFilterHalfSize-1} + * gsl::narrow_cast(i); const auto window = 0.3635819 - 0.4891775*std::cos(w) + 0.1365995*std::cos(2.0*w) - 0.0106411*std::cos(3.0*w); const auto pk = std::numbers::pi * gsl::narrow_cast(k); - mCoeffs[i] = gsl::narrow_cast(window * (1.0-std::cos(pk)) / pk); + mCoeffs[i] = gsl::narrow_cast(window * 2.0 / pk); } } NOINLINE void process(const std::span dst, std::span src) const { -#if HAVE_SSE_INTRINSICS +#if HAVE_NEON + if(const std::size_t todo{dst.size()>>2}) + { + auto out = std::span{reinterpret_cast(dst.data()), todo}; + std::generate(out.begin(), out.end(), [&src,this] + { + auto r0 = vdupq_n_f32(0.0f); + auto r1 = vdupq_n_f32(0.0f); + auto r2 = vdupq_n_f32(0.0f); + auto r3 = vdupq_n_f32(0.0f); + for(auto j = 0_uz;j < mCoeffs.size();j+=4) + { + const auto coeffs = vld1q_f32(&mCoeffs[j]); + const auto s0 = vld1q_f32(&src[j*2]); + const auto s1 = vld1q_f32(&src[j*2 + 4]); + const auto s2 = vcombine_f32(vget_high_f32(s0), vget_low_f32(s1)); + const auto s3 = vcombine_f32(vget_high_f32(s1), vld1_f32(&src[j*2 + 8])); + const auto values0 = vuzpq_f32(s0, s1); + const auto values1 = vuzpq_f32(s2, s3); + + r0 = vmlaq_f32(r0, values0.val[0], coeffs); + r1 = vmlaq_f32(r1, values0.val[1], coeffs); + r2 = vmlaq_f32(r2, values1.val[0], coeffs); + r3 = vmlaq_f32(r3, values1.val[1], coeffs); + } + src = src.subspan(4); + + vtranspose4(r0, r1, r2, r3); + return vaddq_f32(vaddq_f32(r0, r1), vaddq_f32(r2, r3)); + }); + } + if(const auto todo = dst.size()&3) + { + std::ranges::generate(dst.last(todo), [&src,this] + { + auto r4 = vdupq_n_f32(0.0f); + for(auto j = 0_uz;j < mCoeffs.size();j+=4) + { + const auto coeffs = vld1q_f32(&mCoeffs[j]); + const auto s = load4(src[j*2], src[j*2 + 2], src[j*2 + 4], src[j*2 + 6]); + r4 = vmlaq_f32(r4, s, coeffs); + } + src = src.subspan(1); + r4 = vaddq_f32(r4, vrev64q_f32(r4)); + return vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0); + }); + } + /* NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast) */ + +#elif HAVE_SSE_INTRINSICS + /* NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast) * Need to be able to cast floats to SIMD float types. */ @@ -139,56 +193,6 @@ class PhaseShifterT { }); } -#elif HAVE_NEON - - if(const std::size_t todo{dst.size()>>2}) - { - auto out = std::span{reinterpret_cast(dst.data()), todo}; - std::generate(out.begin(), out.end(), [&src,this] - { - auto r0 = vdupq_n_f32(0.0f); - auto r1 = vdupq_n_f32(0.0f); - auto r2 = vdupq_n_f32(0.0f); - auto r3 = vdupq_n_f32(0.0f); - for(auto j = 0_uz;j < mCoeffs.size();j+=4) - { - const auto coeffs = vld1q_f32(&mCoeffs[j]); - const auto s0 = vld1q_f32(&src[j*2]); - const auto s1 = vld1q_f32(&src[j*2 + 4]); - const auto s2 = vcombine_f32(vget_high_f32(s0), vget_low_f32(s1)); - const auto s3 = vcombine_f32(vget_high_f32(s1), vld1_f32(&src[j*2 + 8])); - const auto values0 = vuzpq_f32(s0, s1); - const auto values1 = vuzpq_f32(s2, s3); - - r0 = vmlaq_f32(r0, values0.val[0], coeffs); - r1 = vmlaq_f32(r1, values0.val[1], coeffs); - r2 = vmlaq_f32(r2, values1.val[0], coeffs); - r3 = vmlaq_f32(r3, values1.val[1], coeffs); - } - src = src.subspan(4); - - vtranspose4(r0, r1, r2, r3); - return vaddq_f32(vaddq_f32(r0, r1), vaddq_f32(r2, r3)); - }); - } - if(const auto todo = dst.size()&3) - { - std::ranges::generate(dst.last(todo), [&src,this] - { - auto r4 = vdupq_n_f32(0.0f); - for(auto j = 0_uz;j < mCoeffs.size();j+=4) - { - const auto coeffs = vld1q_f32(&mCoeffs[j]); - const auto s = load4(src[j*2], src[j*2 + 2], src[j*2 + 4], src[j*2 + 6]); - r4 = vmlaq_f32(r4, s, coeffs); - } - src = src.subspan(1); - r4 = vaddq_f32(r4, vrev64q_f32(r4)); - return vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0); - }); - } - /* NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast) */ - #else std::ranges::generate(dst, [&src,this] @@ -203,4 +207,7 @@ class PhaseShifterT { } }; -#endif /* PHASE_SHIFTER_H */ +template inline +auto const gPShifter = PhaseShifterT{}; + +#endif /* PHASE_SHIFTER_HPP */ diff --git a/3rdparty/openal/common/vecmat.h b/3rdparty/openal/common/vecmat.h index 6595b0248573..bd55184a9be4 100644 --- a/3rdparty/openal/common/vecmat.h +++ b/3rdparty/openal/common/vecmat.h @@ -3,10 +3,10 @@ #include #include +#include #include #include -#include "altypes.hpp" #include "opthelpers.h" @@ -27,9 +27,9 @@ class Vector { constexpr auto operator=(Vector&&) & noexcept LIFETIMEBOUND -> Vector& = default; [[nodiscard]] constexpr - auto operator[](usize const idx) noexcept LIFETIMEBOUND -> float& { return mVals[idx]; } + auto operator[](std::size_t const idx) noexcept LIFETIMEBOUND -> float& { return mVals[idx]; } [[nodiscard]] constexpr - auto operator[](usize const idx) const noexcept LIFETIMEBOUND -> float const& + auto operator[](std::size_t const idx) const noexcept LIFETIMEBOUND -> float const& { return mVals[idx]; } constexpr auto operator+=(const Vector &rhs) & noexcept -> Vector& @@ -95,9 +95,9 @@ class Matrix { constexpr auto operator=(const Matrix&) & noexcept LIFETIMEBOUND -> Matrix& = default; constexpr auto operator=(Matrix&&) & noexcept LIFETIMEBOUND -> Matrix& = default; - [[nodiscard]] constexpr auto operator[](usize const idx) noexcept LIFETIMEBOUND + [[nodiscard]] constexpr auto operator[](std::size_t const idx) noexcept LIFETIMEBOUND { return std::span{&mVals[idx*4], 4}; } - [[nodiscard]] constexpr auto operator[](usize const idx) const noexcept LIFETIMEBOUND + [[nodiscard]] constexpr auto operator[](std::size_t const idx) const noexcept LIFETIMEBOUND { return std::span{&mVals[idx*4], 4}; } [[nodiscard]] static constexpr auto Identity() noexcept -> Matrix diff --git a/3rdparty/openal/common/win_main_utf8.h b/3rdparty/openal/common/win_main_utf8.h index 9eced79db365..60daed5f43bc 100644 --- a/3rdparty/openal/common/win_main_utf8.h +++ b/3rdparty/openal/common/win_main_utf8.h @@ -69,7 +69,7 @@ int my_main(int, char**); #include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "fmt/base.h" #include "fmt/ostream.h" diff --git a/3rdparty/openal/config.h.in b/3rdparty/openal/config.h.in index 0c312b4bb3a5..babc78d0d962 100644 --- a/3rdparty/openal/config.h.in +++ b/3rdparty/openal/config.h.in @@ -46,6 +46,9 @@ /* Define to 1 if we have C++20 modules, else 0 */ #cmakedefine01 HAVE_CXXMODULES +/* Define to 1 to enable dynamic loading of optional libs, else 0 */ +#cmakedefine01 HAVE_DYNLOAD + /* Define to 1 if we have DBus/RTKit, else 0 */ #cmakedefine01 HAVE_RTKIT diff --git a/3rdparty/openal/core/allpass_conv.hpp b/3rdparty/openal/core/allpass_conv.hpp index 010c6e8b19d7..29f6e501e9fa 100644 --- a/3rdparty/openal/core/allpass_conv.hpp +++ b/3rdparty/openal/core/allpass_conv.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -11,7 +12,6 @@ #include "alcomplex.h" #include "altypes.hpp" #include "gsl/gsl" -#include "phase_shifter.h" #include "pffft.h" #include "vector.h" @@ -39,7 +39,7 @@ * being applied in the frequency domain, so these "overflow" samples need to * be accounted for. */ -template +template struct SegmentedFilter { static constexpr auto sFftLength = 256_uz; static constexpr auto sSampleLength = sFftLength / 2_uz; @@ -52,21 +52,26 @@ struct SegmentedFilter { SegmentedFilter() noexcept : mFft{sFftLength, PFFFT_REAL} { + static constexpr auto FilterHalfSize = unsigned{FilterSize/2}; + /* To set up the filter, we first need to generate the desired - * response (not reversed). + * response. */ auto tmpBuffer = std::vector(FilterSize, 0.0); - for(const auto i : std::views::iota(0_uz, FilterSize/2)) + for(const auto i : std::views::iota(0_uz, FilterHalfSize)) { - const auto k = int{FilterSize/2} - gsl::narrow_cast(i*2 + 1); + const auto k = int{FilterHalfSize} - gsl::narrow_cast(i*2 + 1); - const auto w = 2.0*std::numbers::pi/double{FilterSize} - * gsl::narrow_cast(i*2 + 1); + /* Calculate the Blackman-Nuttall window value for this + * coefficient. + */ + const auto w = 2.0*std::numbers::pi/double{FilterHalfSize-1} + * gsl::narrow_cast(i); const auto window = 0.3635819 - 0.4891775*std::cos(w) + 0.1365995*std::cos(2.0*w) - 0.0106411*std::cos(3.0*w); const auto pk = std::numbers::pi * gsl::narrow_cast(k); - tmpBuffer[i*2 + 1] = window * (1.0-std::cos(pk)) / pk; + tmpBuffer[i*2 + 1] = window * 2.0 / pk; } /* The response is split into segments that are converted to the @@ -98,10 +103,7 @@ struct SegmentedFilter { } }; -template -inline const SegmentedFilter gSegmentedFilter; - -template -inline const PhaseShifterT gPShifter; +template inline +auto const gSegmentedFilter = SegmentedFilter{}; #endif /* CORE_ALLPASS_CONV_HPP */ diff --git a/3rdparty/openal/core/ambidefs.cpp b/3rdparty/openal/core/ambidefs.cpp index e292f106c75f..f816b635bc67 100644 --- a/3rdparty/openal/core/ambidefs.cpp +++ b/3rdparty/openal/core/ambidefs.cpp @@ -281,7 +281,7 @@ constexpr auto Order4Enc2D = std::array{ static_assert(Order4Dec2D.size() == Order4Enc2D.size(), "Fourth-order 2D mismatch"); -template +template constexpr auto CalcAmbiUpsampler(const std::array, M> &decoder, const std::array &encoder) noexcept { diff --git a/3rdparty/openal/core/ambidefs.h b/3rdparty/openal/core/ambidefs.h index ad773f5ad32c..a7e5a8f02033 100644 --- a/3rdparty/openal/core/ambidefs.h +++ b/3rdparty/openal/core/ambidefs.h @@ -4,7 +4,7 @@ #include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "opthelpers.h" @@ -12,7 +12,7 @@ * needed will be (o+1)**2, thus zero-order has 1, first-order has 4, second- * order has 9, third-order has 16, and fourth-order has 25. */ -constexpr auto AmbiChannelsFromOrder(usize const order) noexcept -> usize +constexpr auto AmbiChannelsFromOrder(std::size_t const order) noexcept -> std::size_t { return (order+1) * (order+1); } inline constexpr auto MaxAmbiOrder = 4_uz; @@ -38,7 +38,7 @@ inline constexpr auto AmbiPeriphonicMask = 0xfe7ce4u; * representation. This is 2 per each order above zero-order, plus 1 for zero- * order. Or simply, o*2 + 1. */ -constexpr auto Ambi2DChannelsFromOrder(usize const order) noexcept -> usize +constexpr auto Ambi2DChannelsFromOrder(std::size_t const order) noexcept -> std::size_t { return order*2 + 1; } inline constexpr auto MaxAmbi2DChannels = Ambi2DChannelsFromOrder(MaxAmbiOrder); @@ -125,7 +125,7 @@ namespace AmbiScale { 1.0f, /* 2.218529919f, ACN 24, sqrt(315)/8 */ }; - template + template using UpsamplerArrays = std::array, N>; DECL_HIDDEN extern constinit UpsamplerArrays<4> const FirstOrderUp; DECL_HIDDEN extern constinit UpsamplerArrays<4> const FirstOrder2DUp; @@ -141,7 +141,7 @@ namespace AmbiScale { } /* namespace AmbiScale */ namespace AmbiIndex { - inline constexpr auto FromFuMa = std::array{ + inline constexpr auto FromFuMa = std::to_array({ 0_u8, /* W */ 3_u8, /* X */ 1_u8, /* Y */ @@ -163,8 +163,8 @@ namespace AmbiIndex { * I hear otherwise, I don't want to make assumptions here. */ 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, - }; - inline constexpr auto FromFuMa2D = std::array{ + }); + inline constexpr auto FromFuMa2D = std::to_array({ 0_u8, /* W */ 3_u8, /* X */ 1_u8, /* Y */ @@ -176,7 +176,7 @@ namespace AmbiIndex { * a pattern suggesting 24,16. */ 0_u8, 0_u8, - }; + }); inline constexpr auto FromACN = std::array{ 0_u8, @@ -191,7 +191,8 @@ namespace AmbiIndex { inline constexpr auto OrderFromChannel = std::array{ - 0_u8, 1_u8,1_u8,1_u8, + 0_u8, + 1_u8,1_u8,1_u8, 2_u8,2_u8,2_u8,2_u8,2_u8, 3_u8,3_u8,3_u8,3_u8,3_u8,3_u8,3_u8, 4_u8,4_u8,4_u8,4_u8,4_u8,4_u8,4_u8,4_u8,4_u8, diff --git a/3rdparty/openal/core/async_event.h b/3rdparty/openal/core/async_event.h index 66e16cf68917..92494c376427 100644 --- a/3rdparty/openal/core/async_event.h +++ b/3rdparty/openal/core/async_event.h @@ -15,7 +15,8 @@ enum class AsyncEnableBits : u8::value_t { SourceState, BufferCompleted, Disconnected, - Count + + MaxValue = Disconnected }; diff --git a/3rdparty/openal/core/bsinc_tables.cpp b/3rdparty/openal/core/bsinc_tables.cpp index d3338926f243..c2fac865282a 100644 --- a/3rdparty/openal/core/bsinc_tables.cpp +++ b/3rdparty/openal/core/bsinc_tables.cpp @@ -31,7 +31,7 @@ namespace { * starts with the largest value and accumulates successively smaller values, * compounding the rounding and precision error), but it's good enough. */ -template +template constexpr auto cyl_bessel_i(T nu, U x) -> U { if(nu != T{0}) @@ -138,7 +138,7 @@ struct BSincHeader { a_ += (a_.cast_to() != a[si]) ? 1_u32 : 0_u32; m[si] = a_ * 2_u32; - total_size += 4_uz * BSincPhaseCount * ((m[si]+3_u32) & ~3_u32).c_val; + total_size += 4_usize * BSincPhaseCount * ((m[si]+3_u32) & ~3_u32); } } }; @@ -157,9 +157,9 @@ constexpr auto bsinc48_hdr = BSincHeader{80, 47, 1}; template struct BSincFilterArray { - alignas(16) std::array mTable{}; + alignas(16) std::array mTable; - BSincFilterArray() noexcept + BSincFilterArray() noexcept : mTable{} { static constexpr auto BSincPointsMax = (hdr.m[0]+3u).c_val & ~3u; static_assert(BSincPointsMax <= MaxResamplerPadding, "MaxResamplerPadding is too small"); @@ -179,7 +179,7 @@ struct BSincFilterArray { const auto l = floor(m*0.5_f64) - 1.0_f64; const auto o = size_t{BSincPointsMax-m.c_val} / 2u; const auto scale = lerp(hdr.scaleBase, 1.0_f64, - f64::make_from(si+1u)/f64{BSincScaleCount}); + f64::from(si+1u)/f64{BSincScaleCount}); /* Calculate an appropriate cutoff frequency. An explanation may be * in order here. @@ -235,19 +235,19 @@ struct BSincFilterArray { * transition band is not fully wrapped at this scale and the * cutoff doesn't need adjustment. */ - const auto max_cutoff = (0.5_f64 - hdr.scaleBase)*scale; + const auto max_cutoff = (0.5 - hdr.scaleBase)*scale; const auto width = hdr.scaleBase * std::max(hdr.scaleLimit, scale); - const auto cutoff2 = std::min(max_cutoff, (scale - width)*0.5_f64) * 2.0_f64; + const auto cutoff2 = std::min(max_cutoff, (scale - width)*0.5) * 2.0; - for(const auto pi : std::views::iota(0_uz, BSincPhaseCount)) + for(const auto pi : std::views::iota(0_u32, BSincPhaseCount)) { - const auto phase = l + f64::make_from(pi)/f64{BSincPhaseCount}; + const auto phase = l + pi.as()/BSincPhaseCount; - for(const auto i : std::views::iota(0_uz, m)) + for(const auto i : std::views::iota(0_u32, m)) { - const auto x = f64::make_from(i) - phase; - filter[si][pi][o+i] = Kaiser(hdr.beta, x/a, besseli_0_beta) * cutoff2 * - Sinc(cutoff2*x); + const auto x = i - phase; + filter[si][pi.c_val][o+i.c_val] = Kaiser(hdr.beta, x/a, besseli_0_beta) + * cutoff2 * Sinc(cutoff2*x); } } } @@ -359,7 +359,7 @@ constexpr auto GenerateBSincTable(const T &filter) noexcept -> BSincTable ret.m[i] = (hdr.m[i]+3u) & ~3u; ret.filterOffset[0] = 0; for(const auto i : std::views::iota(1_uz, BSincScaleCount)) - ret.filterOffset[i] = ret.filterOffset[i-1] + ret.m[i-1]*4*BSincPhaseCount; + ret.filterOffset[i] = ret.filterOffset[i-1] + ret.m[i-1]*4u*BSincPhaseCount; ret.Tab = filter.getTable(); return ret; } diff --git a/3rdparty/openal/core/context.cpp b/3rdparty/openal/core/context.cpp index 79df166501a4..fd5401b6b10b 100644 --- a/3rdparty/openal/core/context.cpp +++ b/3rdparty/openal/core/context.cpp @@ -12,11 +12,16 @@ #include "device.h" #include "effectslot.h" #include "gsl/gsl" -#include "logging.h" #include "ringbuffer.h" #include "voice.h" #include "voice_change.h" +#if HAVE_CXXMODULES +import logging; +#else +#include "logging.h" +#endif + #ifdef __cpp_lib_atomic_is_always_lock_free static_assert(std::atomic::is_always_lock_free, "atomic isn't lock-free"); diff --git a/3rdparty/openal/core/context.h b/3rdparty/openal/core/context.h index d9e5fe57cc4d..a3da3450a0ec 100644 --- a/3rdparty/openal/core/context.h +++ b/3rdparty/openal/core/context.h @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -15,6 +14,7 @@ #include "altypes.hpp" #include "async_event.h" #include "atomic.h" +#include "bitset.hpp" #include "flexarray.h" #include "gsl/gsl" #include "opthelpers.h" @@ -119,9 +119,9 @@ struct ContextBase { using VoiceArray = al::FlexArray; al::atomic_unique_ptr mVoices; - std::atomic mActiveVoiceCount; + std::atomic mActiveVoiceCount; - void allocVoices(usize addcount); + void allocVoices(std::size_t addcount); [[nodiscard]] auto getVoicesSpan() const noexcept LIFETIMEBOUND -> std::span { return {mVoices.load(std::memory_order_relaxed)->data(), @@ -145,8 +145,8 @@ struct ContextBase { FifoBufferPtr mAsyncEvents; /* uint32 to work with macOS wait/notify wrappers, but really just a bool. */ std::atomic mEventsPending; - using AsyncEventBitset = std::bitset; - std::atomic mEnabledEvts{0u}; + using AsyncEventBitset = al::bitset; + std::atomic mEnabledEvts; /* Asynchronous voice change actions are processed as a linked list of * VoiceChange objects by the mixer, which is atomically appended to. diff --git a/3rdparty/openal/core/converter.cpp b/3rdparty/openal/core/converter.cpp index c2cebac57869..a0c90eba0afe 100644 --- a/3rdparty/openal/core/converter.cpp +++ b/3rdparty/openal/core/converter.cpp @@ -47,8 +47,8 @@ template<> constexpr auto LoadSample(u32 const val) noexcept -> floa template -void LoadSampleArray(std::span const dst, void const *const src, usize const channel, - usize const srcstep) noexcept +void LoadSampleArray(std::span const dst, void const *const src, std::size_t const channel, + std::size_t const srcstep) noexcept { Expects(channel < srcstep); const auto srcspan = std::span{static_cast*>(src), dst.size()*srcstep}; @@ -62,8 +62,8 @@ void LoadSampleArray(std::span const dst, void const *const src, usize co }); } -void LoadSamples(std::span const dst, void const *const src, usize const channel, - usize const srcstep, DevFmtType const srctype) noexcept +void LoadSamples(std::span const dst, void const *const src, std::size_t const channel, + std::size_t const srcstep, DevFmtType const srctype) noexcept { #define HANDLE_FMT(T) \ case T: LoadSampleArray(dst, src, channel, srcstep); break @@ -102,8 +102,8 @@ template<> auto StoreSample(float const val) noexcept -> u8 { return StoreSample(val).reinterpret_as() + 128; } template -void StoreSampleArray(void *const dst, std::span const src, usize const channel, - usize const dststep) noexcept +void StoreSampleArray(void *const dst, std::span const src, std::size_t const channel, + std::size_t const dststep) noexcept { Expects(channel < dststep); const auto dstspan = std::span{static_cast*>(dst), src.size()*dststep}; @@ -118,8 +118,8 @@ void StoreSampleArray(void *const dst, std::span const src, usize c } -void StoreSamples(void *const dst, std::span const src, usize const channel, - usize const dststep, DevFmtType const dsttype) noexcept +void StoreSamples(void *const dst, std::span const src, std::size_t const channel, + std::size_t const dststep, DevFmtType const dsttype) noexcept { #define HANDLE_FMT(T) \ case T: StoreSampleArray(dst, src, channel, dststep); break @@ -147,7 +147,7 @@ void Mono2Stereo(std::span const dst, void const *const src) noexcept } template -void Multi2Mono(unsigned chanmask, usize const step, std::span const dst, +void Multi2Mono(unsigned chanmask, std::size_t const step, std::span const dst, void const *const src) noexcept { const auto scale = std::sqrt(1.0f / gsl::narrow_cast(std::popcount(chanmask))); @@ -174,7 +174,7 @@ void Multi2Mono(unsigned chanmask, usize const step, std::span const dst, } // namespace auto SampleConverter::Create(DevFmtType const srcType, DevFmtType const dstType, - usize const numchans, unsigned const srcRate, unsigned const dstRate, + std::size_t const numchans, unsigned const srcRate, unsigned const dstRate, Resampler const resampler) -> SampleConverterPtr { auto converter = SampleConverterPtr{}; @@ -200,7 +200,7 @@ auto SampleConverter::Create(DevFmtType const srcType, DevFmtType const dstType, if(converter->mIncrement == MixerFracOne) { converter->mResample = [](InterpState const*, std::span const src, unsigned, - unsigned const, std::span const dst) + unsigned const, std::span const dst) noexcept NONBLOCKING { std::ranges::copy(src | std::views::drop(MaxResamplerEdge) | std::views::take(dst.size()), dst.begin()); @@ -356,10 +356,10 @@ auto SampleConverter::convertPlanar(void const **const src, unsigned *const srcf for(const auto chan : std::views::iota(0_uz, mChan.size())) { auto samples = std::span{static_cast(srcs[chan]), - NumSrcSamples*usize{mSrcTypeSize}}; + NumSrcSamples*std::size_t{mSrcTypeSize}}; LoadSamples(std::span{mChan[chan].PrevSamples}.subspan(prepcount, readable), samples.data(), 0, 1, mSrcType); - srcs[chan] = samples.subspan(usize{mSrcTypeSize}*readable).data(); + srcs[chan] = samples.subspan(std::size_t{mSrcTypeSize}*readable).data(); } mSrcPrepCount = prepcount + readable; @@ -406,7 +406,7 @@ auto SampleConverter::convertPlanar(void const **const src, unsigned *const srcf mResample(&mState, SrcData, DataPosFrac, increment, DstData.first(DstSize)); auto DstSamples = std::span{static_cast(dsts[chan]), - usize{mDstTypeSize}*dstframes}.subspan(pos*usize{mDstTypeSize}); + std::size_t{mDstTypeSize}*dstframes}.subspan(pos*std::size_t{mDstTypeSize}); StoreSamples(DstSamples.data(), DstData.first(DstSize), 0, 1, mDstType); } @@ -421,8 +421,8 @@ auto SampleConverter::convertPlanar(void const **const src, unsigned *const srcf std::ranges::for_each(srcs, [this,NumSrcSamples,srcread](void const *&srcref) { auto const srcspan = std::span{static_cast(srcref), - usize{mSrcTypeSize}*NumSrcSamples}; - srcref = srcspan.subspan(usize{mSrcTypeSize}*srcread).data(); + std::size_t{mSrcTypeSize}*NumSrcSamples}; + srcref = srcspan.subspan(std::size_t{mSrcTypeSize}*srcread).data(); }); NumSrcSamples -= srcread; diff --git a/3rdparty/openal/core/converter.h b/3rdparty/openal/core/converter.h index 0a46496a3103..92f571a299c7 100644 --- a/3rdparty/openal/core/converter.h +++ b/3rdparty/openal/core/converter.h @@ -1,11 +1,12 @@ #ifndef CORE_CONVERTER_H #define CORE_CONVERTER_H +#include +#include #include #include #include "almalloc.h" -#include "altypes.hpp" #include "devformat.h" #include "flexarray.h" #include "mixer/defs.h" @@ -13,7 +14,7 @@ class SampleConverter { - explicit SampleConverter(usize const numchans) : mChan{numchans} { } + explicit SampleConverter(std::size_t const numchans) : mChan{numchans} { } public: DevFmtType mSrcType{}; @@ -43,12 +44,13 @@ class SampleConverter { using SampleOffset = std::chrono::duration>; [[nodiscard]] auto currentInputDelay() const noexcept -> SampleOffset { - auto const prep = i64{mSrcPrepCount} - MaxResamplerEdge; - return SampleOffset{(prep< std::unique_ptr; + static auto Create(DevFmtType srcType, DevFmtType dstType, std::size_t numchans, + unsigned srcRate, unsigned dstRate, Resampler resampler) + -> std::unique_ptr; DEF_FAM_NEWDEL(SampleConverter, mChan) }; diff --git a/3rdparty/openal/core/cpu_caps.cpp b/3rdparty/openal/core/cpu_caps.cpp index ba5d171d8809..6f5d12441860 100644 --- a/3rdparty/openal/core/cpu_caps.cpp +++ b/3rdparty/openal/core/cpu_caps.cpp @@ -4,7 +4,7 @@ #include "cpu_caps.h" -#if defined(_WIN32) && (defined(_M_ARM) || defined(_M_ARM64)) +#if defined(_WIN32) && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) #include #ifndef PF_ARM_NEON_INSTRUCTIONS_AVAILABLE #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19 @@ -39,7 +39,7 @@ inline auto get_cpuid(unsigned int f) -> std::array #define CAN_GET_CPUID #elif defined(HAVE_CPUID_INTRINSIC) \ - && (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)) + && (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC))) using reg_type = int; inline auto get_cpuid(unsigned int f) -> std::array @@ -137,7 +137,7 @@ auto GetCPUInfo() -> std::optional #if HAVE_NEON #ifdef __ARM_NEON ret.mCaps |= CPU_CAP_NEON; -#elif defined(_WIN32) && (defined(_M_ARM) || defined(_M_ARM64)) +#elif defined(_WIN32) && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) if(IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE)) ret.mCaps |= CPU_CAP_NEON; #else diff --git a/3rdparty/openal/core/cubic_tables.cpp b/3rdparty/openal/core/cubic_tables.cpp index 48bedde72b40..846201fba7f3 100644 --- a/3rdparty/openal/core/cubic_tables.cpp +++ b/3rdparty/openal/core/cubic_tables.cpp @@ -7,7 +7,7 @@ #include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "cubic_defs.h" #include "gsl/gsl" diff --git a/3rdparty/openal/core/decoderbase.hpp b/3rdparty/openal/core/decoderbase.hpp new file mode 100644 index 000000000000..12cbda5afb29 --- /dev/null +++ b/3rdparty/openal/core/decoderbase.hpp @@ -0,0 +1,38 @@ +#ifndef CORE_DECODERBASE_HPP +#define CORE_DECODERBASE_HPP + +#include +#include + + +struct DecoderBase { + static constexpr auto sMaxPadding = std::size_t{256}; + + /* For 2-channel UHJ, shelf filters should use these LF responses. */ + static constexpr auto sWLFScale = 0.661f; + static constexpr auto sXYLFScale = 1.293f; + + DecoderBase() = default; + DecoderBase(const DecoderBase&) = delete; + DecoderBase(DecoderBase&&) = delete; + virtual ~DecoderBase() = default; + + void operator=(const DecoderBase&) = delete; + void operator=(DecoderBase&&) = delete; + + virtual void decode(std::span> samples, bool updateState) = 0; + + /** + * The width factor for Super Stereo processing. Can be changed in between + * calls to decode, with valid values being between 0...0.7. + * + * 0.46 seems to produce the least amount of channel bleed when the output + * is subsequently UHJ encoded (given a stereo sound with a noise on the + * left buffer channel, for instance, when decoded with UhjStereoDecoder + * and then encoded with UhjEncoder, the right output channel was at its + * quietest). + */ + float mWidthControl{0.46f}; +}; + +#endif /* CORE_DECODERBASE_HPP */ diff --git a/3rdparty/openal/core/device.cpp b/3rdparty/openal/core/device.cpp index a0fd91974985..8f248719bd69 100644 --- a/3rdparty/openal/core/device.cpp +++ b/3rdparty/openal/core/device.cpp @@ -17,12 +17,12 @@ DeviceBase::DeviceBase(DeviceType type) DeviceBase::~DeviceBase() = default; -auto DeviceBase::removeContext(ContextBase *context) -> size_t +auto DeviceBase::removeContext(ContextBase *context) -> usize { auto oldarray = std::span{*mContexts.load(std::memory_order_acquire)}; if(const auto toremove = std::ranges::count(oldarray, context)) { - const auto newsize = oldarray.size() - gsl::narrow_cast(toremove); + const auto newsize = oldarray.size() - gsl::narrow_cast(toremove); auto newarray = ContextArray::Create(newsize); /* Copy the current/old context handles to the new array, excluding the diff --git a/3rdparty/openal/core/device.h b/3rdparty/openal/core/device.h index 64c7628e77ec..026a2c546d8f 100644 --- a/3rdparty/openal/core/device.h +++ b/3rdparty/openal/core/device.h @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -18,15 +17,17 @@ #include "alnumeric.h" #include "ambidefs.h" #include "atomic.h" +#include "bitset.hpp" #include "bufferline.h" +#include "decoderbase.hpp" #include "devformat.h" +#include "encoderbase.hpp" #include "filters/nfc.h" #include "flexarray.h" #include "gsl/gsl" #include "intrusive_ptr.h" #include "mixer/hrtfdefs.h" #include "resampler_limits.h" -#include "uhjfilter.h" #include "vector.h" class BFormatDec; @@ -80,7 +81,7 @@ struct InputRemixMap { class DistanceComp { - explicit DistanceComp(usize const count) : mSamples{count} { } + explicit DistanceComp(std::size_t const count) : mSamples{count} { } public: /* Maximum delay in samples for speaker distance compensation. */ @@ -94,14 +95,14 @@ class DistanceComp { std::array mChannels{}; al::FlexArray mSamples; - static auto Create(usize const numsamples) -> std::unique_ptr + static auto Create(std::size_t const numsamples) -> std::unique_ptr { return std::unique_ptr{new(FamCount{numsamples}) DistanceComp{numsamples}}; } DEF_FAM_NEWDEL(DistanceComp, mSamples) }; -constexpr auto InvalidChannelIndex = ~0_u8; +inline constexpr auto InvalidChannelIndex = ~0_u8; struct BFChannelConfig { float Scale; @@ -122,7 +123,7 @@ struct MixParams { * destination channel is InvalidChannelIndex, the given source channel is * not used for output. */ - template F> + template F> void setAmbiMixParams(MixParams const &inmix, float const gainbase, F func) const { auto const numIn = inmix.Buffer.size(); @@ -191,7 +192,7 @@ using PostProcess = std::variant; -enum { +enum class DeviceFlag : u8::value_t { // Frequency was requested by the app or config file FrequencyRequest, // Channel configuration was requested by the app or config file @@ -211,7 +212,7 @@ enum { */ Virtualization, - DeviceFlagsCount + MaxValue = Virtualization }; enum class DeviceState : u8::value_t { @@ -244,7 +245,7 @@ struct DeviceBase { DevAmbiScaling mAmbiScale{DevAmbiScaling::Default}; // Device flags - std::bitset Flags; + al::bitset mFlags; DeviceState mDeviceState{DeviceState::Unprepared}; unsigned NumAuxSends{}; @@ -275,7 +276,7 @@ struct DeviceBase { AmbiRotateMatrix mAmbiRotateMatrix2{}; /* Temp storage used for mixer processing. */ - static constexpr auto MixerLineSize = usize{BufferLineSize + DecoderBase::sMaxPadding}; + static constexpr auto MixerLineSize = std::size_t{BufferLineSize + DecoderBase::sMaxPadding}; static constexpr auto MixerChannelsMax = 25_uz; alignas(16) std::array mSampleData{}; alignas(16) std::array mResampleData{}; @@ -382,16 +383,16 @@ struct DeviceBase { + mClockBaseSec.load(std::memory_order_relaxed) + ns; } - static void Process(std::monostate const&, usize const) { } - void Process(AmbiDecPostProcess const &proc, usize SamplesToDo) const; - void Process(HrtfPostProcess const &proc, usize SamplesToDo); - void Process(UhjPostProcess const &proc, usize SamplesToDo); - void Process(TsmePostProcess const &proc, usize SamplesToDo); - void Process(StablizerPostProcess const &proc, usize SamplesToDo); - void Process(Bs2bPostProcess const &proc, usize SamplesToDo); + static void Process(std::monostate const&, std::size_t const) { } + void Process(AmbiDecPostProcess const &proc, std::size_t SamplesToDo) const; + void Process(HrtfPostProcess const &proc, std::size_t SamplesToDo); + void Process(UhjPostProcess const &proc, std::size_t SamplesToDo); + void Process(TsmePostProcess const &proc, std::size_t SamplesToDo); + void Process(StablizerPostProcess const &proc, std::size_t SamplesToDo); + void Process(Bs2bPostProcess const &proc, std::size_t SamplesToDo); void renderSamples(std::span outBuffers, unsigned numSamples); - void renderSamples(void *outBuffer, unsigned numSamples, usize frameStep); + void renderSamples(void *outBuffer, unsigned numSamples, std::size_t frameStep); /* Caller must lock the device state, and the mixer must not be running. */ void doDisconnect(std::string&& msg); diff --git a/3rdparty/openal/core/encoderbase.hpp b/3rdparty/openal/core/encoderbase.hpp index 7de41f3d87fb..a32b53f5faac 100644 --- a/3rdparty/openal/core/encoderbase.hpp +++ b/3rdparty/openal/core/encoderbase.hpp @@ -1,10 +1,9 @@ #ifndef CORE_ENCODERBASE_HPP #define CORE_ENCODERBASE_HPP +#include #include -#include "altypes.hpp" - struct EncoderBase { EncoderBase() = default; @@ -15,7 +14,7 @@ struct EncoderBase { auto operator=(const EncoderBase&) -> void = delete; auto operator=(EncoderBase&&) -> void = delete; - virtual auto getDelay() noexcept -> usize = 0; + virtual auto getDelay() noexcept -> std::size_t = 0; /** Encodes a 2-channel output signal from a B-Format input signal. */ virtual auto encode(std::span LeftOut, std::span RightOut, diff --git a/3rdparty/openal/core/filters/biquad.cpp b/3rdparty/openal/core/filters/biquad.cpp index be2931c31cd6..0c650b6c8944 100644 --- a/3rdparty/openal/core/filters/biquad.cpp +++ b/3rdparty/openal/core/filters/biquad.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,7 @@ static_assert(std::popcount(gsl::narrow(SamplesPerStep)) == 1, /* Sets dst to the given value, returns true if it's meaningfully different. */ [[nodiscard]] -auto check_set(float &dst, float const value) noexcept -> bool +auto check_set(float &dst, float const value) noexcept NONBLOCKING -> bool { const auto is_diff = !(std::abs(value - dst) <= 0.015625f/* 1/64 */); dst = value; @@ -45,7 +46,7 @@ auto check_set(float &dst, float const value) noexcept -> bool auto BiquadFilter::SetParams(BiquadType const type, float const f0norm, float gain, - float const rcpQ, Coefficients &coeffs) -> bool + float const rcpQ, Coefficients &coeffs) noexcept NONBLOCKING -> bool { /* HACK: Limit gain to -100dB. This shouldn't ever happen, all callers * already clamp to minimum of 0.001, or have a limited range of values @@ -128,7 +129,7 @@ auto BiquadFilter::SetParams(BiquadType const type, float const f0norm, float ga } void BiquadInterpFilter::setParams(BiquadType const type, float const f0norm, float const gain, - float const rcpQ) + float const rcpQ) noexcept NONBLOCKING { if(!SetParams(type, f0norm, gain, rcpQ, mTargetCoeffs)) { @@ -147,7 +148,7 @@ void BiquadInterpFilter::setParams(BiquadType const type, float const f0norm, fl } } -void BiquadInterpFilter::copyParamsFrom(BiquadInterpFilter const &other) noexcept +void BiquadInterpFilter::copyParamsFrom(BiquadInterpFilter const &other) noexcept NONBLOCKING { auto is_diff = check_set(mTargetCoeffs.mB0, other.mTargetCoeffs.mB0); is_diff |= check_set(mTargetCoeffs.mB1, other.mTargetCoeffs.mB1); @@ -172,7 +173,8 @@ void BiquadInterpFilter::copyParamsFrom(BiquadInterpFilter const &other) noexcep } -void BiquadFilter::process(std::span const src, std::span const dst) +void BiquadFilter::process(std::span const src, std::span const dst) noexcept + NONBLOCKING { auto z1 = mZ1; auto z2 = mZ2; @@ -198,12 +200,13 @@ void BiquadFilter::process(std::span const src, std::span co mZ2 = z2; } -void BiquadInterpFilter::process(std::span src, std::span dst) +void BiquadInterpFilter::process(std::span src, std::span dst) noexcept + NONBLOCKING { if(mCounter > 0) { auto counter = mCounter / SamplesPerStep; - auto steprem = gsl::narrow_cast(SamplesPerStep - (mCounter&SamplesPerStepMask)); + auto steprem = gsl::narrow_cast(SamplesPerStep-(mCounter&SamplesPerStepMask)); while(counter > 0) { auto const td = std::min(steprem, src.size()); @@ -249,7 +252,7 @@ void BiquadInterpFilter::process(std::span src, std::span ds void BiquadFilter::dualProcess(BiquadFilter &other, std::span const src, - std::span const dst) + std::span const dst) noexcept NONBLOCKING { ASSUME(this != &other); auto z01 = mZ1; @@ -279,13 +282,14 @@ void BiquadFilter::dualProcess(BiquadFilter &other, std::span const } void BiquadInterpFilter::dualProcess(BiquadInterpFilter &other, std::span src, - std::span dst) + std::span dst) noexcept NONBLOCKING { ASSUME(this != &other); if(auto const maxcounter = std::max(mCounter, other.mCounter); maxcounter > 0) { auto counter = maxcounter / SamplesPerStep; - auto steprem = gsl::narrow_cast(SamplesPerStep - (maxcounter&SamplesPerStepMask)); + auto steprem = gsl::narrow_cast( + SamplesPerStep - (maxcounter&SamplesPerStepMask)); while(counter > 0) { auto const td = std::min(steprem, src.size()); diff --git a/3rdparty/openal/core/filters/biquad.h b/3rdparty/openal/core/filters/biquad.h index e9fda2823e96..94e1d7c6dfd7 100644 --- a/3rdparty/openal/core/filters/biquad.h +++ b/3rdparty/openal/core/filters/biquad.h @@ -50,7 +50,7 @@ class BiquadFilter { Coefficients mCoeffs; static auto SetParams(BiquadType type, float f0norm, float gain, float rcpQ, - Coefficients &coeffs) -> bool; + Coefficients &coeffs) noexcept NONBLOCKING -> bool; /** * Calculates the rcpQ (i.e. 1/Q) coefficient for shelving filters, using @@ -58,7 +58,7 @@ class BiquadFilter { * \param gain 0 < gain * \param slope 0 < slope <= 1 */ - static auto rcpQFromSlope(float const gain, float const slope) -> float + static auto rcpQFromSlope(float const gain, float const slope) noexcept NONBLOCKING -> float { return std::sqrt((gain + 1.0f/gain)*(1.0f/slope - 1.0f) + 2.0f); } /** @@ -67,14 +67,15 @@ class BiquadFilter { * \param f0norm 0 < f0norm < 0.5. * \param bandwidth 0 < bandwidth */ - static auto rcpQFromBandwidth(float const f0norm, float const bandwidth) -> float + static + auto rcpQFromBandwidth(float const f0norm, float const bandwidth) noexcept NONBLOCKING -> float { const auto w0 = std::numbers::pi_v*2.0f * f0norm; return 2.0f*std::sinh(std::log(2.0f)/2.0f*bandwidth*w0/std::sin(w0)); } public: - void clear() noexcept { mZ1 = mZ2 = 0.0f; } + void clear() noexcept NONBLOCKING { mZ1 = mZ2 = 0.0f; } /** * Sets the filter state for the specified filter type and its parameters. @@ -89,7 +90,7 @@ class BiquadFilter { * \param slope Slope steepness of the transition band. */ void setParamsFromSlope(BiquadType const type, float const f0norm, float gain, - float const slope) + float const slope) noexcept NONBLOCKING { gain = std::max(gain, 0.001f); /* Limit -60dB */ SetParams(type, f0norm, gain, rcpQFromSlope(gain, slope), mCoeffs); @@ -108,20 +109,23 @@ class BiquadFilter { * \param bandwidth Normalized bandwidth of the transition band. */ void setParamsFromBandwidth(BiquadType const type, float const f0norm, float const gain, - float const bandwidth) + float const bandwidth) noexcept NONBLOCKING { SetParams(type, f0norm, gain, rcpQFromBandwidth(f0norm, bandwidth), mCoeffs); } - void copyParamsFrom(BiquadFilter const &other) noexcept + void copyParamsFrom(BiquadFilter const &other) noexcept NONBLOCKING { mCoeffs = other.mCoeffs; } - void process(std::span src, std::span dst); + void process(std::span src, std::span dst) noexcept NONBLOCKING; /** Processes this filter and the other at the same time. */ - void dualProcess(BiquadFilter &other, std::span src, std::span dst); + void dualProcess(BiquadFilter &other, std::span src, std::span dst) + noexcept NONBLOCKING; /* Rather hacky. It's just here to support "manual" processing. */ - [[nodiscard]] auto getComponents() const noexcept -> std::array { return {mZ1,mZ2}; } - void setComponents(float const z1, float const z2) noexcept { mZ1 = z1; mZ2 = z2; } - [[nodiscard]] auto processOne(float const in, float &z1, float &z2) const noexcept -> float + [[nodiscard]] + auto getComponents() const noexcept NONBLOCKING -> std::array { return {mZ1,mZ2}; } + void setComponents(float const z1, float const z2) noexcept NONBLOCKING { mZ1 = z1; mZ2 = z2; } + [[nodiscard]] + auto processOne(float const in, float &z1, float &z2) const noexcept NONBLOCKING -> float { const auto out = in*mCoeffs.mB0 + z1; z1 = in*mCoeffs.mB1 - out*mCoeffs.mA1 + z2; @@ -134,10 +138,10 @@ class BiquadInterpFilter : protected BiquadFilter { Coefficients mTargetCoeffs; int mCounter{-1}; - void setParams(BiquadType type, float f0norm, float gain, float rcpQ); + void setParams(BiquadType type, float f0norm, float gain, float rcpQ) noexcept NONBLOCKING; public: - void reset() noexcept + void reset() noexcept NONBLOCKING { BiquadFilter::clear(); mTargetCoeffs = Coefficients{}; @@ -145,7 +149,7 @@ class BiquadInterpFilter : protected BiquadFilter { mCounter = -1; } - void clear() noexcept + void clear() noexcept NONBLOCKING { BiquadFilter::clear(); mCoeffs = mTargetCoeffs; @@ -165,7 +169,7 @@ class BiquadInterpFilter : protected BiquadFilter { * \param slope Slope steepness of the transition band. */ void setParamsFromSlope(BiquadType const type, float const f0norm, float gain, - float const slope) + float const slope) noexcept NONBLOCKING { gain = std::max(gain, 0.001f); /* Limit -60dB */ setParams(type, f0norm, gain, rcpQFromSlope(gain, slope)); @@ -184,28 +188,31 @@ class BiquadInterpFilter : protected BiquadFilter { * \param bandwidth Normalized bandwidth of the transition band. */ void setParamsFromBandwidth(BiquadType const type, float const f0norm, float const gain, - float const bandwidth) + float const bandwidth) noexcept NONBLOCKING { setParams(type, f0norm, gain, rcpQFromBandwidth(f0norm, bandwidth)); } - void copyParamsFrom(const BiquadInterpFilter &other) noexcept; + void copyParamsFrom(const BiquadInterpFilter &other) noexcept NONBLOCKING; - void process(std::span src, std::span dst); + void process(std::span src, std::span dst) noexcept NONBLOCKING; /** Processes this filter and the other at the same time. */ - void dualProcess(BiquadInterpFilter &other, std::span src, std::span dst); + void dualProcess(BiquadInterpFilter &other, std::span src, std::span dst) + noexcept NONBLOCKING; }; struct DualBiquad { BiquadFilter &f0, &f1; - void process(std::span const src, std::span const dst) const + void process(std::span const src, std::span const dst) const noexcept + NONBLOCKING { f0.dualProcess(f1, src, dst); } }; struct DualBiquadInterp { BiquadInterpFilter &f0, &f1; - void process(std::span const src, std::span const dst) const + void process(std::span const src, std::span const dst) const noexcept + NONBLOCKING { f0.dualProcess(f1, src, dst); } }; diff --git a/3rdparty/openal/core/filters/nfc.cpp b/3rdparty/openal/core/filters/nfc.cpp index 09a232423b3a..708037d3792a 100644 --- a/3rdparty/openal/core/filters/nfc.cpp +++ b/3rdparty/openal/core/filters/nfc.cpp @@ -15,10 +15,10 @@ * compensated for using a bass-cut given the playback speaker distance, to * avoid excessive bass in the playback. * - * For real-time rendered audio, emulating the near-field effect based on the - * sound source's distance, and subsequently compensating for it at output - * based on the speaker distances, can create a more realistic perception of - * sound distance beyond a simple 1/r attenuation. + * Emulating the near-field effect based on the sound source's distance, and + * subsequently compensating for it at output based on the speaker distances, + * can create a more realistic perception of sound distance compared to a + * simple 1/r attenuation. * * These filters do just that. Each one applies a low-shelf filter, created as * the combination of a bass-boost for a given sound source distance (near- @@ -53,7 +53,7 @@ constexpr auto B2 = std::array{ 3.0f, 3.0f}; constexpr auto B3 = std::array{3.6778f, 6.4595f, 2.3222f}; constexpr auto B4 = std::array{4.2076f, 11.4877f, 5.7924f, 9.1401f}; -auto NfcFilterCreate1(float const w1) noexcept -> NfcFilter1 +auto NfcFilterCreate1(float const w1) noexcept NONBLOCKING -> NfcFilter1 { auto nfc = NfcFilter1{}; @@ -72,7 +72,7 @@ auto NfcFilterCreate1(float const w1) noexcept -> NfcFilter1 return nfc; } -void NfcFilterAdjust1(NfcFilter1 *const nfc, float const w0) noexcept +void NfcFilterAdjust1(NfcFilter1 *const nfc, float const w0) noexcept NONBLOCKING { auto const r = 0.5f * w0; auto const b_00 = B1[0] * r; @@ -83,7 +83,7 @@ void NfcFilterAdjust1(NfcFilter1 *const nfc, float const w0) noexcept } -auto NfcFilterCreate2(float const w1) noexcept -> NfcFilter2 +auto NfcFilterCreate2(float const w1) noexcept NONBLOCKING -> NfcFilter2 { auto nfc = NfcFilter2{}; @@ -103,7 +103,7 @@ auto NfcFilterCreate2(float const w1) noexcept -> NfcFilter2 return nfc; } -void NfcFilterAdjust2(NfcFilter2 *const nfc, float const w0) noexcept +void NfcFilterAdjust2(NfcFilter2 *const nfc, float const w0) noexcept NONBLOCKING { const auto r = 0.5f * w0; const auto b_10 = B2[0] * r; @@ -116,7 +116,7 @@ void NfcFilterAdjust2(NfcFilter2 *const nfc, float const w0) noexcept } -auto NfcFilterCreate3(float const w1) noexcept -> NfcFilter3 +auto NfcFilterCreate3(float const w1) noexcept NONBLOCKING -> NfcFilter3 { auto nfc = NfcFilter3{}; @@ -140,7 +140,7 @@ auto NfcFilterCreate3(float const w1) noexcept -> NfcFilter3 return nfc; } -void NfcFilterAdjust3(NfcFilter3 *const nfc, float const w0) noexcept +void NfcFilterAdjust3(NfcFilter3 *const nfc, float const w0) noexcept NONBLOCKING { auto const r = 0.5f * w0; auto const b_10 = B3[0] * r; @@ -156,7 +156,7 @@ void NfcFilterAdjust3(NfcFilter3 *const nfc, float const w0) noexcept } -auto NfcFilterCreate4(float const w1) noexcept -> NfcFilter4 +auto NfcFilterCreate4(float const w1) noexcept NONBLOCKING -> NfcFilter4 { auto nfc = NfcFilter4{}; @@ -183,7 +183,7 @@ auto NfcFilterCreate4(float const w1) noexcept -> NfcFilter4 return nfc; } -void NfcFilterAdjust4(NfcFilter4 *const nfc, float const w0) noexcept +void NfcFilterAdjust4(NfcFilter4 *const nfc, float const w0) noexcept NONBLOCKING { auto const r = 0.5f * w0; auto const b_10 = B4[0] * r; @@ -202,7 +202,7 @@ void NfcFilterAdjust4(NfcFilter4 *const nfc, float const w0) noexcept } // namespace -void NfcFilter::init(float const w1) noexcept +void NfcFilter::init(float const w1) noexcept NONBLOCKING { first = NfcFilterCreate1(w1); second = NfcFilterCreate2(w1); @@ -210,7 +210,7 @@ void NfcFilter::init(float const w1) noexcept fourth = NfcFilterCreate4(w1); } -void NfcFilter::adjust(float const w0) noexcept +void NfcFilter::adjust(float const w0) noexcept NONBLOCKING { NfcFilterAdjust1(&first, w0); NfcFilterAdjust2(&second, w0); @@ -219,7 +219,8 @@ void NfcFilter::adjust(float const w0) noexcept } -void NfcFilter1::process(std::span const src, std::span const dst) +void NfcFilter1::process(std::span const src, std::span const dst) noexcept + NONBLOCKING { auto z = mZ; std::ranges::transform(src, dst.begin(), [coeffs0=mCoeffs, &z](float const in) -> float @@ -232,7 +233,8 @@ void NfcFilter1::process(std::span const src, std::span cons mZ = z; } -void NfcFilter2::process(std::span const src, std::span const dst) +void NfcFilter2::process(std::span const src, std::span const dst) noexcept + NONBLOCKING { auto z = mZ; std::ranges::transform(src, dst.begin(), [coeffs=mCoeffs,&z](float const in) noexcept -> float @@ -246,7 +248,8 @@ void NfcFilter2::process(std::span const src, std::span cons mZ = z; } -void NfcFilter3::process(std::span const src, std::span const dst) +void NfcFilter3::process(std::span const src, std::span const dst) noexcept + NONBLOCKING { auto z = mZ; std::ranges::transform(src, dst.begin(), [coeffs=mCoeffs,&z](float const in) noexcept -> float @@ -264,7 +267,8 @@ void NfcFilter3::process(std::span const src, std::span cons mZ = z; } -void NfcFilter4::process(std::span const src, std::span const dst) +void NfcFilter4::process(std::span const src, std::span const dst) noexcept + NONBLOCKING { auto z = mZ; std::ranges::transform(src, dst.begin(), [coeffs=mCoeffs,&z](float const in) noexcept -> float diff --git a/3rdparty/openal/core/filters/nfc.h b/3rdparty/openal/core/filters/nfc.h index 26047451e1ef..6ff1f7baef95 100644 --- a/3rdparty/openal/core/filters/nfc.h +++ b/3rdparty/openal/core/filters/nfc.h @@ -4,6 +4,8 @@ #include #include +#include "opthelpers.h" + struct NfcFilter1 { struct Coefficients { @@ -13,7 +15,7 @@ struct NfcFilter1 { Coefficients mCoeffs; std::array mZ{}; - void process(std::span src, std::span dst); + void process(std::span src, std::span dst) noexcept NONBLOCKING; }; struct NfcFilter2 { struct Coefficients { @@ -23,7 +25,7 @@ struct NfcFilter2 { Coefficients mCoeffs; std::array mZ{}; - void process(std::span src, std::span dst); + void process(std::span src, std::span dst) noexcept NONBLOCKING; }; struct NfcFilter3 { struct Coefficients { @@ -33,7 +35,7 @@ struct NfcFilter3 { Coefficients mCoeffs; std::array mZ{}; - void process(std::span src, std::span dst); + void process(std::span src, std::span dst) noexcept NONBLOCKING; }; struct NfcFilter4 { struct Coefficients { @@ -43,7 +45,7 @@ struct NfcFilter4 { Coefficients mCoeffs; std::array mZ{}; - void process(std::span src, std::span dst); + void process(std::span src, std::span dst) noexcept NONBLOCKING; }; class NfcFilter { @@ -63,23 +65,27 @@ class NfcFilter { * should not be too small relative to the control distance. */ - void init(float w1) noexcept; - void adjust(float w0) noexcept; + void init(float w1) noexcept NONBLOCKING; + void adjust(float w0) noexcept NONBLOCKING; /* Near-field control filter for first-order ambisonic channels (1-3). */ - void process1(std::span const src, std::span const dst) + void process1(std::span const src, std::span const dst) noexcept + NONBLOCKING { first.process(src, dst); } /* Near-field control filter for second-order ambisonic channels (4-8). */ - void process2(std::span const src, std::span const dst) + void process2(std::span const src, std::span const dst) noexcept + NONBLOCKING { second.process(src, dst); } /* Near-field control filter for third-order ambisonic channels (9-15). */ - void process3(std::span const src, std::span const dst) + void process3(std::span const src, std::span const dst) noexcept + NONBLOCKING { third.process(src, dst); } /* Near-field control filter for fourth-order ambisonic channels (16-24). */ - void process4(std::span const src, std::span const dst) + void process4(std::span const src, std::span const dst) noexcept + NONBLOCKING { fourth.process(src, dst); } }; diff --git a/3rdparty/openal/core/filters/splitter.cpp b/3rdparty/openal/core/filters/splitter.cpp index 05a67449a889..269f7128b4f0 100644 --- a/3rdparty/openal/core/filters/splitter.cpp +++ b/3rdparty/openal/core/filters/splitter.cpp @@ -12,7 +12,7 @@ #include "gsl/gsl" -void BandSplitter::init(float const f0norm) +void BandSplitter::init(float const f0norm) noexcept NONBLOCKING { auto const w = std::numbers::pi_v*2.0f * std::min(f0norm, 0.49f); if(auto const cw = std::cos(w); cw > std::numeric_limits::epsilon()) @@ -26,7 +26,7 @@ void BandSplitter::init(float const f0norm) } void BandSplitter::process(std::span const input, std::span const hpout, - std::span const lpout) + std::span const lpout) noexcept NONBLOCKING { auto const ap_coeff = mCoeff; auto const lp_coeff = mCoeff*0.5f + 0.5f; @@ -63,7 +63,7 @@ void BandSplitter::process(std::span const input, std::span } void BandSplitter::processHfScale(std::span const input, std::span const output, - float const hfscale) + float const hfscale) noexcept NONBLOCKING { auto const ap_coeff = mCoeff; auto const lp_coeff = mCoeff*0.5f + 0.5f; @@ -96,7 +96,8 @@ void BandSplitter::processHfScale(std::span const input, std::span< mApZ1 = ap_z1; } -void BandSplitter::processHfScale(std::span const samples, float const hfscale) +void BandSplitter::processHfScale(std::span const samples, float const hfscale) noexcept + NONBLOCKING { auto const ap_coeff = mCoeff; auto const lp_coeff = mCoeff*0.5f + 0.5f; @@ -130,7 +131,7 @@ void BandSplitter::processHfScale(std::span const samples, float const hf } void BandSplitter::processScale(std::span const samples, float const hfscale, - float const lfscale) + float const lfscale) noexcept NONBLOCKING { auto const ap_coeff = mCoeff; auto const lp_coeff = mCoeff*0.5f + 0.5f; @@ -159,7 +160,7 @@ void BandSplitter::processScale(std::span const samples, float const hfsc mApZ1 = ap_z1; } -void BandSplitter::processAllPass(std::span const samples) +void BandSplitter::processAllPass(std::span const samples) noexcept NONBLOCKING { auto const coeff = mCoeff; auto z1 = mApZ1; diff --git a/3rdparty/openal/core/filters/splitter.h b/3rdparty/openal/core/filters/splitter.h index bcc65742e05d..c73700fdeb7f 100644 --- a/3rdparty/openal/core/filters/splitter.h +++ b/3rdparty/openal/core/filters/splitter.h @@ -3,6 +3,7 @@ #include +#include "opthelpers.h" /* Band splitter. Splits a signal into two phase-matching frequency bands. */ class BandSplitter { @@ -17,20 +18,22 @@ class BandSplitter { explicit BandSplitter(float const f0norm) { init(f0norm); } auto operator=(BandSplitter const&) -> BandSplitter& = default; - void init(float f0norm); - void clear() noexcept { mLpZ1 = mLpZ2 = mApZ1 = 0.0f; } - void process(std::span input, std::span hpout, std::span lpout); + void init(float f0norm) noexcept NONBLOCKING; + void clear() noexcept NONBLOCKING { mLpZ1 = mLpZ2 = mApZ1 = 0.0f; } + void process(std::span input, std::span hpout, std::span lpout) + noexcept NONBLOCKING; - void processHfScale(std::span input, std::span output, float hfscale); + void processHfScale(std::span input, std::span output, float hfscale) + noexcept NONBLOCKING; - void processHfScale(std::span samples, float hfscale); - void processScale(std::span samples, float hfscale, float lfscale); + void processHfScale(std::span samples, float hfscale) noexcept NONBLOCKING; + void processScale(std::span samples, float hfscale, float lfscale) noexcept NONBLOCKING; /** * The all-pass portion of the band splitter. Applies the same phase shift * without splitting or scaling the signal. */ - void processAllPass(std::span samples); + void processAllPass(std::span samples) noexcept NONBLOCKING; }; #endif /* CORE_FILTERS_SPLITTER_H */ diff --git a/3rdparty/openal/core/fpu_ctrl.cpp b/3rdparty/openal/core/fpu_ctrl.cpp index 705242032dfa..3a8da32e71cc 100644 --- a/3rdparty/openal/core/fpu_ctrl.cpp +++ b/3rdparty/openal/core/fpu_ctrl.cpp @@ -31,7 +31,7 @@ namespace { [[maybe_unused]] auto disable_denormals() -> unsigned int { -#if HAVE_SSE_INTRINSICS +#if HAVE_SSE_INTRINSICS && !defined(__powerpc64__) const auto state = _mm_getcsr(); auto sseState = state; sseState &= ~(_MM_FLUSH_ZERO_MASK | _MM_DENORMALS_ZERO_MASK); @@ -39,7 +39,7 @@ auto disable_denormals() -> unsigned int _mm_setcsr(sseState); return state; -#elif HAVE_SSE +#elif HAVE_SSE && !defined(__powerpc64__) const auto state = _mm_getcsr(); auto sseState = state; @@ -65,7 +65,7 @@ auto disable_denormals() -> unsigned int [[maybe_unused]] void reset_fpu(unsigned int state [[maybe_unused]]) { -#if HAVE_SSE_INTRINSICS || HAVE_SSE +#if (HAVE_SSE_INTRINSICS || HAVE_SSE) && !defined(__powerpc64__) _mm_setcsr(state); #endif } diff --git a/3rdparty/openal/core/helpers.cpp b/3rdparty/openal/core/helpers.cpp index fe43ae396ef2..198cae07663a 100644 --- a/3rdparty/openal/core/helpers.cpp +++ b/3rdparty/openal/core/helpers.cpp @@ -24,9 +24,14 @@ #include "alstring.h" #include "filesystem.h" #include "gsl/gsl" -#include "logging.h" #include "strutils.hpp" +#if HAVE_CXXMODULES +import logging; +#else +#include "logging.h" +#endif + namespace { @@ -345,7 +350,7 @@ auto SearchDataFiles(const std::string_view ext, const std::string_view subdir) const auto datadirs = std::string{al::getenv("XDG_DATA_DIRS") .value_or("/usr/local/share/:/usr/share/")}; - auto curpos = 0_uz; + auto curpos = std::size_t{0}; while(curpos < datadirs.size()) { auto nextpos = datadirs.find(':', curpos); diff --git a/3rdparty/openal/core/hrtf.cpp b/3rdparty/openal/core/hrtf.cpp index 8f064c275dfc..d8aa8fbd1d68 100644 --- a/3rdparty/openal/core/hrtf.cpp +++ b/3rdparty/openal/core/hrtf.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -34,10 +33,15 @@ #include "helpers.h" #include "hrtf_loader.hpp" #include "hrtf_resource.hpp" -#include "logging.h" #include "mixer/hrtfdefs.h" #include "polyphase_resampler.h" +#if HAVE_CXXMODULES +import logging; +#else +#include "logging.h" +#endif + namespace { @@ -134,7 +138,7 @@ class databuf final : public std::streambuf { if(pos < 0 || pos > egptr()-eback()) return traits_type::eof(); - setg(eback(), eback()+gsl::narrow_cast(pos), egptr()); + setg(eback(), eback()+gsl::narrow_cast(pos), egptr()); return pos; } @@ -201,9 +205,9 @@ void HrtfStore::getCoeffs(float const elevation, float const azimuth, float cons /* Calculate the elevation indices. */ auto const elev0 = CalcEvIndex(field->evCount.c_val, elevation); - auto const elev1_idx = usize{std::min(elev0.idx+1u, field->evCount.c_val-1u)}; - auto const ir0offset = usize{mElev[ebase + elev0.idx].irOffset.c_val}; - auto const ir1offset = usize{mElev[ebase + elev1_idx].irOffset.c_val}; + auto const elev1_idx = std::size_t{std::min(elev0.idx+1u, field->evCount.c_val-1u)}; + auto const ir0offset = mElev[ebase + elev0.idx].irOffset.as().c_val; + auto const ir1offset = mElev[ebase + elev1_idx].irOffset.as().c_val; /* Calculate azimuth indices. */ auto const az0 = CalcAzIndex(mElev[ebase + elev0.idx].azCount.c_val, azimuth); @@ -226,16 +230,16 @@ void HrtfStore::getCoeffs(float const elevation, float const azimuth, float cons ( elev0.blend) * ( az1.blend) * dirfact}; /* Calculate the blended HRIR delays. */ - auto d = gsl::narrow_cast(mDelays[idx[0]][0].c_val)*blend[0] - + gsl::narrow_cast(mDelays[idx[1]][0].c_val)*blend[1] - + gsl::narrow_cast(mDelays[idx[2]][0].c_val)*blend[2] - + gsl::narrow_cast(mDelays[idx[3]][0].c_val)*blend[3]; + auto d = (mDelays[idx[0]][0].as()*blend[0] + + mDelays[idx[1]][0].as()*blend[1] + + mDelays[idx[2]][0].as()*blend[2] + + mDelays[idx[3]][0].as()*blend[3]).c_val; delays[0] = fastf2u(d * float{1.0f/HrirDelayFracOne}); - d = gsl::narrow_cast(mDelays[idx[0]][1].c_val)*blend[0] - + gsl::narrow_cast(mDelays[idx[1]][1].c_val)*blend[1] - + gsl::narrow_cast(mDelays[idx[2]][1].c_val)*blend[2] - + gsl::narrow_cast(mDelays[idx[3]][1].c_val)*blend[3]; + d = (mDelays[idx[0]][1].as()*blend[0] + + mDelays[idx[1]][1].as()*blend[1] + + mDelays[idx[2]][1].as()*blend[2] + + mDelays[idx[3]][1].as()*blend[3]).c_val; delays[1] = fastf2u(d * float{1.0f/HrirDelayFracOne}); /* Calculate the blended HRIR coefficients. */ @@ -254,7 +258,7 @@ void HrtfStore::getCoeffs(float const elevation, float const azimuth, float cons } -auto DirectHrtfState::Create(usize const num_chans) -> std::unique_ptr +auto DirectHrtfState::Create(std::size_t const num_chans) -> std::unique_ptr { return std::unique_ptr{new(FamCount{num_chans}) DirectHrtfState{num_chans}}; } void DirectHrtfState::build(HrtfStore const *const Hrtf, unsigned const irSize, @@ -275,7 +279,7 @@ void DirectHrtfState::build(HrtfStore const *const Hrtf, unsigned const irSize, std::ranges::transform(std::views::iota(0_uz, mChannels.size()), (mChannels | std::views::transform(&HrtfChannelState::mHfScale)).begin(), - [AmbiOrderHFGain](usize const idx) + [AmbiOrderHFGain](std::size_t const idx) { auto const order = AmbiIndex::OrderFromChannel[idx]; return AmbiOrderHFGain[order.c_val]; @@ -588,8 +592,7 @@ try { std::ranges::transform(new_delays, (delays | std::views::join).begin(), [delay_scale](float const fdelay) -> u8 { - return u8::make_from(al::saturate_cast( - float2int(fdelay*delay_scale + 0.5f))); + return u8::from(al::saturate_cast(float2int(fdelay*delay_scale + 0.5f))); }); /* Scale the IR size for the new sample rate and update the stored diff --git a/3rdparty/openal/core/hrtf.h b/3rdparty/openal/core/hrtf.h index 4a042695bb43..1f0a69649684 100644 --- a/3rdparty/openal/core/hrtf.h +++ b/3rdparty/openal/core/hrtf.h @@ -47,8 +47,8 @@ struct HrtfStore { void inc_ref() noexcept; void dec_ref() noexcept; - auto operator new(usize) -> void* = delete; - auto operator new[](usize) -> void* = delete; + auto operator new(std::size_t) -> void* = delete; + auto operator new[](std::size_t) -> void* = delete; void operator delete[](void*) noexcept = delete; void operator delete(gsl::owner block, void*) noexcept @@ -82,7 +82,7 @@ struct AngularPoint { class DirectHrtfState { - explicit DirectHrtfState(usize const numchans) : mChannels{numchans} { } + explicit DirectHrtfState(std::size_t const numchans) : mChannels{numchans} { } public: std::array mTemp{}; @@ -102,7 +102,7 @@ class DirectHrtfState { std::span const> AmbiMatrix, float XOverFreq, std::span AmbiOrderHFGain); - static auto Create(usize num_chans) -> std::unique_ptr; + static auto Create(std::size_t num_chans) -> std::unique_ptr; DEF_FAM_NEWDEL(DirectHrtfState, mChannels) }; diff --git a/3rdparty/openal/core/hrtf_loader.cpp b/3rdparty/openal/core/hrtf_loader.cpp index 36f3b32d2ed3..eef0acdef26f 100644 --- a/3rdparty/openal/core/hrtf_loader.cpp +++ b/3rdparty/openal/core/hrtf_loader.cpp @@ -17,7 +17,14 @@ #include "fmt/ranges.h" #include "gsl/gsl" #include "hrtf.h" + +#if HAVE_CXXMODULES +import format.types; +import logging; +#else +#include "alformattypes.hpp" #include "logging.h" +#endif namespace { @@ -166,7 +173,7 @@ auto readle(std::istream &data) -> T alignas(T) auto ret = std::array{}; if(!data.read(ret.data(), num_bits/8)) { - if constexpr(al::strong_number) + if constexpr(al::strict_number) return T{gsl::narrow_cast(EOF)}; else return gsl::narrow_cast(EOF); diff --git a/3rdparty/openal/core/hrtf_resource.cpp b/3rdparty/openal/core/hrtf_resource.cpp index 0c7c6280c4c9..91980bbf9f1f 100644 --- a/3rdparty/openal/core/hrtf_resource.cpp +++ b/3rdparty/openal/core/hrtf_resource.cpp @@ -8,24 +8,21 @@ #ifndef ALSOFT_EMBED_HRTF_DATA -auto GetHrtfResource(int name [[maybe_unused]]) noexcept -> std::span +auto GetHrtfResource(int const name [[maybe_unused]]) noexcept -> std::span { return {}; } #else namespace { -/* NOLINTNEXTLINE(*-avoid-c-arrays) */ -constexpr char hrtf_default[] = { -#include "default_hrtf.txt" -}; +#include "default_hrtf.hpp" } // namespace -auto GetHrtfResource(int name) noexcept -> std::span +auto GetHrtfResource(int const name) noexcept -> std::span { if(name == DefaultHrtfResourceID) - return hrtf_default; + return default_hrtf; return {}; } #endif diff --git a/3rdparty/openal/core/logging.cpp b/3rdparty/openal/core/logging.cpp index 0d9f9025fbd6..3306b3c4acd5 100644 --- a/3rdparty/openal/core/logging.cpp +++ b/3rdparty/openal/core/logging.cpp @@ -1,8 +1,7 @@ #include "config.h" -#include "logging.h" - +#include #include #include #include @@ -11,8 +10,10 @@ #include #include +#include "alformat.hpp" #include "alnumeric.h" #include "alstring.h" +#include "filesystem.h" #include "fmt/std.h" #include "strutils.hpp" @@ -23,6 +24,12 @@ #include #endif +#if HAVE_CXXMODULES +import logging; +#else +#include "logging.h" +#endif + #ifdef _DEBUG LogLevel gLogLevel{LogLevel::Warning}; @@ -36,7 +43,7 @@ using namespace std::string_view_literals; using lpvoid = void*; -enum class LogState : u8::value_t { +enum class LogState : std::uint8_t { FirstRun, Ready, Disable diff --git a/3rdparty/openal/core/logging.cppm b/3rdparty/openal/core/logging.cppm new file mode 100644 index 000000000000..bbdd98c3e23a --- /dev/null +++ b/3rdparty/openal/core/logging.cppm @@ -0,0 +1,53 @@ +module; + +#include +#include + +#include "alformat.hpp" +#include "filesystem.h" +#include "gsl/gsl" +#include "opthelpers.h" + + +export module logging; + +export { + +enum class LogLevel : std::uint8_t { + Disable, + Error, + Warning, + Trace +}; + +using LogCallbackFunc = auto(*)(void *userptr, char level, gsl::czstring message, int length) + noexcept -> void; + +extern "C++" { +DECL_HIDDEN extern LogLevel gLogLevel; + +void al_set_log_callback(LogCallbackFunc callback, void *userptr); + +void al_open_logfile(fs::path const &fname); +void al_print_impl(LogLevel level, al::string_view fmt, al::format_args&& args); +} /* extern "C++" */ + +template +void al_print(LogLevel const level, al::format_string const fmt, Args&& ...args) noexcept +try { + al_print_impl(level, fmt.get(), al::make_format_args(args...)); +} catch(...) { /* Swallow all exceptions */ } + +template +void TRACE(al::format_string const fmt, Args&& ...args) noexcept +{ al_print(LogLevel::Trace, fmt, std::forward(args)...); } + +template +void WARN(al::format_string const fmt, Args&& ...args) noexcept +{ al_print(LogLevel::Warning, fmt, std::forward(args)...); } + +template +void ERR(al::format_string const fmt, Args&& ...args) noexcept +{ al_print(LogLevel::Error, fmt, std::forward(args)...); } + +} diff --git a/3rdparty/openal/core/logging.h b/3rdparty/openal/core/logging.h index 858b0a4e8eb7..72472b84824e 100644 --- a/3rdparty/openal/core/logging.h +++ b/3rdparty/openal/core/logging.h @@ -1,16 +1,16 @@ #ifndef CORE_LOGGING_H #define CORE_LOGGING_H +#include #include #include "alformat.hpp" -#include "alnumeric.h" #include "filesystem.h" #include "gsl/gsl" #include "opthelpers.h" -enum class LogLevel : u8::value_t { +enum class LogLevel : std::uint8_t { Disable, Error, Warning, diff --git a/3rdparty/openal/core/mastering.cpp b/3rdparty/openal/core/mastering.cpp index 59c0fe4c82f3..6b7dd1b1ad54 100644 --- a/3rdparty/openal/core/mastering.cpp +++ b/3rdparty/openal/core/mastering.cpp @@ -22,11 +22,11 @@ static_assert((BufferLineSize & (BufferLineSize-1)) == 0, "BufferLineSize is not a power of 2"); struct SlidingHold { - alignas(16) FloatBufferLine mValues; - std::array mExpiries; + alignas(16) std::array mValues; + std::array mExpiries; unsigned mLowerIndex; unsigned mUpperIndex; - unsigned mLength; + sys_uint mLength; }; @@ -43,7 +43,7 @@ constexpr auto assume_aligned_span(const std::span s) noexcept -> std::span * * http://www.richardhartersworld.com/cri/2001/slidingmin.html */ -float UpdateSlidingHold(SlidingHold *Hold, unsigned const i, float const in) +auto UpdateSlidingHold(SlidingHold *Hold, unsigned const i, f32 const in) -> f32 { static constexpr auto mask = unsigned{BufferLineSize - 1}; const auto length = Hold->mLength; @@ -85,56 +85,54 @@ float UpdateSlidingHold(SlidingHold *Hold, unsigned const i, float const in) return values[upperIndex]; } -void ShiftSlidingHold(SlidingHold *Hold, unsigned const n) +void ShiftSlidingHold(SlidingHold *Hold, sys_uint const n) { if(Hold->mLowerIndex < Hold->mUpperIndex) { auto expiries = std::span{Hold->mExpiries}.first(Hold->mLowerIndex+1); - std::ranges::transform(expiries, expiries.begin(), [n](unsigned const e) { return e-n; }); + std::ranges::transform(expiries, expiries.begin(), [n](sys_uint const e) { return e-n; }); expiries = std::span{Hold->mExpiries}.subspan(Hold->mUpperIndex); - std::ranges::transform(expiries, expiries.begin(), [n](unsigned const e) { return e-n; }); + std::ranges::transform(expiries, expiries.begin(), [n](sys_uint const e) { return e-n; }); } else { const auto expiries = std::span{Hold->mExpiries}.first(Hold->mLowerIndex+1) .subspan(Hold->mUpperIndex); - std::ranges::transform(expiries, expiries.begin(), [n](unsigned const e) { return e-n; }); + std::ranges::transform(expiries, expiries.begin(), [n](sys_uint const e) { return e-n; }); } } } // namespace -auto Compressor::Create(const size_t NumChans, const float SampleRate, const FlagBits AutoFlags, - const float LookAheadTime, const float HoldTime, const float PreGainDb, const float PostGainDb, - const float ThresholdDb, const float Ratio, const float KneeDb, const float AttackTime, - const float ReleaseTime) -> std::unique_ptr +auto Compressor::Create(Params const params) -> std::unique_ptr { - const auto lookAhead = gsl::narrow_cast(std::clamp( - std::round(LookAheadTime*SampleRate), 0.0f, BufferLineSize-1.0f)); - const auto hold = gsl::narrow_cast(std::clamp(std::round(HoldTime*SampleRate), 0.0f, - BufferLineSize-1.0f)); + const auto lookAhead = std::clamp(round(params.LookAheadTime*params.SampleRate), 0.0_f32, + f32{BufferLineSize-1.0f}).reinterpret_as(); + const auto hold = std::clamp(round(params.HoldTime*params.SampleRate), 0.0_f32, + f32{BufferLineSize-1.0f}).reinterpret_as(); auto Comp = std::make_unique(PrivateToken{}); - Comp->mAuto.Knee = AutoFlags.test(AutoKnee); - Comp->mAuto.Attack = AutoFlags.test(AutoAttack); - Comp->mAuto.Release = AutoFlags.test(AutoRelease); - Comp->mAuto.PostGain = AutoFlags.test(AutoPostGain); - Comp->mAuto.Declip = AutoFlags.test(AutoPostGain) && AutoFlags.test(AutoDeclip); - Comp->mLookAhead = lookAhead; - Comp->mPreGain = std::pow(10.0f, PreGainDb / 20.0f); - Comp->mPostGain = std::log(10.0f)/20.0f * PostGainDb; - Comp->mThreshold = std::log(10.0f)/20.0f * ThresholdDb; - Comp->mSlope = 1.0f / std::max(1.0f, Ratio) - 1.0f; - Comp->mKnee = std::max(0.0f, std::log(10.0f)/20.0f * KneeDb); - Comp->mAttack = std::max(1.0f, AttackTime * SampleRate); - Comp->mRelease = std::max(1.0f, ReleaseTime * SampleRate); + Comp->mAuto.Knee = params.AutoFlags.test(Flags::AutoKnee); + Comp->mAuto.Attack = params.AutoFlags.test(Flags::AutoAttack); + Comp->mAuto.Release = params.AutoFlags.test(Flags::AutoRelease); + Comp->mAuto.PostGain = params.AutoFlags.test(Flags::AutoPostGain); + Comp->mAuto.Declip = params.AutoFlags.test(Flags::AutoPostGain) + && params.AutoFlags.test(Flags::AutoDeclip); + Comp->mLookAhead = lookAhead.c_val; + Comp->mPreGain = pow(10.0_f32, params.PreGainDb / 20.0_f32); + Comp->mPostGain = (log(10.0_f64)/20.0_f64 * params.PostGainDb).cast_to(); + Comp->mThreshold = (log(10.0_f64)/20.0_f64 * params.ThresholdDb).cast_to(); + Comp->mSlope = 1.0_f32/std::max(1.0_f32, params.Ratio) - 1.0_f32; + Comp->mKnee = std::max(0.0_f64, log(10.0_f64)/20.0_f64 * params.KneeDb).cast_to(); + Comp->mAttack = std::max(1.0_f32, params.AttackTime * params.SampleRate); + Comp->mRelease = std::max(1.0_f32, params.ReleaseTime * params.SampleRate); /* Knee width automation actually treats the compressor as a limiter. By * varying the knee width, it can effectively be seen as applying * compression over a wide range of ratios. */ - if(AutoFlags.test(AutoKnee)) - Comp->mSlope = -1.0f; + if(params.AutoFlags.test(Flags::AutoKnee)) + Comp->mSlope = -1.0_f32; if(lookAhead > 0) { @@ -145,16 +143,16 @@ auto Compressor::Create(const size_t NumChans, const float SampleRate, const Fla if(hold > 1) { Comp->mHold = std::make_unique(); - Comp->mHold->mValues[0] = -std::numeric_limits::infinity(); + Comp->mHold->mValues[0] = -f32::infinity(); Comp->mHold->mExpiries[0] = hold; Comp->mHold->mLength = hold; } - Comp->mDelay.resize(NumChans, FloatBufferLine{}); + Comp->mDelay.resize(params.NumChans.c_val, FloatBufferLine{}); } - Comp->mCrestCoeff = std::exp(-1.0f / (0.200f * SampleRate)); // 200ms - Comp->mGainEstimate = Comp->mThreshold * -0.5f * Comp->mSlope; - Comp->mAdaptCoeff = std::exp(-1.0f / (2.0f * SampleRate)); // 2s + Comp->mCrestCoeff = exp(-1.0_f32 / (0.200_f32 * params.SampleRate)); // 200ms + Comp->mGainEstimate = Comp->mThreshold * -0.5_f32 * Comp->mSlope; + Comp->mAdaptCoeff = exp(-1.0_f32 / (2.0_f32 * params.SampleRate)); // 2s return Comp; } @@ -186,8 +184,8 @@ void Compressor::gainCompressor(unsigned const SamplesToDo) auto knee = mKnee; auto t_att = attack; auto t_rel = release - attack; - auto a_att = std::exp(-1.0f / t_att); - auto a_rel = std::exp(-1.0f / t_rel); + auto a_att = exp(-1.0_f32 / t_att); + auto a_rel = exp(-1.0_f32 / t_rel); auto y_1 = mLastRelease; auto y_L = mLastAttack; auto c_dev = mLastGainDev; @@ -197,30 +195,30 @@ void Compressor::gainCompressor(unsigned const SamplesToDo) std::ranges::transform(mSideChain | std::views::take(SamplesToDo), mSideChain | std::views::drop(mLookAhead), mSideChain.begin(), - [&](const float input, const float lookAhead) -> float + [&](f32 const input, f32 const lookAhead) -> f32 { if(autoKnee) - knee = std::max(0.0f, 2.5f*(c_dev + c_est)); - const auto knee_h = 0.5f * knee; + knee = std::max(0.0_f32, 2.5_f32*(c_dev + c_est)); + const auto knee_h = 0.5_f32 * knee; /* This is the gain computer. It applies a static compression curve to * the control signal. */ const auto x_over = lookAhead - threshold; - const auto y_G = (x_over <= -knee_h) ? 0.0f - : (std::fabs(x_over) < knee_h) ? (x_over+knee_h) * (x_over+knee_h) / (2.0f * knee) + const auto y_G = (x_over <= -knee_h) ? 0.0_f32 + : (x_over.abs() < knee_h) ? (x_over+knee_h) * (x_over+knee_h) / (2.0_f32 * knee) : x_over; const auto y2_crest = *(crestFactor++); if(autoAttack) { - t_att = 2.0f*attack/y2_crest; - a_att = std::exp(-1.0f / t_att); + t_att = 2.0_f32*attack/y2_crest; + a_att = exp(-1.0_f32 / t_att); } if(autoRelease) { - t_rel = 2.0f*release/y2_crest - t_att; - a_rel = std::exp(-1.0f / t_rel); + t_rel = 2.0_f32*release/y2_crest - t_att; + a_rel = exp(-1.0_f32 / t_rel); } /* Gain smoothing (ballistics) is done via a smooth decoupled peak @@ -252,7 +250,7 @@ void Compressor::gainCompressor(unsigned const SamplesToDo) postGain = -(c_dev + c_est); } - return std::exp(postGain - y_L); + return exp(postGain - y_L); }); mLastRelease = y_1; @@ -270,7 +268,7 @@ void Compressor::process(unsigned const SamplesToDo, std::span std::ranges::for_each(InOut, [SamplesToDo,preGain](const FloatBufferSpan input) -> void { std::ranges::transform(input | std::views::take(SamplesToDo), input.begin(), - [preGain](const float s) noexcept { return s * preGain; }); + [preGain](const float s) noexcept { return s * preGain.c_val; }); }); } @@ -278,12 +276,12 @@ void Compressor::process(unsigned const SamplesToDo, std::span * channels. */ const auto sideChain = std::span{mSideChain}.subspan(mLookAhead, SamplesToDo); - std::ranges::fill(sideChain, 0.0f); + std::ranges::fill(sideChain, 0.0_f32); std::ranges::for_each(InOut, [sideChain](const FloatBufferSpan input) -> void { std::ranges::transform(sideChain, input, sideChain.begin(), - [](const float s0, const float s1) noexcept -> float - { return std::max(s0, std::fabs(s1)); }); + [](f32 const s0, f32 const s1) noexcept -> f32 + { return std::max(s0, s1.abs()); }); }); if(mAuto.Attack || mAuto.Release) @@ -298,9 +296,9 @@ void Compressor::process(unsigned const SamplesToDo, std::span auto y2_rms = mLastRmsSq; std::ranges::transform(sideChain, mCrestFactor.begin(), - [&y2_rms,&y2_peak,a_crest](const float x_abs) noexcept -> float + [&y2_rms,&y2_peak,a_crest](f32 const x_abs) noexcept -> f32 { - const auto x2 = std::clamp(x_abs*x_abs, 0.000001f, 1000000.0f); + const auto x2 = f32{std::clamp(x_abs*x_abs, 0.000001_f32, 1000000.0_f32)}; y2_peak = std::max(x2, lerpf(x2, y2_peak, a_crest)); y2_rms = lerpf(x2, y2_rms, a_crest); @@ -318,9 +316,9 @@ void Compressor::process(unsigned const SamplesToDo, std::span * operating as a limiter. */ auto i = 0u; - std::ranges::transform(sideChain, sideChain.begin(), [&i,hold](const float x_abs) -> float + std::ranges::transform(sideChain, sideChain.begin(), [&i,hold](f32 const x_abs) -> f32 { - const auto x_G = std::log(std::max(0.000001f, x_abs)); + auto const x_G = log(std::max(0.000001_f32, x_abs)); return UpdateSlidingHold(hold, i++, x_G); }); ShiftSlidingHold(hold, SamplesToDo); @@ -331,8 +329,8 @@ void Compressor::process(unsigned const SamplesToDo, std::span * absolute value of the incoming signal) and performs most of its * operations in the log domain. */ - std::ranges::transform(sideChain, sideChain.begin(), [](const float s) -> float - { return std::log(std::max(0.000001f, s)); }); + std::ranges::transform(sideChain, sideChain.begin(), [](f32 const s) -> f32 + { return log(std::max(0.000001_f32, s)); }); } gainCompressor(SamplesToDo); @@ -372,7 +370,8 @@ void Compressor::process(unsigned const SamplesToDo, std::span std::ranges::for_each(InOut, [gains](const FloatBufferSpan inout) -> void { const auto buffer = assume_aligned_span<16>(std::span{inout}); - std::ranges::transform(gains, buffer, buffer.begin(), std::multiplies{}); + std::ranges::transform(gains | std::views::transform(&f32::c_val), buffer, buffer.begin(), + std::multiplies{}); }); std::ranges::copy(mSideChain | std::views::drop(SamplesToDo) | std::views::take(mLookAhead), diff --git a/3rdparty/openal/core/mastering.h b/3rdparty/openal/core/mastering.h index 1b2bab8d7722..e670c34f03dd 100644 --- a/3rdparty/openal/core/mastering.h +++ b/3rdparty/openal/core/mastering.h @@ -2,12 +2,11 @@ #define CORE_MASTERING_H #include -#include #include #include -#include "alnumeric.h" #include "altypes.hpp" +#include "bitset.hpp" #include "bufferline.h" #include "vector.h" @@ -36,40 +35,41 @@ class Compressor { unsigned mLookAhead{0}; - float mPreGain{0.0f}; - float mPostGain{0.0f}; + f32 mPreGain{0.0f}; + f32 mPostGain{0.0f}; - float mThreshold{0.0f}; - float mSlope{0.0f}; - float mKnee{0.0f}; + f32 mThreshold{0.0f}; + f32 mSlope{0.0f}; + f32 mKnee{0.0f}; - float mAttack{0.0f}; - float mRelease{0.0f}; + f32 mAttack{0.0f}; + f32 mRelease{0.0f}; - alignas(16) std::array mSideChain{}; - alignas(16) std::array mCrestFactor{}; + alignas(16) std::array mSideChain{}; + alignas(16) std::array mCrestFactor{}; std::unique_ptr mHold; - al::vector mDelay; + al::vector mDelay; - float mCrestCoeff{0.0f}; - float mGainEstimate{0.0f}; - float mAdaptCoeff{0.0f}; + f32 mCrestCoeff{0.0f}; + f32 mGainEstimate{0.0f}; + f32 mAdaptCoeff{0.0f}; - float mLastPeakSq{0.0f}; - float mLastRmsSq{0.0f}; - float mLastRelease{0.0f}; - float mLastAttack{0.0f}; - float mLastGainDev{0.0f}; + f32 mLastPeakSq{0.0f}; + f32 mLastRmsSq{0.0f}; + f32 mLastRelease{0.0f}; + f32 mLastAttack{0.0f}; + f32 mLastGainDev{0.0f}; void gainCompressor(unsigned SamplesToDo); struct PrivateToken { }; public: - enum { - AutoKnee, AutoAttack, AutoRelease, AutoPostGain, AutoDeclip, FlagsCount + enum class Flags { + AutoKnee, AutoAttack, AutoRelease, AutoPostGain, AutoDeclip, + MaxValue = AutoDeclip }; - using FlagBits = std::bitset; + using FlagBits = al::bitset; Compressor() = delete; explicit Compressor(PrivateToken); @@ -81,37 +81,38 @@ class Compressor { void process(unsigned SamplesToDo, std::span InOut); [[nodiscard]] auto getLookAhead() const noexcept -> unsigned { return mLookAhead; } - /** - * The compressor is initialized with the following settings: - * - * \param NumChans Number of channels to process. - * \param SampleRate Sample rate to process. - * \param AutoFlags Flags to automate specific parameters: - * AutoKnee - automate the knee width parameter - * AutoAttack - automate the attack time parameter - * AutoRelease - automate the release time parameter - * AutoPostGain - automate the make-up (post) gain - * parameter - * AutoDeclip - automate clipping reduction. Ignored - * when not automating make-up gain - * \param LookAheadTime Look-ahead time (in seconds). - * \param HoldTime Peak hold-time (in seconds). - * \param PreGainDb Gain applied before detection (in dB). - * \param PostGainDb Make-up gain applied after compression (in dB). - * \param ThresholdDb Triggering threshold (in dB). - * \param Ratio Compression ratio (x:1). Set to INFINIFTY for true - * limiting. Ignored when automating knee width. - * \param KneeDb Knee width (in dB). Ignored when automating knee - * width. - * \param AttackTime Attack time (in seconds). Acts as a maximum when - * automating attack time. - * \param ReleaseTime Release time (in seconds). Acts as a maximum when - * automating release time. - */ - static auto Create(const size_t NumChans, const float SampleRate, const FlagBits AutoFlags, - const float LookAheadTime, const float HoldTime, const float PreGainDb, - const float PostGainDb, const float ThresholdDb, const float Ratio, const float KneeDb, - const float AttackTime, const float ReleaseTime) -> std::unique_ptr; + /** Parameters for initializing the compressor. */ + struct Params { + u32 NumChans; /**< Number of channels to process. */ + f32 SampleRate; /**< Sample rate to process. */ + FlagBits AutoFlags; /**< Flags to automate specific parameters: + * AutoKnee - automate the knee width parameter + * AutoAttack - automate the attack time parameter + * AutoRelease - automate the release time parameter + * AutoPostGain - automate the make-up (post) gain parameter + * AutoDeclip - automate clipping reduction. Ignored when not + * automating make-up gain + */ + f32 LookAheadTime; /**< Look-ahead time (in seconds). */ + f32 HoldTime; /**< Peak hold-time (in seconds). */ + f32 PreGainDb; /**< Gain applied before detection (in dB). */ + f32 PostGainDb; /**< Make-up gain applied after compression (in dB). */ + f32 ThresholdDb; /**< Triggering threshold (in dB). */ + f32 Ratio; /**< Compression ratio (x:1). Set to INFINITY for true + * limiting. Ignored when automating knee width. + */ + f32 KneeDb; /**< Knee width (in dB). Ignored when automating knee + * width. + */ + f32 AttackTime; /**< Attack time (in seconds). Acts as a maximum when + * automating attack time. + */ + f32 ReleaseTime; /**< Release time (in seconds). Acts as a maximum when + * automating release time. + */ + }; + + static auto Create(Params params) -> std::unique_ptr; }; using CompressorPtr = std::unique_ptr; diff --git a/3rdparty/openal/core/mixer.cpp b/3rdparty/openal/core/mixer.cpp index a3866328f6d7..04d9f98a1fa9 100644 --- a/3rdparty/openal/core/mixer.cpp +++ b/3rdparty/openal/core/mixer.cpp @@ -13,8 +13,8 @@ #include "mixer/defs.h" -auto CalcAmbiCoeffs(const float y, const float z, const float x, const float spread) - -> std::array +auto CalcAmbiCoeffs(const float y, const float z, const float x, const float spread) noexcept + NONBLOCKING -> std::array { auto coeffs = CalcAmbiCoeffs(y, z, x); @@ -91,7 +91,7 @@ auto CalcAmbiCoeffs(const float y, const float z, const float x, const float spr } void ComputePanGains(const MixParams *mix, const std::span coeffs, - const float ingain, const std::span gains) + const float ingain, const std::span gains) noexcept NONBLOCKING { auto ambimap = std::span{std::as_const(mix->AmbiMap)}.first(mix->Buffer.size()); diff --git a/3rdparty/openal/core/mixer.h b/3rdparty/openal/core/mixer.h index 5a9d5f45601d..977eaed0baee 100644 --- a/3rdparty/openal/core/mixer.h +++ b/3rdparty/openal/core/mixer.h @@ -3,9 +3,9 @@ #include #include +#include #include -#include "alnumeric.h" #include "ambidefs.h" #include "bufferline.h" #include "opthelpers.h" @@ -13,29 +13,31 @@ struct MixParams; void Mix_C(std::span InSamples, std::span OutBuffer, - std::span CurrentGains, std::span TargetGains, usize Counter, - usize OutPos); + std::span CurrentGains, std::span TargetGains, std::size_t Counter, + std::size_t OutPos) noexcept NONBLOCKING; void Mix_C(std::span InSamples, std::span OutBuffer, float &CurrentGain, - float TargetGain, usize Counter); + float TargetGain, std::size_t Counter) noexcept NONBLOCKING; /* Mixer functions that handle one input and multiple output channels. */ using MixerOutFunc = void(*)(std::span InSamples, std::span OutBuffer, std::span CurrentGains, - std::span TargetGains, usize Counter, usize OutPos); + std::span TargetGains, std::size_t Counter, std::size_t OutPos) noexcept + NONBLOCKING; inline constinit auto MixSamplesOut = MixerOutFunc{Mix_C}; inline void MixSamples(std::span const InSamples, std::span const OutBuffer, std::span const CurrentGains, - std::span const TargetGains, usize const Counter, usize const OutPos) + std::span const TargetGains, std::size_t const Counter, std::size_t const OutPos) + noexcept NONBLOCKING { MixSamplesOut(InSamples, OutBuffer, CurrentGains, TargetGains, Counter, OutPos); } /* Mixer functions that handle one input and one output channel. */ using MixerOneFunc = void(*)(std::span InSamples, std::span OutBuffer, - float &CurrentGain, float TargetGain, usize Counter); + float &CurrentGain, float TargetGain, std::size_t Counter) noexcept NONBLOCKING; inline constinit auto MixSamplesOne = MixerOneFunc{Mix_C}; inline void MixSamples(std::span const InSamples, std::span const OutBuffer, - float &CurrentGain, float const TargetGain, usize const Counter) + float &CurrentGain, float const TargetGain, std::size_t const Counter) noexcept NONBLOCKING { MixSamplesOne(InSamples, OutBuffer, CurrentGain, TargetGain, Counter); } @@ -53,7 +55,8 @@ inline void MixSamples(std::span const InSamples, std::span * The components are ordered such that OpenAL's X, Y, and Z are the first, * second, and third parameters respectively -- simply negate X and Z. */ -std::array CalcAmbiCoeffs(float y, float z, float x, float spread); +std::array CalcAmbiCoeffs(float y, float z, float x, float spread) noexcept + NONBLOCKING; /** * CalcDirectionCoeffs @@ -62,8 +65,8 @@ std::array CalcAmbiCoeffs(float y, float z, float x, floa * vector must be normalized (unit length), and the spread is the angular width * of the sound (0...tau). */ -inline auto CalcDirectionCoeffs(const std::span dir, const float spread) - -> std::array +inline auto CalcDirectionCoeffs(const std::span dir, const float spread) noexcept + NONBLOCKING -> std::array { /* Convert from OpenAL coords to Ambisonics. */ return CalcAmbiCoeffs(-dir[0], dir[1], -dir[2], spread); @@ -75,7 +78,7 @@ inline auto CalcDirectionCoeffs(const std::span dir, const float * Calculates ambisonic coefficients based on an OpenAL direction vector. The * vector must be normalized (unit length). */ -constexpr auto CalcDirectionCoeffs(const std::span dir) +constexpr auto CalcDirectionCoeffs(const std::span dir) noexcept NONBLOCKING -> std::array { /* Convert from OpenAL coords to Ambisonics. */ @@ -90,7 +93,7 @@ constexpr auto CalcDirectionCoeffs(const std::span dir) * respectively. */ inline auto CalcAngleCoeffs(const float azimuth, const float elevation, const float spread) - -> std::array + noexcept NONBLOCKING -> std::array { const float x{-std::sin(azimuth) * std::cos(elevation)}; const float y{ std::sin(elevation)}; @@ -108,7 +111,7 @@ inline auto CalcAngleCoeffs(const float azimuth, const float elevation, const fl * coeffs are a 'slice' of a transform matrix for the input channel, used to * scale and orient the sound samples. */ -void ComputePanGains(const MixParams *mix, const std::span coeffs, - const float ingain, const std::span gains); +void ComputePanGains(const MixParams *mix, std::span coeffs, + float ingain, std::span gains) noexcept NONBLOCKING; #endif /* CORE_MIXER_H */ diff --git a/3rdparty/openal/core/mixer/defs.h b/3rdparty/openal/core/mixer/defs.h index b28ea69ae423..90ad2b35b47b 100644 --- a/3rdparty/openal/core/mixer/defs.h +++ b/3rdparty/openal/core/mixer/defs.h @@ -1,12 +1,15 @@ #ifndef CORE_MIXER_DEFS_H #define CORE_MIXER_DEFS_H +#include "config_simd.h" + #include +#include #include #include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "core/bufferline.h" #include "core/cubic_defs.h" @@ -66,35 +69,40 @@ struct CubicState { using InterpState = std::variant; using ResamplerFunc = void(*)(InterpState const *state, std::span src, unsigned frac, - unsigned increment, std::span dst); + unsigned increment, std::span dst) noexcept NONBLOCKING; [[nodiscard]] -auto PrepareResampler(Resampler resampler, unsigned increment, InterpState *state) - -> ResamplerFunc; +auto PrepareResampler(Resampler resampler, unsigned increment, InterpState *state) noexcept + NONBLOCKING -> ResamplerFunc; #define DECL_RESAMPLER(T, I) \ void Resample_##T##_##I(InterpState const *state, std::span src, \ - unsigned frac, unsigned increment, std::span dst); + unsigned frac, unsigned increment, std::span dst) noexcept \ + NONBLOCKING; #define DECL_MIXER(I) \ void Mix_##I(std::span InSamples, \ std::span OutBuffer, std::span CurrentGains, \ - std::span TargetGains, usize Counter, usize OutPos); \ + std::span TargetGains, std::size_t Counter, \ + std::size_t OutPos) noexcept NONBLOCKING; \ void Mix_##I(std::span InSamples, std::span OutBuffer, \ - float &CurrentGain, float TargetGain, usize Counter); + float &CurrentGain, float TargetGain, std::size_t Counter) noexcept \ + NONBLOCKING; #define DECL_HRTF_MIXER(I) \ void MixHrtf_##I(std::span InSamples, \ std::span AccumSamples, unsigned IrSize, \ - MixHrtfFilter const *hrtfparams, usize SamplesToDo); \ + MixHrtfFilter const *hrtfparams, std::size_t SamplesToDo) noexcept \ + NONBLOCKING; \ void MixHrtfBlend_##I(std::span InSamples, \ std::span AccumSamples, unsigned IrSize, \ HrtfFilter const *oldparams, MixHrtfFilter const *newparams, \ - usize SamplesToDo); \ + std::size_t SamplesToDo) noexcept NONBLOCKING; \ void MixDirectHrtf_##I(FloatBufferSpan LeftOut, FloatBufferSpan RightOut, \ std::span InSamples, std::span AccumSamples,\ std::span TempBuf, \ - std::span ChanState, usize IrSize, usize SamplesToDo); + std::span ChanState, std::size_t IrSize, \ + std::size_t SamplesToDo) noexcept NONBLOCKING; DECL_RESAMPLER(Point, C) @@ -106,6 +114,15 @@ DECL_RESAMPLER(BSinc, C) DECL_MIXER(C) DECL_HRTF_MIXER(C) +#if HAVE_NEON +DECL_RESAMPLER(Linear, NEON) +DECL_RESAMPLER(Cubic, NEON) +DECL_RESAMPLER(FastBSinc, NEON) +DECL_RESAMPLER(BSinc, NEON) + +DECL_MIXER(NEON) +DECL_HRTF_MIXER(NEON) +#endif #if HAVE_SSE DECL_RESAMPLER(Cubic, SSE) DECL_RESAMPLER(FastBSinc, SSE) @@ -122,24 +139,16 @@ DECL_RESAMPLER(Cubic, SSE2) DECL_RESAMPLER(Linear, SSE4) DECL_RESAMPLER(Cubic, SSE4) #endif -#if HAVE_NEON -DECL_RESAMPLER(Linear, NEON) -DECL_RESAMPLER(Cubic, NEON) -DECL_RESAMPLER(FastBSinc, NEON) -DECL_RESAMPLER(BSinc, NEON) - -DECL_MIXER(NEON) -DECL_HRTF_MIXER(NEON) -#endif #undef DECL_HRTF_MIXER #undef DECL_MIXER #undef DECL_RESAMPLER /* Vectorized resampler helpers */ -template -constexpr void InitPosArrays(unsigned const pos, unsigned const frac, unsigned const increment, - std::span const frac_arr, std::span const pos_arr) +template constexpr +void InitPosArrays(unsigned const pos, unsigned const frac, unsigned const increment, + std::span const frac_arr, std::span const pos_arr) noexcept + NONBLOCKING { static_assert(pos_arr.size() == frac_arr.size()); pos_arr[0] = pos; diff --git a/3rdparty/openal/core/mixer/hrtfbase.h b/3rdparty/openal/core/mixer/hrtfbase.h index 141228edd6ea..cc2e5e1028f3 100644 --- a/3rdparty/openal/core/mixer/hrtfbase.h +++ b/3rdparty/openal/core/mixer/hrtfbase.h @@ -2,22 +2,22 @@ #define CORE_MIXER_HRTFBASE_H #include -#include +#include #include -#include "alnumeric.h" #include "defs.h" #include "gsl/gsl" #include "hrtfdefs.h" #include "opthelpers.h" -using ApplyCoeffsT = void(*)(std::span Values, usize irSize, ConstHrirSpan Coeffs, - float left, float right); +using ApplyCoeffsT = void(*)(std::span Values, std::size_t irSize, ConstHrirSpan Coeffs, + float left, float right) noexcept NONBLOCKING; template void MixHrtfBase(std::span const InSamples, std::span const AccumSamples, - usize const IrSize, MixHrtfFilter const *const hrtfparams, usize const SamplesToDo) + std::size_t const IrSize, MixHrtfFilter const *const hrtfparams, std::size_t const SamplesToDo) + noexcept NONBLOCKING { ASSUME(SamplesToDo > 0); ASSUME(SamplesToDo <= BufferLineSize); @@ -27,8 +27,8 @@ void MixHrtfBase(std::span const InSamples, std::span const auto const gainstep = hrtfparams->GainStep; auto const gain = hrtfparams->Gain; - auto ldelay = usize{HrtfHistoryLength} - hrtfparams->Delay[0]; - auto rdelay = usize{HrtfHistoryLength} - hrtfparams->Delay[1]; + auto ldelay = std::size_t{HrtfHistoryLength} - hrtfparams->Delay[0]; + auto rdelay = std::size_t{HrtfHistoryLength} - hrtfparams->Delay[1]; auto stepcount = 0.0f; for(auto i = 0_uz;i < SamplesToDo;++i) { @@ -43,8 +43,8 @@ void MixHrtfBase(std::span const InSamples, std::span const template void MixHrtfBlendBase(std::span const InSamples, std::span const AccumSamples, - usize const IrSize, HrtfFilter const *const oldparams, MixHrtfFilter const *const newparams, - usize const SamplesToDo) + std::size_t const IrSize, HrtfFilter const *const oldparams, + MixHrtfFilter const *const newparams, std::size_t const SamplesToDo) noexcept NONBLOCKING { ASSUME(SamplesToDo > 0); ASSUME(SamplesToDo <= BufferLineSize); @@ -57,8 +57,8 @@ void MixHrtfBlendBase(std::span const InSamples, std::span c if(oldparams->Gain > GainSilenceThreshold) [[likely]] { - auto ldelay = usize{HrtfHistoryLength} - oldparams->Delay[0]; - auto rdelay = usize{HrtfHistoryLength} - oldparams->Delay[1]; + auto ldelay = std::size_t{HrtfHistoryLength} - oldparams->Delay[0]; + auto rdelay = std::size_t{HrtfHistoryLength} - oldparams->Delay[1]; auto stepcount = gsl::narrow_cast(SamplesToDo); for(auto i = 0_uz;i < SamplesToDo;++i) { @@ -73,8 +73,8 @@ void MixHrtfBlendBase(std::span const InSamples, std::span c if(newGainStep*gsl::narrow_cast(SamplesToDo) > GainSilenceThreshold) [[likely]] { - auto ldelay = usize{HrtfHistoryLength+1} - newparams->Delay[0]; - auto rdelay = usize{HrtfHistoryLength+1} - newparams->Delay[1]; + auto ldelay = std::size_t{HrtfHistoryLength+1} - newparams->Delay[0]; + auto rdelay = std::size_t{HrtfHistoryLength+1} - newparams->Delay[1]; auto stepcount = 1.0f; for(auto i = 1_uz;i < SamplesToDo;++i) { @@ -92,7 +92,7 @@ template void MixDirectHrtfBase(FloatBufferSpan const LeftOut, FloatBufferSpan const RightOut, std::span const InSamples, std::span const AccumSamples, std::span const TempBuf, std::span const ChannelState, - usize const IrSize, usize const SamplesToDo) + std::size_t const IrSize, std::size_t const SamplesToDo) noexcept NONBLOCKING { ASSUME(SamplesToDo > 0); ASSUME(SamplesToDo <= BufferLineSize); diff --git a/3rdparty/openal/core/mixer/hrtfdefs.h b/3rdparty/openal/core/mixer/hrtfdefs.h index 491eac0c5f43..cfbb61006e97 100644 --- a/3rdparty/openal/core/mixer/hrtfdefs.h +++ b/3rdparty/openal/core/mixer/hrtfdefs.h @@ -4,7 +4,7 @@ #include #include -#include "alnumeric.h" +#include "altypes.hpp" #include "core/filters/splitter.h" diff --git a/3rdparty/openal/core/mixer/mixer_c.cpp b/3rdparty/openal/core/mixer/mixer_c.cpp index ebddae5c1193..4e2c3839b929 100644 --- a/3rdparty/openal/core/mixer/mixer_c.cpp +++ b/3rdparty/openal/core/mixer/mixer_c.cpp @@ -1,6 +1,7 @@ #include "config.h" #include +#include #include #include #include @@ -28,22 +29,24 @@ constexpr auto CubicPhaseDiffBits = unsigned{MixerFracBits - CubicPhaseBits}; constexpr auto CubicPhaseDiffOne = 1u << CubicPhaseDiffBits; constexpr auto CubicPhaseDiffMask = CubicPhaseDiffOne - 1u; -using SamplerNST = auto(std::span vals, usize pos, unsigned frac) noexcept -> float; +using SamplerNST = auto(std::span vals, std::size_t pos, unsigned frac) noexcept + NONBLOCKING -> float; template -using SamplerT = auto(T const &istate, std::span vals, usize pos, unsigned frac) - noexcept -> float; +using SamplerT = auto(T const &istate, std::span vals, std::size_t pos, unsigned frac) + noexcept NONBLOCKING -> float; [[nodiscard]] constexpr -auto do_point(std::span const vals, usize const pos, unsigned) noexcept -> float +auto do_point(std::span const vals, std::size_t const pos, unsigned) noexcept + NONBLOCKING -> float { return vals[pos]; } [[nodiscard]] constexpr -auto do_lerp(std::span const vals, usize const pos, unsigned const frac) noexcept - -> float +auto do_lerp(std::span const vals, std::size_t const pos, unsigned const frac) + noexcept NONBLOCKING -> float { return lerpf(vals[pos+0], vals[pos+1], gsl::narrow_cast(frac)*(1.0f/MixerFracOne)); } [[nodiscard]] constexpr -auto do_cubic(CubicState const &istate, std::span const vals, usize const pos, - unsigned const frac) noexcept -> float +auto do_cubic(CubicState const &istate, std::span const vals, std::size_t const pos, + unsigned const frac) noexcept NONBLOCKING -> float { /* Calculate the phase index and factor. */ auto const pi = unsigned{frac>>CubicPhaseDiffBits}; ASSUME(pi < CubicPhaseCount); @@ -57,10 +60,10 @@ auto do_cubic(CubicState const &istate, std::span const vals, usize + (fil[2] + pf*phd[2])*vals[pos+2] + (fil[3] + pf*phd[3])*vals[pos+3]; } [[nodiscard]] constexpr -auto do_fastbsinc(BsincState const &bsinc, std::span const vals, usize const pos, - unsigned const frac) noexcept -> float +auto do_fastbsinc(BsincState const &bsinc, std::span const vals, + std::size_t const pos, unsigned const frac) noexcept NONBLOCKING -> float { - auto const m = usize{bsinc.m.c_val}; + auto const m = std::size_t{bsinc.m.c_val}; ASSUME(m > 0); ASSUME(m <= MaxResamplerPadding); @@ -78,10 +81,10 @@ auto do_fastbsinc(BsincState const &bsinc, std::span const vals, us return r; } [[nodiscard]] constexpr -auto do_bsinc(BsincState const &bsinc, std::span const vals, usize const pos, - unsigned const frac) noexcept -> float +auto do_bsinc(BsincState const &bsinc, std::span const vals, std::size_t const pos, + unsigned const frac) noexcept NONBLOCKING -> float { - auto const m = usize{bsinc.m.c_val}; + auto const m = std::size_t{bsinc.m.c_val}; ASSUME(m > 0); ASSUME(m <= MaxResamplerPadding); @@ -103,7 +106,7 @@ auto do_bsinc(BsincState const &bsinc, std::span const vals, usize template void DoResample(std::span const src, unsigned frac, unsigned const increment, - std::span const dst) + std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); auto pos = 0_uz; @@ -119,7 +122,7 @@ void DoResample(std::span const src, unsigned frac, unsigned const template Sampler> void DoResample(U const istate, std::span const src, unsigned frac, - unsigned const increment, std::span const dst) + unsigned const increment, std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); auto pos = 0_uz; @@ -133,8 +136,8 @@ void DoResample(U const istate, std::span const src, unsigned frac, }); } -void ApplyCoeffs(std::span const Values, usize const IrSize, ConstHrirSpan const Coeffs, - float const left, float const right) noexcept +void ApplyCoeffs(std::span const Values, std::size_t const IrSize, + ConstHrirSpan const Coeffs, float const left, float const right) noexcept NONBLOCKING { ASSUME(IrSize >= MinIrLength); ASSUME(IrSize <= HrirLength); @@ -145,8 +148,8 @@ void ApplyCoeffs(std::span const Values, usize const IrSize, ConstHrirSpa } force_inline void MixLine(std::span InSamples, std::span const dst, - float &CurrentGain, float const TargetGain, float const delta, usize const fade_len, - usize Counter) + float &CurrentGain, float const TargetGain, float const delta, std::size_t const fade_len, + std::size_t Counter) noexcept NONBLOCKING { auto const step = (TargetGain-CurrentGain) * delta; @@ -185,33 +188,33 @@ force_inline void MixLine(std::span InSamples, std::span con } // namespace void Resample_Point_C(InterpState const*, std::span const src, unsigned const frac, - unsigned const increment, std::span const dst) + unsigned const increment, std::span const dst) noexcept NONBLOCKING { DoResample(src.subspan(MaxResamplerEdge), frac, increment, dst); } void Resample_Linear_C(InterpState const*, std::span const src, unsigned const frac, - unsigned const increment, std::span const dst) + unsigned const increment, std::span const dst) noexcept NONBLOCKING { DoResample(src.subspan(MaxResamplerEdge), frac, increment, dst); } void Resample_Cubic_C(InterpState const *const state, std::span const src, - unsigned const frac, unsigned const increment, std::span const dst) + unsigned const frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { - DoResample(std::get(*state), src.subspan(MaxResamplerEdge-1), - frac, increment, dst); + DoResample(*gsl::not_null{std::get_if(state)}, + src.subspan(MaxResamplerEdge-1), frac, increment, dst); } void Resample_FastBSinc_C(InterpState const *const state, std::span const src, - unsigned const frac, unsigned const increment, std::span const dst) + unsigned const frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { - auto const istate = std::get(*state); + auto const istate = *gsl::not_null{std::get_if(state)}; ASSUME(istate.l.c_val <= MaxResamplerEdge); DoResample(istate, src.subspan(MaxResamplerEdge-istate.l.c_val), frac, increment, dst); } void Resample_BSinc_C(InterpState const *const state, std::span const src, - unsigned const frac, unsigned const increment, std::span const dst) + unsigned const frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { - auto const istate = std::get(*state); + auto const istate = *gsl::not_null{std::get_if(state)}; ASSUME(istate.l.c_val <= MaxResamplerEdge); DoResample(istate, src.subspan(MaxResamplerEdge-istate.l.c_val), frac, increment, dst); @@ -219,12 +222,13 @@ void Resample_BSinc_C(InterpState const *const state, std::span con void MixHrtf_C(std::span const InSamples, std::span const AccumSamples, - unsigned const IrSize, MixHrtfFilter const *const hrtfparams, usize const SamplesToDo) + unsigned const IrSize, MixHrtfFilter const *const hrtfparams, std::size_t const SamplesToDo) + noexcept NONBLOCKING { MixHrtfBase(InSamples, AccumSamples, IrSize, hrtfparams, SamplesToDo); } void MixHrtfBlend_C(std::span const InSamples, std::span const AccumSamples, unsigned const IrSize, HrtfFilter const *const oldparams, MixHrtfFilter const *const newparams, - usize const SamplesToDo) + std::size_t const SamplesToDo) noexcept NONBLOCKING { MixHrtfBlendBase(InSamples, AccumSamples, IrSize, oldparams, newparams, SamplesToDo); @@ -233,7 +237,7 @@ void MixHrtfBlend_C(std::span const InSamples, std::span con void MixDirectHrtf_C(FloatBufferSpan const LeftOut, FloatBufferSpan const RightOut, std::span const InSamples, std::span const AccumSamples, std::span const TempBuf, std::span const ChanState, - usize const IrSize, usize const SamplesToDo) + std::size_t const IrSize, std::size_t const SamplesToDo) noexcept NONBLOCKING { MixDirectHrtfBase(LeftOut, RightOut, InSamples, AccumSamples, TempBuf, ChanState, IrSize, SamplesToDo); @@ -242,7 +246,7 @@ void MixDirectHrtf_C(FloatBufferSpan const LeftOut, FloatBufferSpan const RightO void Mix_C(std::span const InSamples, std::span const OutBuffer, std::span const CurrentGains, std::span const TargetGains, - usize const Counter, usize const OutPos) + std::size_t const Counter, std::size_t const OutPos) noexcept NONBLOCKING { auto const delta = (Counter > 0) ? 1.0f / gsl::narrow_cast(Counter) : 0.0f; auto const fade_len = std::min(Counter, InSamples.size()); @@ -255,7 +259,7 @@ void Mix_C(std::span const InSamples, std::span co } void Mix_C(std::span const InSamples, std::span const OutBuffer, - float &CurrentGain, float const TargetGain, usize const Counter) + float &CurrentGain, float const TargetGain, std::size_t const Counter) noexcept NONBLOCKING { auto const delta = (Counter > 0) ? 1.0f / gsl::narrow_cast(Counter) : 0.0f; auto const fade_len = std::min(Counter, InSamples.size()); diff --git a/3rdparty/openal/core/mixer/mixer_neon.cpp b/3rdparty/openal/core/mixer/mixer_neon.cpp index f9884ff46e77..6e60f5af1c1a 100644 --- a/3rdparty/openal/core/mixer/mixer_neon.cpp +++ b/3rdparty/openal/core/mixer/mixer_neon.cpp @@ -47,7 +47,8 @@ void vtranspose4(float32x4_t &x0, float32x4_t &x1, float32x4_t &x2, float32x4_t x3 = u1_.val[1]; } -inline auto set_f4(float const l0, float const l1, float const l2, float const l3) -> float32x4_t +inline +auto set_f4(float const l0, float const l1, float const l2, float const l3) noexcept -> float32x4_t { auto ret = vmovq_n_f32(l0); ret = vsetq_lane_f32(l1, ret, 1); @@ -56,8 +57,8 @@ inline auto set_f4(float const l0, float const l1, float const l2, float const l return ret; } -inline void ApplyCoeffs(std::span const Values, usize const IrSize, - ConstHrirSpan const Coeffs, float const left, float const right) +inline void ApplyCoeffs(std::span const Values, std::size_t const IrSize, + ConstHrirSpan const Coeffs, float const left, float const right) noexcept NONBLOCKING { ASSUME(IrSize >= MinIrLength); ASSUME(IrSize <= HrirLength); @@ -77,8 +78,8 @@ inline void ApplyCoeffs(std::span const Values, usize const IrSize, } force_inline void MixLine(std::span const InSamples, std::span const dst, - float &CurrentGain, float const TargetGain, float const delta, usize const fade_len, - usize const realign_len, usize Counter) + float &CurrentGain, float const TargetGain, float const delta, std::size_t const fade_len, + std::size_t const realign_len, std::size_t Counter) noexcept NONBLOCKING { auto const step = float{(TargetGain-CurrentGain) * delta}; @@ -183,7 +184,7 @@ force_inline void MixLine(std::span const InSamples, std::span const src, unsigned frac, - unsigned const increment, std::span const dst) + unsigned const increment, std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); @@ -222,7 +223,7 @@ void Resample_Linear_NEON(InterpState const*, std::span const src, if(auto const todo = dst.size()&3) { - auto pos = usize{vgetq_lane_u32(pos4, 0)}; + auto pos = std::size_t{vgetq_lane_u32(pos4, 0)}; frac = vgetq_lane_u32(frac4, 0); std::ranges::generate(dst.last(todo), [&pos,&frac,src,increment] @@ -239,11 +240,11 @@ void Resample_Linear_NEON(InterpState const*, std::span const src, } void Resample_Cubic_NEON(InterpState const *const state, std::span const src, - unsigned frac, unsigned const increment, std::span const dst) + unsigned frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); - auto const filter = std::get(*state).filter; + auto const filter = gsl::not_null{std::get_if(state)}->filter; auto const increment4 = vdupq_n_u32(increment*4u); auto const fracMask4 = vdupq_n_u32(MixerFracMask); @@ -303,7 +304,7 @@ void Resample_Cubic_NEON(InterpState const *const state, std::span if(auto const todo = dst.size()&3) { - auto pos = usize{vgetq_lane_u32(pos4, 0)}; + auto pos = std::size_t{vgetq_lane_u32(pos4, 0)}; frac = vgetq_lane_u32(frac4, 0); std::ranges::generate(dst.last(todo), [&pos,&frac,src,increment,filter] @@ -329,10 +330,10 @@ void Resample_Cubic_NEON(InterpState const *const state, std::span } void Resample_FastBSinc_NEON(InterpState const *const state, std::span const src, - unsigned frac, unsigned const increment, std::span const dst) + unsigned frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { - auto const &bsinc = std::get(*state); - auto const m = usize{bsinc.m.c_val}; + auto const &bsinc = *gsl::not_null{std::get_if(state)}; + auto const m = std::size_t{bsinc.m.c_val}; ASSUME(m > 0); ASSUME(m <= MaxResamplerPadding); ASSUME(frac < MixerFracOne); @@ -340,7 +341,7 @@ void Resample_FastBSinc_NEON(InterpState const *const state, std::span float { // Calculate the phase index and factor. @@ -375,11 +376,11 @@ void Resample_FastBSinc_NEON(InterpState const *const state, std::span const src, - unsigned frac, unsigned const increment, std::span const dst) + unsigned frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { - auto const &bsinc = std::get(*state); + auto const &bsinc = *gsl::not_null{std::get_if(state)}; auto const sf4 = vdupq_n_f32(bsinc.sf); - auto const m = usize{bsinc.m.c_val}; + auto const m = std::size_t{bsinc.m.c_val}; ASSUME(m > 0); ASSUME(m <= MaxResamplerPadding); ASSUME(frac < MixerFracOne); @@ -387,7 +388,7 @@ void Resample_BSinc_NEON(InterpState const *const state, std::span auto const filter = bsinc.filter.first(4_uz*BSincPhaseCount*m); ASSUME(bsinc.l.c_val <= MaxResamplerEdge); - auto pos = usize{MaxResamplerEdge-bsinc.l.c_val}; + auto pos = std::size_t{MaxResamplerEdge-bsinc.l.c_val}; std::ranges::generate(dst, [&pos,&frac,src,increment,sf4,m,filter]() -> float { // Calculate the phase index and factor. @@ -427,12 +428,13 @@ void Resample_BSinc_NEON(InterpState const *const state, std::span void MixHrtf_NEON(std::span const InSamples, std::span const AccumSamples, - unsigned const IrSize, MixHrtfFilter const *const hrtfparams, usize const SamplesToDo) + unsigned const IrSize, MixHrtfFilter const *const hrtfparams, std::size_t const SamplesToDo) + noexcept NONBLOCKING { MixHrtfBase(InSamples, AccumSamples, IrSize, hrtfparams, SamplesToDo); } void MixHrtfBlend_NEON(std::span const InSamples, std::span const AccumSamples, unsigned const IrSize, HrtfFilter const *const oldparams, MixHrtfFilter const *const newparams, - usize const SamplesToDo) + std::size_t const SamplesToDo) noexcept NONBLOCKING { MixHrtfBlendBase(InSamples, AccumSamples, IrSize, oldparams, newparams, SamplesToDo); @@ -441,7 +443,7 @@ void MixHrtfBlend_NEON(std::span const InSamples, std::span void MixDirectHrtf_NEON(FloatBufferSpan const LeftOut, FloatBufferSpan const RightOut, std::span const InSamples, std::span const AccumSamples, std::span const TempBuf, std::span const ChanState, - usize const IrSize, usize const SamplesToDo) + std::size_t const IrSize, std::size_t const SamplesToDo) noexcept NONBLOCKING { MixDirectHrtfBase(LeftOut, RightOut, InSamples, AccumSamples, TempBuf, ChanState, IrSize, SamplesToDo); @@ -450,7 +452,7 @@ void MixDirectHrtf_NEON(FloatBufferSpan const LeftOut, FloatBufferSpan const Rig void Mix_NEON(std::span const InSamples, std::span const OutBuffer, std::span const CurrentGains, std::span const TargetGains, - usize const Counter, usize const OutPos) + std::size_t const Counter, std::size_t const OutPos) noexcept NONBLOCKING { if((OutPos&3) != 0) [[unlikely]] return Mix_C(InSamples, OutBuffer, CurrentGains, TargetGains, Counter, OutPos); @@ -467,7 +469,7 @@ void Mix_NEON(std::span const InSamples, std::span } void Mix_NEON(std::span const InSamples, std::span const OutBuffer, - float &CurrentGain, float const TargetGain, usize const Counter) + float &CurrentGain, float const TargetGain, std::size_t const Counter) noexcept NONBLOCKING { /* NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) */ if((reinterpret_cast(OutBuffer.data())&15) != 0) [[unlikely]] diff --git a/3rdparty/openal/core/mixer/mixer_sse.cpp b/3rdparty/openal/core/mixer/mixer_sse.cpp index f89c5f061aa0..3b8c70d63032 100644 --- a/3rdparty/openal/core/mixer/mixer_sse.cpp +++ b/3rdparty/openal/core/mixer/mixer_sse.cpp @@ -9,7 +9,6 @@ #include #include -#include "alnumeric.h" #include "core/bsinc_defs.h" #include "core/bufferline.h" #include "core/cubic_defs.h" @@ -21,7 +20,7 @@ #include "opthelpers.h" -#if defined(__GNUC__) && !defined(__clang__) && !defined(__SSE__) +#if defined(__GNUC__) && !defined(__clang__) && !defined(__SSE__) && !defined(__powerpc64__) #pragma GCC target("sse") #endif @@ -38,8 +37,8 @@ constexpr auto CubicPhaseDiffMask = CubicPhaseDiffOne - 1u; force_inline auto vmadd(__m128 const x, __m128 const y, __m128 const z) noexcept -> __m128 { return _mm_add_ps(x, _mm_mul_ps(y, z)); } -void ApplyCoeffs(std::span const Values, usize const IrSize, ConstHrirSpan const Coeffs, - float const left, float const right) +void ApplyCoeffs(std::span const Values, std::size_t const IrSize, + ConstHrirSpan const Coeffs, float const left, float const right) noexcept NONBLOCKING { ASSUME(IrSize >= MinIrLength); ASSUME(IrSize <= HrirLength); @@ -49,7 +48,7 @@ void ApplyCoeffs(std::span const Values, usize const IrSize, ConstHrirSpa * underlying HRIR is a fixed-size multiple of 2, any extra samples are * either 0 (silence) or more IR samples that get applied for "free". */ - auto const count4 = usize{(IrSize+1) >> 1}; + auto const count4 = (IrSize+1) >> 1; /* NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast) * This isn't technically correct to test alignment, but it's true for @@ -93,8 +92,8 @@ void ApplyCoeffs(std::span const Values, usize const IrSize, ConstHrirSpa } force_inline void MixLine(std::span const InSamples, std::span const dst, - float &CurrentGain, float const TargetGain, float const delta, usize const fade_len, - usize const realign_len, usize const Counter) + float &CurrentGain, float const TargetGain, float const delta, std::size_t const fade_len, + std::size_t const realign_len, std::size_t const Counter) noexcept NONBLOCKING { auto const step = float{(TargetGain-CurrentGain) * delta}; @@ -198,16 +197,16 @@ force_inline void MixLine(std::span const InSamples, std::span const src, - unsigned frac, unsigned const increment, std::span const dst) + unsigned frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); - auto const filter = std::get(*state).filter; + auto const filter = gsl::not_null{std::get_if(state)}->filter; - auto pos = usize{MaxResamplerEdge-1}; + auto pos = std::size_t{MaxResamplerEdge-1}; std::ranges::generate(dst, [&pos,&frac,src,increment,filter]() -> float { - auto const pi = usize{frac >> CubicPhaseDiffBits}; ASSUME(pi < CubicPhaseCount); + auto const pi = std::size_t{frac >> CubicPhaseDiffBits}; ASSUME(pi < CubicPhaseCount); auto const pf = gsl::narrow_cast(frac&CubicPhaseDiffMask)*(1.0f/CubicPhaseDiffOne); auto const pf4 = _mm_set1_ps(pf); @@ -231,10 +230,10 @@ void Resample_Cubic_SSE(InterpState const *const state, std::span c } void Resample_FastBSinc_SSE(InterpState const *const state, std::span const src, - unsigned frac, unsigned const increment, std::span const dst) + unsigned frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { - auto const &bsinc = std::get(*state); - auto const m = usize{bsinc.m.c_val}; + auto const &bsinc = *gsl::not_null{std::get_if(state)}; + auto const m = std::size_t{bsinc.m.c_val}; ASSUME(m > 0); ASSUME(m <= MaxResamplerPadding); ASSUME(frac < MixerFracOne); @@ -242,11 +241,11 @@ void Resample_FastBSinc_SSE(InterpState const *const state, std::span float { // Calculate the phase index and factor. - auto const pi = usize{frac >> BSincPhaseDiffBits}; ASSUME(pi < BSincPhaseCount); + auto const pi = std::size_t{frac >> BSincPhaseDiffBits}; ASSUME(pi < BSincPhaseCount); auto const pf = gsl::narrow_cast(frac&BSincPhaseDiffMask)*(1.0f/BSincPhaseDiffOne); // Apply the phase interpolated filter. @@ -278,11 +277,11 @@ void Resample_FastBSinc_SSE(InterpState const *const state, std::span const src, - unsigned frac, unsigned const increment, std::span const dst) + unsigned frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { - auto const &bsinc = std::get(*state); + auto const &bsinc = *gsl::not_null{std::get_if(state)}; auto const sf4 = _mm_set1_ps(bsinc.sf); - auto const m = usize{bsinc.m.c_val}; + auto const m = std::size_t{bsinc.m.c_val}; ASSUME(m > 0); ASSUME(m <= MaxResamplerPadding); ASSUME(frac < MixerFracOne); @@ -290,11 +289,11 @@ void Resample_BSinc_SSE(InterpState const *const state, std::span c auto const filter = bsinc.filter.first(4_uz*BSincPhaseCount*m); ASSUME(bsinc.l.c_val <= MaxResamplerEdge); - auto pos = usize{MaxResamplerEdge-bsinc.l.c_val}; + auto pos = std::size_t{MaxResamplerEdge-bsinc.l.c_val}; std::ranges::generate(dst, [&pos,&frac,src,increment,sf4,m,filter]() -> float { // Calculate the phase index and factor. - auto const pi = usize{frac >> BSincPhaseDiffBits}; ASSUME(pi < BSincPhaseCount); + auto const pi = std::size_t{frac >> BSincPhaseDiffBits}; ASSUME(pi < BSincPhaseCount); auto const pf = gsl::narrow_cast(frac&BSincPhaseDiffMask)*(1.0f/BSincPhaseDiffOne); // Apply the scale and phase interpolated filter. @@ -331,12 +330,13 @@ void Resample_BSinc_SSE(InterpState const *const state, std::span c void MixHrtf_SSE(std::span const InSamples, std::span const AccumSamples, - unsigned const IrSize, MixHrtfFilter const *const hrtfparams, usize const SamplesToDo) + unsigned const IrSize, MixHrtfFilter const *const hrtfparams, std::size_t const SamplesToDo) + noexcept NONBLOCKING { MixHrtfBase(InSamples, AccumSamples, IrSize, hrtfparams, SamplesToDo); } void MixHrtfBlend_SSE(std::span const InSamples, std::span const AccumSamples, unsigned const IrSize, HrtfFilter const *const oldparams, MixHrtfFilter const *const newparams, - usize const SamplesToDo) + std::size_t const SamplesToDo) noexcept NONBLOCKING { MixHrtfBlendBase(InSamples, AccumSamples, IrSize, oldparams, newparams, SamplesToDo); @@ -345,7 +345,7 @@ void MixHrtfBlend_SSE(std::span const InSamples, std::span c void MixDirectHrtf_SSE(FloatBufferSpan const LeftOut, FloatBufferSpan const RightOut, std::span const InSamples, std::span const AccumSamples, std::span const TempBuf, std::span const ChanState, - usize const IrSize, usize const SamplesToDo) + std::size_t const IrSize, std::size_t const SamplesToDo) noexcept NONBLOCKING { MixDirectHrtfBase(LeftOut, RightOut, InSamples, AccumSamples, TempBuf, ChanState, IrSize, SamplesToDo); @@ -354,7 +354,7 @@ void MixDirectHrtf_SSE(FloatBufferSpan const LeftOut, FloatBufferSpan const Righ void Mix_SSE(std::span const InSamples, std::span const OutBuffer, std::span const CurrentGains, std::span const TargetGains, - usize const Counter, usize const OutPos) + std::size_t const Counter, std::size_t const OutPos) noexcept NONBLOCKING { if((OutPos&3) != 0) [[unlikely]] return Mix_C(InSamples, OutBuffer, CurrentGains, TargetGains, Counter, OutPos); @@ -371,7 +371,7 @@ void Mix_SSE(std::span const InSamples, std::span } void Mix_SSE(std::span const InSamples, std::span const OutBuffer, - float &CurrentGain, float const TargetGain, usize const Counter) + float &CurrentGain, float const TargetGain, std::size_t const Counter) noexcept NONBLOCKING { /* NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) */ if((reinterpret_cast(OutBuffer.data())&15) != 0) [[unlikely]] diff --git a/3rdparty/openal/core/mixer/mixer_sse2.cpp b/3rdparty/openal/core/mixer/mixer_sse2.cpp index 0b07034411f2..c563255ba4e2 100644 --- a/3rdparty/openal/core/mixer/mixer_sse2.cpp +++ b/3rdparty/openal/core/mixer/mixer_sse2.cpp @@ -36,7 +36,7 @@ #include "opthelpers.h" -#if defined(__GNUC__) && !defined(__clang__) && !defined(__SSE2__) +#if defined(__GNUC__) && !defined(__clang__) && !defined(__SSE2__) && !defined(__powerpc64__) #pragma GCC target("sse2") #endif @@ -52,7 +52,7 @@ force_inline auto vmadd(__m128 const x, __m128 const y, __m128 const z) noexcept } // namespace void Resample_Linear_SSE2(InterpState const*, std::span const src, unsigned frac, - unsigned const increment, std::span const dst) + unsigned const increment, std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); @@ -72,13 +72,13 @@ void Resample_Linear_SSE2(InterpState const*, std::span const src, std::ranges::generate(std::span{reinterpret_cast<__m128*>(dst.data()), dst.size()/4}, [src,increment4,fracMask4,fracOne4,&pos4,&frac4] { - auto const pos0 = as_unsigned(_mm_cvtsi128_si32(pos4)); - auto const pos1 = as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 4))); - auto const pos2 = as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 8))); - auto const pos3 = as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 12))); + auto const pos0 = std::size_t{as_unsigned(_mm_cvtsi128_si32(pos4))}; + auto const pos1 = std::size_t{as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 4)))}; + auto const pos2 = std::size_t{as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 8)))}; + auto const pos3 = std::size_t{as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 12)))}; ASSUME(pos0 <= pos1); ASSUME(pos1 <= pos2); ASSUME(pos2 <= pos3); auto const val1 = _mm_setr_ps(src[pos0], src[pos1], src[pos2], src[pos3]); - auto const val2 = _mm_setr_ps(src[pos0+1_uz], src[pos1+1_uz], src[pos2+1_uz], src[pos3+1_uz]); + auto const val2 = _mm_setr_ps(src[pos0+1], src[pos1+1], src[pos2+1], src[pos3+1]); /* val1 + (val2-val1)*mu */ auto const r0 = _mm_sub_ps(val2, val1); @@ -93,7 +93,7 @@ void Resample_Linear_SSE2(InterpState const*, std::span const src, if(auto const todo = dst.size()&3) { - auto pos = usize{as_unsigned(_mm_cvtsi128_si32(pos4))}; + auto pos = std::size_t{as_unsigned(_mm_cvtsi128_si32(pos4))}; frac = as_unsigned(_mm_cvtsi128_si32(frac4)); std::ranges::generate(dst.last(todo), [src,increment,&pos,&frac] @@ -110,11 +110,11 @@ void Resample_Linear_SSE2(InterpState const*, std::span const src, } void Resample_Cubic_SSE2(InterpState const *const state, std::span const src, - unsigned frac, unsigned const increment, std::span const dst) + unsigned frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); - auto const filter = std::get(*state).filter; + auto const filter = gsl::not_null{std::get_if(state)}->filter; auto const increment4 = _mm_set1_epi32(as_signed(increment*4)); auto const fracMask4 = _mm_set1_epi32(MixerFracMask); @@ -182,12 +182,12 @@ void Resample_Cubic_SSE2(InterpState const *const state, std::span if(auto const todo = dst.size()&3) { - auto pos = usize{as_unsigned(_mm_cvtsi128_si32(pos4))}; + auto pos = std::size_t{as_unsigned(_mm_cvtsi128_si32(pos4))}; frac = as_unsigned(_mm_cvtsi128_si32(frac4)); std::ranges::generate(dst.last(todo), [src,filter,increment,&pos,&frac] { - const auto pi = usize{frac >> CubicPhaseDiffBits}; ASSUME(pi < CubicPhaseCount); + const auto pi = std::size_t{frac >> CubicPhaseDiffBits}; ASSUME(pi < CubicPhaseCount); const auto pf = gsl::narrow_cast(frac&CubicPhaseDiffMask) * (1.0f/CubicPhaseDiffOne); const auto pf4 = _mm_set1_ps(pf); diff --git a/3rdparty/openal/core/mixer/mixer_sse41.cpp b/3rdparty/openal/core/mixer/mixer_sse41.cpp index ce2be9c7efb3..1ba91493495c 100644 --- a/3rdparty/openal/core/mixer/mixer_sse41.cpp +++ b/3rdparty/openal/core/mixer/mixer_sse41.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -36,7 +37,7 @@ #include "opthelpers.h" -#if defined(__GNUC__) && !defined(__clang__) && !defined(__SSE4_1__) +#if defined(__GNUC__) && !defined(__clang__) && !defined(__SSE4_1__) && !defined(__powerpc64__) #pragma GCC target("sse4.1") #endif @@ -52,7 +53,7 @@ force_inline auto vmadd(__m128 const x, __m128 const y, __m128 const z) noexcept } // namespace void Resample_Linear_SSE4(InterpState const*, std::span const src, unsigned frac, - unsigned const increment, std::span const dst) + unsigned const increment, std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); @@ -72,13 +73,13 @@ void Resample_Linear_SSE4(InterpState const*, std::span const src, std::ranges::generate(std::span{reinterpret_cast<__m128*>(dst.data()), dst.size()/4}, [src,increment4,fracMask4,fracOne4,&pos4,&frac4] { - auto const pos0 = as_unsigned(_mm_cvtsi128_si32(pos4)); - auto const pos1 = as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 4))); - auto const pos2 = as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 8))); - auto const pos3 = as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 12))); + auto const pos0 = std::size_t{as_unsigned(_mm_cvtsi128_si32(pos4))}; + auto const pos1 = std::size_t{as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 4)))}; + auto const pos2 = std::size_t{as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 8)))}; + auto const pos3 = std::size_t{as_unsigned(_mm_cvtsi128_si32(_mm_srli_si128(pos4, 12)))}; ASSUME(pos0 <= pos1); ASSUME(pos1 <= pos2); ASSUME(pos2 <= pos3); auto const val1 = _mm_setr_ps(src[pos0], src[pos1], src[pos2], src[pos3]); - auto const val2 = _mm_setr_ps(src[pos0+1_uz], src[pos1+1_uz], src[pos2+1_uz], src[pos3+1_uz]); + auto const val2 = _mm_setr_ps(src[pos0+1], src[pos1+1], src[pos2+1], src[pos3+1]); /* val1 + (val2-val1)*mu */ auto const r0 = _mm_sub_ps(val2, val1); @@ -97,7 +98,7 @@ void Resample_Linear_SSE4(InterpState const*, std::span const src, * four samples, so the lowest element is the next position to * resample. */ - auto pos = usize{as_unsigned(_mm_cvtsi128_si32(pos4))}; + auto pos = std::size_t{as_unsigned(_mm_cvtsi128_si32(pos4))}; frac = as_unsigned(_mm_cvtsi128_si32(frac4)); std::ranges::generate(dst.last(todo), [&pos,&frac,src,increment] @@ -114,11 +115,11 @@ void Resample_Linear_SSE4(InterpState const*, std::span const src, } void Resample_Cubic_SSE4(InterpState const *const state, std::span const src, - unsigned frac, unsigned const increment, std::span const dst) + unsigned frac, unsigned const increment, std::span const dst) noexcept NONBLOCKING { ASSUME(frac < MixerFracOne); - auto const filter = std::get(*state).filter; + auto const filter = gsl::not_null{std::get_if(state)}->filter; auto const increment4 = _mm_set1_epi32(as_signed(increment*4)); auto const fracMask4 = _mm_set1_epi32(MixerFracMask); @@ -186,12 +187,12 @@ void Resample_Cubic_SSE4(InterpState const *const state, std::span if(auto const todo = dst.size()&3) { - auto pos = usize{as_unsigned(_mm_cvtsi128_si32(pos4))}; + auto pos = std::size_t{as_unsigned(_mm_cvtsi128_si32(pos4))}; frac = as_unsigned(_mm_cvtsi128_si32(frac4)); std::ranges::generate(dst.last(todo), [&pos,&frac,src,increment,filter] { - auto const pi = usize{frac >> CubicPhaseDiffBits}; ASSUME(pi < CubicPhaseCount); + auto const pi = std::size_t{frac >> CubicPhaseDiffBits}; ASSUME(pi < CubicPhaseCount); auto const pf = gsl::narrow_cast(frac&CubicPhaseDiffMask) * (1.0f/CubicPhaseDiffOne); auto const pf4 = _mm_set1_ps(pf); diff --git a/3rdparty/openal/core/rtkit.cpp b/3rdparty/openal/core/rtkit.cpp index aed4f9ada39f..aab9b017de6d 100644 --- a/3rdparty/openal/core/rtkit.cpp +++ b/3rdparty/openal/core/rtkit.cpp @@ -49,13 +49,18 @@ #include "dynload.h" #include "gsl/gsl" -#include "logging.h" #if HAVE_DYNLOAD #include +#if HAVE_CXXMODULES +import logging; +#else +#include "logging.h" +#endif + namespace { #define DBUS_FUNCTIONS(MAGIC) \ @@ -150,6 +155,12 @@ auto HasDBus() -> bool #else +#if HAVE_CXXMODULES +import logging; +#else +#include "logging.h" +#endif + namespace { constexpr auto HasDBus() noexcept -> bool { return true; } } /* namespace */ diff --git a/3rdparty/openal/core/tsmefilter.cpp b/3rdparty/openal/core/tsmefilter.cpp index 5c945df2bae4..2277b0c6d377 100644 --- a/3rdparty/openal/core/tsmefilter.cpp +++ b/3rdparty/openal/core/tsmefilter.cpp @@ -1,15 +1,23 @@ +#include "config.h" + #include #include "allpass_conv.hpp" #include "altypes.hpp" #include "tsmefilter.hpp" +#if HAVE_CXXMODULES +import phase_shifter; +#else +#include "phase_shifter.hpp" +#endif + namespace { -template -constexpr auto assume_aligned_span(std::span const s) noexcept -> std::span -{ return std::span{std::assume_aligned(s.data()), s.size()}; } +template constexpr +auto assume_aligned_span(std::span const s) noexcept -> std::span +{ return std::span{std::assume_aligned(s.data()), s.size()}; } } /* namespace */ @@ -126,7 +134,7 @@ constexpr auto assume_aligned_span(std::span const s) noexcept -> std::span * Right = S - D */ -template +template void TsmeEncoder::encode(const std::span LeftOut, const std::span RightOut, const std::span> InSamples) { @@ -320,5 +328,184 @@ void TsmeEncoderIIR::encode(const std::span LeftOut, const std::span; -template struct TsmeEncoder; + +/* This Super Stereo decoder is copied from uhjfilter.cpp. The reason for a + * separate implementation is due to the phase shift not interacting well with + * the TSME encoder, resulting in severely reduced stereo separation. Reversing + * the phase shift fixes it to retain stereo separation, although causes + * reduced stereo separation with the UHJ encoder. + * + * For N3D output scaling, this becomes: + * + * S = Left + Right + * D = Left - Right + * + * W = 0.6098637*S - j(0.6896511*w*D) + * X = 1.05631501729*S + j(0.934107402059*w*D) + * Y = 2.06031664957*w*D - j(0.264078754323*S) + * + * where j is a +90 degree phase shift. w is a variable control for the + * resulting stereo width, with the range 0 <= w <= 0.7. + */ +template +void TsmeStereoDecoder::decode(std::span> const samples, + bool const updateState) +{ + static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large"); + + const auto samplesToDo = samples[0].size() - sInputPadding; + + { + const auto left = assume_aligned_span<16>(samples[0]); + const auto right = assume_aligned_span<16>(samples[1]); + + std::ranges::transform(left, right, mS.begin(), std::plus{}); + + /* Pre-apply the width factor to the difference signal D. Smoothly + * interpolate when it changes. + */ + const auto wtarget = mWidthControl; + const auto wcurrent = (mCurrentWidth < 0.0f) ? wtarget : mCurrentWidth; + if(wtarget == wcurrent || !updateState) + { + std::ranges::transform(left, right, mD.begin(), [wcurrent](float l, float r) noexcept + { return (l-r) * wcurrent; }); + mCurrentWidth = wcurrent; + } + else + { + const auto wstep = (wtarget - wcurrent) / gsl::narrow_cast(samplesToDo); + auto fi = 0.0f; + + const auto lfade = left.first(samplesToDo); + auto dstore = std::ranges::transform(lfade, right, mD.begin(), + [wcurrent,wstep,&fi](const float l, const float r) noexcept + { + const float ret{(l-r) * (wcurrent + wstep*fi)}; + fi += 1.0f; + return ret; + }).out; + + const auto lend = left.last(sInputPadding); + const auto rend = right.last(sInputPadding); + std::ranges::transform(lend, rend, dstore, [wtarget](float l, float r) noexcept + { return (l-r) * wtarget; }); + mCurrentWidth = wtarget; + } + } + + const auto woutput = assume_aligned_span<16>(samples[0].first(samplesToDo)); + const auto xoutput = assume_aligned_span<16>(samples[1].first(samplesToDo)); + const auto youtput = assume_aligned_span<16>(samples[2].first(samplesToDo)); + + /* Precompute j*D and store in xoutput. */ + auto tmpiter = std::ranges::copy(mDTHistory, mTemp.begin()).out; + std::ranges::copy(mD | std::views::take(samplesToDo+sInputPadding), tmpiter); + if(updateState) [[likely]] + std::ranges::copy(mTemp|std::views::drop(samplesToDo)|std::views::take(mDTHistory.size()), + mDTHistory.begin()); + gPShifter.process(xoutput, mTemp); + + /* W = 0.6098637*S - j(0.6896511*w*D) */ + std::ranges::transform(mS, xoutput, woutput.begin(), [](const float s, const float jd) noexcept + { return 0.6098637f*s - 0.6896511f*jd; }); + /* X = 1.05631501729*S + j(0.934107402059*w*D) */ + std::ranges::transform(mS, xoutput, xoutput.begin(), [](const float s, const float jd) noexcept + { return 1.05631501729f*s + 0.934107402059f*jd; }); + + /* Precompute j*S and store in youtput. */ + tmpiter = std::ranges::copy(mSHistory, mTemp.begin()).out; + std::ranges::copy(mS | std::views::take(samplesToDo+sInputPadding), tmpiter); + if(updateState) [[likely]] + std::ranges::copy(mTemp|std::views::drop(samplesToDo)|std::views::take(mSHistory.size()), + mSHistory.begin()); + gPShifter.process(youtput, mTemp); + + /* Y = 2.06031664957*w*D - j(0.264078754323*S) */ + std::ranges::transform(mD, youtput, youtput.begin(), [](const float d, const float js) noexcept + { return 2.06031664957f*d - 0.264078754323f*js; }); +} + +void TsmeStereoDecoderIIR::decode(std::span> const samples, + bool const updateState) +{ + static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large"); + + const auto samplesToDo = samples[0].size() - sInputPadding; + + { + const auto left = assume_aligned_span<16>(samples[0]); + const auto right = assume_aligned_span<16>(samples[1]); + + std::ranges::transform(left, right, mS.begin(), std::plus{}); + + /* Pre-apply the width factor to the difference signal D. Smoothly + * interpolate when it changes. + */ + const auto wtarget = mWidthControl; + const auto wcurrent = (mCurrentWidth < 0.0f) ? wtarget : mCurrentWidth; + if(wtarget == wcurrent || !updateState) + { + std::ranges::transform(left, right, mD.begin(), [wcurrent](float l, float r) noexcept + { return (l-r) * wcurrent; }); + mCurrentWidth = wcurrent; + } + else + { + const auto wstep = (wtarget - wcurrent) / gsl::narrow_cast(samplesToDo); + auto fi = 0.0f; + + const auto lfade = left.first(samplesToDo); + auto dstore = std::ranges::transform(lfade, right, mD.begin(), + [wcurrent,wstep,&fi](const float l, const float r) noexcept + { + const float ret{(l-r) * (wcurrent + wstep*fi)}; + fi += 1.0f; + return ret; + }).out; + + const auto lend = left.last(sInputPadding); + const auto rend = right.last(sInputPadding); + std::ranges::transform(lend, rend, dstore, [wtarget](float l, float r) noexcept + { return (l-r) * wtarget; }); + mCurrentWidth = wtarget; + } + } + + const auto woutput = assume_aligned_span<16>(samples[0].first(samplesToDo)); + const auto xoutput = assume_aligned_span<16>(samples[1].first(samplesToDo)); + const auto youtput = assume_aligned_span<16>(samples[2].first(samplesToDo)); + + /* Apply filter1 to S and store in mTemp. */ + process(mFilter1S, Filter1Coeff, std::span{mS}.first(samplesToDo), updateState, mTemp); + + /* Precompute j*D and store in xoutput. */ + if(mFirstRun) processOne(mFilter2D, Filter2Coeff, mD[0]); + process(mFilter2D, Filter2Coeff, std::span{mD}.subspan(1, samplesToDo), updateState, xoutput); + + /* W = 0.6098637*S - j(0.6896511*w*D) */ + std::ranges::transform(mTemp, xoutput, woutput.begin(), [](float s, float jd) noexcept + { return 0.6098637f*s - 0.6896511f*jd; }); + /* X = 1.05631501729*S + j(0.934107402059*w*D) */ + std::ranges::transform(mTemp, xoutput, xoutput.begin(), [](float s, float jd) noexcept + { return 1.05631501729f*s + 0.934107402059f*jd; }); + + /* Precompute j*S and store in youtput. */ + if(mFirstRun) processOne(mFilter2S, Filter2Coeff, mS[0]); + process(mFilter2S, Filter2Coeff, std::span{mS}.subspan(1, samplesToDo), updateState, youtput); + + /* Apply filter1 to D and store in mTemp. */ + process(mFilter1D, Filter1Coeff, std::span{mD}.first(samplesToDo), updateState, mTemp); + + /* Y = 2.06031664957*w*D - j(0.264078754323*S) */ + std::ranges::transform(mTemp, youtput, youtput.begin(), [](float d, float js) noexcept + { return 2.06031664957f*d - 0.264078754323f*js; }); + + mFirstRun = false; +} + + +template struct TsmeEncoder<256>; +template struct TsmeStereoDecoder<256>; +template struct TsmeEncoder<512>; +template struct TsmeStereoDecoder<512>; diff --git a/3rdparty/openal/core/tsmefilter.hpp b/3rdparty/openal/core/tsmefilter.hpp index fb29961ca70f..9ef707d2ab07 100644 --- a/3rdparty/openal/core/tsmefilter.hpp +++ b/3rdparty/openal/core/tsmefilter.hpp @@ -8,12 +8,10 @@ #include "allpass_iir.hpp" #include "altypes.hpp" #include "bufferline.h" +#include "decoderbase.hpp" #include "encoderbase.hpp" -inline constexpr auto TsmeLength256 = 256_uz; -inline constexpr auto TsmeLength512 = 512_uz; - enum class TsmeQualityType : u8::value_t { IIR = 0, FIR256, @@ -25,7 +23,7 @@ inline auto TsmeDecodeQuality = TsmeQualityType::Default; inline auto TsmeEncodeQuality = TsmeQualityType::Default; -template +template struct TsmeEncoder final : EncoderBase { struct Tag { using encoder_t = TsmeEncoder; }; @@ -52,7 +50,7 @@ struct TsmeEncoder final : EncoderBase { alignas(16) std::array mD{}; /* History and temp storage for the convolution filter. */ - usize mFifoPos{}, mCurrentSegment{}; + std::size_t mFifoPos{}, mCurrentSegment{}; alignas(16) std::array mWXInOut{}; alignas(16) std::array mFftBuffer{}; alignas(16) std::array mWorkData{}; @@ -60,7 +58,7 @@ struct TsmeEncoder final : EncoderBase { alignas(16) std::array,2> mDirectDelay{}; - auto getDelay() noexcept -> usize final { return sFilterDelay; } + auto getDelay() noexcept -> std::size_t final { return sFilterDelay; } /** * Encodes a 2-channel tetraphonic surround matrix-encoded (stereo @@ -70,6 +68,8 @@ struct TsmeEncoder final : EncoderBase { auto encode(std::span LeftOut, std::span RightOut, std::span> InSamples) -> void final; }; +using TsmeEncoder256 = TsmeEncoder<256>; +using TsmeEncoder512 = TsmeEncoder<512>; struct TsmeEncoderIIR final : EncoderBase { struct Tag { using encoder_t = TsmeEncoderIIR; }; @@ -93,7 +93,7 @@ struct TsmeEncoderIIR final : EncoderBase { std::array mFilter1Direct; std::array mDirectDelay{}; - auto getDelay() noexcept -> usize final { return sFilterDelay; } + auto getDelay() noexcept -> std::size_t final { return sFilterDelay; } /** * Encodes a 2-channel tetraphonic surround matrix-encoded (stereo @@ -104,4 +104,51 @@ struct TsmeEncoderIIR final : EncoderBase { std::span> InSamples) -> void final; }; +template +struct TsmeStereoDecoder final : DecoderBase { + struct Tag { using decoder_t = TsmeStereoDecoder; }; + + static constexpr auto sInputPadding = N/2_uz; + + float mCurrentWidth{-1.0f}; + + alignas(16) std::array mS{}; + alignas(16) std::array mD{}; + + alignas(16) std::array mDTHistory{}; + alignas(16) std::array mSHistory{}; + + alignas(16) std::array mTemp{}; + + /** + * Applies Super Stereo processing on a stereo signal to create a B-Format + * signal with FuMa channel ordering and N3D scaling. The samples span + * should contain 3 channels, the first two being the left and right stereo + * channels, and the third left empty. + */ + void decode(std::span> samples, bool updateState) final; +}; +using TsmeStereoDecoder256 = TsmeStereoDecoder<256>; +using TsmeStereoDecoder512 = TsmeStereoDecoder<512>; + +struct TsmeStereoDecoderIIR final : DecoderBase { + struct Tag { using decoder_t = TsmeStereoDecoderIIR; }; + + static constexpr auto sInputPadding = 1_uz; + + bool mFirstRun{true}; + float mCurrentWidth{-1.0f}; + + alignas(16) std::array mS{}; + alignas(16) std::array mD{}; + alignas(16) std::array mTemp{}; + + AllPassFilter mFilter1S; + AllPassFilter mFilter2D; + AllPassFilter mFilter1D; + AllPassFilter mFilter2S; + + void decode(std::span> samples, bool updateState) final; +}; + #endif /* CORE_TSMEFILTER_HPP */ diff --git a/3rdparty/openal/core/uhjfilter.cpp b/3rdparty/openal/core/uhjfilter.cpp index 5c56f949f999..a222444a1ed5 100644 --- a/3rdparty/openal/core/uhjfilter.cpp +++ b/3rdparty/openal/core/uhjfilter.cpp @@ -4,24 +4,22 @@ #include "uhjfilter.h" #include -#include #include #include #include #include -#include #include #include -#include -#include "alcomplex.h" -#include "alnumeric.h" #include "allpass_conv.hpp" #include "gsl/gsl" #include "pffft.h" -#include "phase_shifter.h" -#include "vector.h" +#if HAVE_CXXMODULES +import phase_shifter; +#else +#include "phase_shifter.hpp" +#endif /* UHJ is primarily defined in terms of classical B-Format. In particular, * classical B-Format defines the encoding gains for a given sound at @@ -34,7 +32,7 @@ * * That is, FuMa with an additional sqrt(2) scaling. The encoding and decoding * functions below work according to N3D scaling, which has the gains: -* + * * W = 1 * X = sqrt(3) * cos(a) * cos(e) * Y = sqrt(3) * sin(a) * cos(e) @@ -81,7 +79,7 @@ constexpr auto assume_aligned_span(const std::span s) noexcept -> std::span * segmented FFT'd response for the desired shift. */ -template +template void UhjEncoder::encode(const std::span LeftOut, const std::span RightOut, const std::span> InSamples) { @@ -299,7 +297,7 @@ void UhjEncoderIIR::encode(const std::span LeftOut, const std::span +template void UhjDecoder::decode(const std::span> samples, const bool updateState) { static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large"); @@ -446,7 +444,7 @@ void UhjDecoderIIR::decode(const std::span> samples, const bool * X = 1.05631501729*S - j(0.934107402059*w*D) * Y = 2.06031664957*w*D + j(0.264078754323*S) */ -template +template void UhjStereoDecoder::decode(const std::span> samples, const bool updateState) { static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large"); @@ -602,10 +600,10 @@ void UhjStereoDecoderIIR::decode(const std::span> samples, cons } -template struct UhjEncoder; -template struct UhjDecoder; -template struct UhjStereoDecoder; +template struct UhjEncoder<256>; +template struct UhjDecoder<256>; +template struct UhjStereoDecoder<256>; -template struct UhjEncoder; -template struct UhjDecoder; -template struct UhjStereoDecoder; +template struct UhjEncoder<512>; +template struct UhjDecoder<512>; +template struct UhjStereoDecoder<512>; diff --git a/3rdparty/openal/core/uhjfilter.h b/3rdparty/openal/core/uhjfilter.h index 2bd34d2e4172..1482c1c65dae 100644 --- a/3rdparty/openal/core/uhjfilter.h +++ b/3rdparty/openal/core/uhjfilter.h @@ -9,12 +9,10 @@ #include "allpass_iir.hpp" #include "altypes.hpp" #include "bufferline.h" +#include "decoderbase.hpp" #include "encoderbase.hpp" -inline constexpr auto UhjLength256 = 256_uz; -inline constexpr auto UhjLength512 = 512_uz; - enum class UhjQualityType : u8::value_t { IIR = 0, FIR256, @@ -26,7 +24,7 @@ inline auto UhjDecodeQuality = UhjQualityType::Default; inline auto UhjEncodeQuality = UhjQualityType::Default; -template +template struct UhjEncoder final : EncoderBase { struct Tag { using encoder_t = UhjEncoder; }; @@ -52,7 +50,7 @@ struct UhjEncoder final : EncoderBase { alignas(16) std::array mD{}; /* History and temp storage for the convolution filter. */ - usize mFifoPos{}, mCurrentSegment{}; + std::size_t mFifoPos{}, mCurrentSegment{}; alignas(16) std::array mWXInOut{}; alignas(16) std::array mFftBuffer{}; alignas(16) std::array mWorkData{}; @@ -60,7 +58,7 @@ struct UhjEncoder final : EncoderBase { alignas(16) std::array,2> mDirectDelay{}; - auto getDelay() noexcept -> usize final { return sFilterDelay; } + auto getDelay() noexcept -> std::size_t final { return sFilterDelay; } /** * Encodes a 2-channel UHJ (stereo-compatible) signal from a B-Format input @@ -69,6 +67,8 @@ struct UhjEncoder final : EncoderBase { auto encode(std::span LeftOut, std::span RightOut, std::span> InSamples) -> void final; }; +using UhjEncoder256 = UhjEncoder<256>; +using UhjEncoder512 = UhjEncoder<512>; struct UhjEncoderIIR final : EncoderBase { struct Tag { using encoder_t = UhjEncoderIIR; }; @@ -92,7 +92,7 @@ struct UhjEncoderIIR final : EncoderBase { std::array mFilter1Direct; std::array mDirectDelay{}; - auto getDelay() noexcept -> usize final { return sFilterDelay; } + auto getDelay() noexcept -> std::size_t final { return sFilterDelay; } /** * Encodes a 2-channel UHJ (stereo-compatible) signal from a B-Format input @@ -103,37 +103,7 @@ struct UhjEncoderIIR final : EncoderBase { }; -struct DecoderBase { - static constexpr auto sMaxPadding = 256_uz; - - /* For 2-channel UHJ, shelf filters should use these LF responses. */ - static constexpr auto sWLFScale = 0.661f; - static constexpr auto sXYLFScale = 1.293f; - - DecoderBase() = default; - DecoderBase(const DecoderBase&) = delete; - DecoderBase(DecoderBase&&) = delete; - virtual ~DecoderBase() = default; - - void operator=(const DecoderBase&) = delete; - void operator=(DecoderBase&&) = delete; - - virtual void decode(std::span> samples, bool updateState) = 0; - - /** - * The width factor for Super Stereo processing. Can be changed in between - * calls to decode, with valid values being between 0...0.7. - * - * 0.46 seems to produce the least amount of channel bleed when the output - * is subsequently UHJ encoded (given a stereo sound with a noise on the - * left buffer channel, for instance, when decoded with UhjStereoDecoder - * and then encoded with UhjEncoder, the right output channel was at its - * quietest). - */ - float mWidthControl{0.46f}; -}; - -template +template struct UhjDecoder final : DecoderBase { struct Tag { using decoder_t = UhjDecoder; }; @@ -159,6 +129,8 @@ struct UhjDecoder final : DecoderBase { */ void decode(std::span> samples, bool updateState) final; }; +using UhjDecoder256 = UhjDecoder<256>; +using UhjDecoder512 = UhjDecoder<512>; struct UhjDecoderIIR final : DecoderBase { struct Tag { using decoder_t = UhjDecoderIIR; }; @@ -185,7 +157,7 @@ struct UhjDecoderIIR final : DecoderBase { void decode(std::span> samples, bool updateState) final; }; -template +template struct UhjStereoDecoder final : DecoderBase { struct Tag { using decoder_t = UhjStereoDecoder; }; @@ -209,6 +181,8 @@ struct UhjStereoDecoder final : DecoderBase { */ void decode(std::span> samples, bool updateState) final; }; +using UhjStereoDecoder256 = UhjStereoDecoder<256>; +using UhjStereoDecoder512 = UhjStereoDecoder<512>; struct UhjStereoDecoderIIR final : DecoderBase { struct Tag { using decoder_t = UhjStereoDecoderIIR; }; diff --git a/3rdparty/openal/core/voice.cpp b/3rdparty/openal/core/voice.cpp index a83dcb8c180a..39ff7c3e3d7d 100644 --- a/3rdparty/openal/core/voice.cpp +++ b/3rdparty/openal/core/voice.cpp @@ -31,15 +31,20 @@ #include "filters/splitter.h" #include "fmt_traits.h" #include "gsl/gsl" -#include "logging.h" #include "mixer.h" #include "mixer/defs.h" #include "mixer/hrtfdefs.h" #include "opthelpers.h" #include "resampler_limits.h" #include "ringbuffer.h" -#include "vector.h" -#include "voice_change.h" +#include "tsmefilter.hpp" +#include "uhjfilter.h" + +#if HAVE_CXXMODULES +import logging; +#else +#include "logging.h" +#endif namespace { @@ -57,10 +62,10 @@ using namespace std::chrono; using namespace std::string_view_literals; using HrtfMixerFunc = void(*)(std::span InSamples, std::span AccumSamples, - unsigned IrSize, MixHrtfFilter const *hrtfparams, usize SamplesToDo); + unsigned IrSize, MixHrtfFilter const *hrtfparams, std::size_t SamplesToDo); using HrtfMixerBlendFunc = void(*)(std::span InSamples, std::span AccumSamples, unsigned IrSize, HrtfFilter const *oldparams, MixHrtfFilter const *newparams, - usize SamplesToDo); + std::size_t SamplesToDo); constinit auto MixHrtfSamples = HrtfMixerFunc{MixHrtf_C}; constinit auto MixHrtfBlendSamples = HrtfMixerBlendFunc{MixHrtfBlend_C}; @@ -181,7 +186,7 @@ void Voice::InitMixer(std::optional const &resopt) namespace { /* IMA ADPCM Stepsize table */ -constexpr auto IMAStep_size = std::array{ +constexpr auto IMAStep_size = std::to_array({ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, @@ -191,35 +196,35 @@ constexpr auto IMAStep_size = std::array{ 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493,10442, 11487,12635,13899,15289,16818,18500,20350,22358,24633,27086,29794, 32767 -}; +}); /* IMA4 ADPCM Codeword decode table */ -constexpr auto IMA4Codeword = std::array{ +constexpr auto IMA4Codeword = std::to_array({ 1, 3, 5, 7, 9, 11, 13, 15, -1,-3,-5,-7,-9,-11,-13,-15, -}; +}); /* IMA4 ADPCM Step index adjust decode table */ -constexpr auto IMA4Index_adjust = std::array{ +constexpr auto IMA4Index_adjust = std::to_array({ -1,-1,-1,-1, 2, 4, 6, 8, -1,-1,-1,-1, 2, 4, 6, 8 -}; +}); /* MSADPCM Adaption table */ -constexpr auto MSADPCMAdaption = std::array{ +constexpr auto MSADPCMAdaption = std::to_array({ 230, 230, 230, 230, 307, 409, 512, 614, 768, 614, 512, 409, 307, 230, 230, 230 -}; +}); /* MSADPCM Adaption Coefficient tables */ constexpr auto MSADPCMAdaptionCoeff = std::array{ - std::array{256, 0}, - std::array{512, -256}, - std::array{ 0, 0}, - std::array{192, 64}, - std::array{240, 0}, - std::array{460, -208}, - std::array{392, -232} + std::to_array({256, 0}), + std::to_array({512, -256}), + std::to_array({ 0, 0}), + std::to_array({192, 64}), + std::to_array({240, 0}), + std::to_array({460, -208}), + std::to_array({392, -232}) }; @@ -254,8 +259,8 @@ auto DoFilters(BiquadInterpFilter &lpfilter, BiquadInterpFilter &hpfilter, template void LoadSamples(std::span const dstSamples, std::span const srcData, - usize const srcChan, usize const srcOffset, usize const srcStep, - usize const samplesPerBlock [[maybe_unused]]) noexcept + std::size_t const srcChan, std::size_t const srcOffset, std::size_t const srcStep, + std::size_t const samplesPerBlock [[maybe_unused]]) noexcept { using TypeTraits = SampleInfo; Expects(srcChan < srcStep); @@ -272,10 +277,10 @@ void LoadSamples(std::span const dstSamples, std::span const src template<> void LoadSamples(std::span dstSamples, std::span src, - usize const srcChan, usize const srcOffset, usize const srcStep, - usize const samplesPerBlock) noexcept + std::size_t const srcChan, std::size_t const srcOffset, std::size_t const srcStep, + std::size_t const samplesPerBlock) noexcept { - static constexpr auto MaxStepIndex = gsl::narrow(IMAStep_size.size()) - 1; + static constexpr auto MaxStepIndex = isize{std::ssize(IMAStep_size) - 1}; Expects(srcStep > 0 && srcStep <= 2); Expects(srcChan < srcStep); @@ -293,17 +298,17 @@ void LoadSamples(std::span dstSamples, std::span(); + auto ima_idx = i16::bit_pack(src[srcChan*4 + 3].value, src[srcChan*4 + 2].value) + .as(); + ima_idx = std::clamp(ima_idx, 0_isize, MaxStepIndex); auto const nibbleData = src.subspan((srcStep+srcChan)*4); src = src.subspan(blockBytes); if(skip == 0) { - dstSamples[0] = gsl::narrow_cast(sample) / 32768.0f; + dstSamples[0] = sample.cast_to().c_val / 32768.0f; dstSamples = dstSamples.subspan(1); if(dstSamples.empty()) return; } @@ -314,8 +319,8 @@ void LoadSamples(std::span dstSamples, std::span int + auto decode_nibble = [&sample,&ima_idx,srcStep,nibbleData](std::size_t const nibbleOffset) + noexcept -> i32 { static constexpr auto NibbleMask = std::byte{0xf}; auto const byteShift = (nibbleOffset&1) * 4; @@ -323,12 +328,13 @@ void LoadSamples(std::span dstSamples, std::span>1)&3); auto const nibble = (nibbleData[byteOffset].value >> byteShift) & NibbleMask; - auto const codeidx = to_integer(nibble); + auto const codeidx = to_integer(nibble); - sample += IMA4Codeword[codeidx]*IMAStep_size[gsl::narrow_cast(ima_idx)]/8; - sample = std::clamp(sample, -32768, 32767); + sample += IMA4Codeword[codeidx] * IMAStep_size[as_unsigned(ima_idx.c_val)] / 8; + sample = std::clamp(sample, -32768_i32, 32767_i32); - ima_idx = std::clamp(ima_idx + IMA4Index_adjust[codeidx], 0_z, MaxStepIndex); + ima_idx = std::clamp(ima_idx + IMA4Index_adjust[codeidx], 0_isize, + MaxStepIndex); return sample; }; @@ -354,7 +360,7 @@ void LoadSamples(std::span dstSamples, std::span(decspl) / 32768.0f; + return decspl.cast_to().c_val / 32768.0f; }); dstSamples = dstSamples.subspan(written); } @@ -362,8 +368,8 @@ void LoadSamples(std::span dstSamples, std::span void LoadSamples(std::span dstSamples, std::span src, - usize const srcChan, usize const srcOffset, usize const srcStep, - usize const samplesPerBlock) noexcept + std::size_t const srcChan, std::size_t const srcOffset, std::size_t const srcStep, + std::size_t const samplesPerBlock) noexcept { Expects(srcStep > 0 && srcStep <= 2); Expects(srcChan < srcStep); @@ -381,16 +387,16 @@ void LoadSamples(std::span dstSamples, std::span(src[srcChan].value), - u8::value_t{MSADPCMAdaptionCoeff.size()-1})}; - auto scale = int{i16::bit_pack(src[srcStep + 2*srcChan + 1].value, - src[srcStep + 2*srcChan + 0].value).c_val}; + auto const blockpred = std::min(u8::bit_pack(src[srcChan].value), + u8{MSADPCMAdaptionCoeff.size()-1}); + auto scale = i16::bit_pack(src[srcStep + 2*srcChan + 1].value, + src[srcStep + 2*srcChan + 0].value).as(); auto sampleHistory = std::array{ - int{i16::bit_pack(src[3*srcStep + 2*srcChan + 1].value, - src[3*srcStep + 2*srcChan + 0].value).c_val}, - int{i16::bit_pack(src[5*srcStep + 2*srcChan + 1].value, - src[5*srcStep + 2*srcChan + 0].value).c_val}}; + i16::bit_pack(src[3*srcStep + 2*srcChan + 1].value, + src[3*srcStep + 2*srcChan + 0].value).as(), + i16::bit_pack(src[5*srcStep + 2*srcChan + 1].value, + src[5*srcStep + 2*srcChan + 0].value).as()}; auto const nibbleData = src.subspan(7*srcStep); src = src.subspan(blockBytes); @@ -402,16 +408,16 @@ void LoadSamples(std::span dstSamples, std::span(sampleHistory[1]) / 32768.0f; + dstSamples[0] = sampleHistory[1].cast_to().c_val / 32768.0f; if(dstSamples.size() < 2) return; - dstSamples[1] = gsl::narrow_cast(sampleHistory[0]) / 32768.0f; + dstSamples[1] = sampleHistory[0].cast_to().c_val / 32768.0f; dstSamples = dstSamples.subspan(2); if(dstSamples.empty()) return; } else if(skip == 1) { --skip; - dstSamples[0] = gsl::narrow_cast(sampleHistory[0]) / 32768.0f; + dstSamples[0] = sampleHistory[0].cast_to().c_val / 32768.0f; dstSamples = dstSamples.subspan(1); if(dstSamples.empty()) return; } @@ -421,8 +427,8 @@ void LoadSamples(std::span dstSamples, std::span int + auto decode_nibble = [&sampleHistory,&scale,coeffs,nibbleData] + (std::size_t const nibbleOffset) noexcept -> i32 { static constexpr auto NibbleMask = std::byte{0xf}; auto const byteOffset = nibbleOffset>>1; @@ -431,14 +437,14 @@ void LoadSamples(std::span dstSamples, std::span> byteShift) & NibbleMask; auto const nval = to_integer(nibble); - auto const pred = ((int{nval}^0x08) - 0x08) * scale; + auto const pred = ((i32{nval}^0x08) - 0x08) * scale; auto const diff = (sampleHistory[0]*coeffs[0] + sampleHistory[1]*coeffs[1]) / 256; - auto const sample = std::clamp(pred + diff, -32768, 32767); + auto const sample = std::clamp(pred + diff, -32768_i32, 32767_i32); sampleHistory[1] = sampleHistory[0]; sampleHistory[0] = sample; - scale = std::max(MSADPCMAdaption[nval] * scale / 256, 16); + scale = std::max(MSADPCMAdaption[nval] * scale / 256_i32, 16_i32); return sample; }; @@ -461,15 +467,15 @@ void LoadSamples(std::span dstSamples, std::span(sample) / 32768.0f; + return sample.cast_to().c_val / 32768.0f; }); dstSamples = dstSamples.subspan(written); } } void LoadSamples(std::span const dstSamples, SampleVariant const &src, - usize const srcChan, usize const srcOffset, usize const srcStep, - usize const samplesPerBlock) noexcept + std::size_t const srcChan, std::size_t const srcOffset, std::size_t const srcStep, + std::size_t const samplesPerBlock) noexcept { std::visit([&](T&& splvec) { @@ -479,8 +485,8 @@ void LoadSamples(std::span const dstSamples, SampleVariant const &src, } void LoadBufferStatic(VoiceBufferItem const *const buffer, - VoiceBufferItem const *const bufferLoopItem, usize const dataPosInt, usize const srcChannel, - usize const srcStep, std::span voiceSamples) + VoiceBufferItem const *const bufferLoopItem, std::size_t const dataPosInt, + std::size_t const srcChannel, std::size_t const srcStep, std::span voiceSamples) { if(!bufferLoopItem) { @@ -500,8 +506,8 @@ void LoadBufferStatic(VoiceBufferItem const *const buffer, } else { - auto const loopStart = usize{buffer->mLoopStart}; - auto const loopEnd = usize{buffer->mLoopEnd}; + auto const loopStart = std::size_t{buffer->mLoopStart}; + auto const loopEnd = std::size_t{buffer->mLoopEnd}; ASSUME(loopEnd > loopStart); auto const intPos = (dataPosInt < loopEnd) ? dataPosInt @@ -524,8 +530,8 @@ void LoadBufferStatic(VoiceBufferItem const *const buffer, } } -void LoadBufferCallback(VoiceBufferItem const *const buffer, usize const dataPosInt, - usize const numCallbackSamples, usize const srcChannel, usize const srcStep, +void LoadBufferCallback(VoiceBufferItem const *const buffer, std::size_t const dataPosInt, + std::size_t const numCallbackSamples, std::size_t const srcChannel, std::size_t const srcStep, std::span voiceSamples) { auto lastSample = 0.0f; @@ -542,7 +548,7 @@ void LoadBufferCallback(VoiceBufferItem const *const buffer, usize const dataPos } void LoadBufferQueue(VoiceBufferItem const *buffer, VoiceBufferItem const *const bufferLoopItem, - usize dataPosInt, usize const srcChannel, usize const srcStep, + std::size_t dataPosInt, std::size_t const srcChannel, std::size_t const srcStep, std::span voiceSamples) { auto lastSample = 0.0f; @@ -576,7 +582,7 @@ void LoadBufferQueue(VoiceBufferItem const *buffer, VoiceBufferItem const *const void DoHrtfMix(std::span const samples, DirectParams &parms, float const targetGain, - usize const counter, usize outPos, bool const isPlaying, DeviceBase *const device) + std::size_t const counter, std::size_t outPos, bool const isPlaying, DeviceBase *const device) { auto const IrSize = device->mIrSize; auto const HrtfSamples = std::span{device->ExtraSampleData}; @@ -656,7 +662,9 @@ void DoNfcMix(std::span const samples, std::span o DirectParams &parms, std::span const outGains, unsigned const counter, unsigned const outPos, DeviceBase *const device) { - using FilterProc = void(NfcFilter::*)(std::span src, std::span dst); + using FilterProc = void(NfcFilter::*)(std::span src, std::span dst) + noexcept NONBLOCKING; + static constexpr auto NfcProcess = std::array{FilterProc{nullptr}, &NfcFilter::process1, &NfcFilter::process2, &NfcFilter::process3, &NfcFilter::process4}; static_assert(NfcProcess.size() == MaxAmbiOrder+1); @@ -669,7 +677,7 @@ void DoNfcMix(std::span const samples, std::span o auto const nfcsamples = std::span{device->ExtraSampleData}.first(samples.size()); auto order = 1_uz; - while(auto const chancount = usize{device->NumChannelsPerOrder[order]}) + while(auto const chancount = std::size_t{device->NumChannelsPerOrder[order]}) { (parms.NFCtrlFilter.*NfcProcess[order])(samples, nfcsamples); MixSamples(nfcsamples, outBuffer.first(chancount), CurrentGains, TargetGains, counter, @@ -713,7 +721,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons /* If the static voice's current position is beyond the buffer loop end * position, disable looping. */ - if(mFlags.test(VoiceIsStatic) && bufferLoopItem) + if(mFlags.test(VoiceFlag::IsStatic) && bufferLoopItem) { if(std::cmp_greater_equal(bufPosInt, bufferListItem->mLoopEnd)) bufferLoopItem = nullptr; @@ -873,7 +881,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons std::ranges::fill(std::next(srciter), srcbuf.end(), *srciter); } - else if(mFlags.test(VoiceIsStatic)) + else if(mFlags.test(VoiceFlag::IsStatic)) { auto const uintPos = gsl::narrow_cast(std::max(intPos, 0)); auto const bufferSamples = resampleBuffer.first(srcBufferSize) @@ -881,15 +889,16 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons LoadBufferStatic(bufferListItem, bufferLoopItem, uintPos, chan, mFrameStep, bufferSamples); } - else if(mFlags.test(VoiceIsCallback)) + else if(mFlags.test(VoiceFlag::IsCallback)) { - auto const bufferOffset = usize{cbOffset}; + auto const bufferOffset = std::size_t{cbOffset}; auto const needSamples = bufferOffset + srcBufferSize - srcSampleDelay; auto const needBlocks = (needSamples + mSamplesPerBlock-1) / mSamplesPerBlock; - if(!mFlags.test(VoiceCallbackStopped) && needBlocks > mNumCallbackBlocks) + if(!mFlags.test(VoiceFlag::CallbackStopped) && needBlocks > mNumCallbackBlocks) { - auto const byteOffset = mNumCallbackBlocks * usize{mBytesPerBlock}; - auto const needBytes = (needBlocks-mNumCallbackBlocks) * usize{mBytesPerBlock}; + auto const byteOffset = mNumCallbackBlocks * std::size_t{mBytesPerBlock}; + auto const needBytes = (needBlocks-mNumCallbackBlocks) + * std::size_t{mBytesPerBlock}; auto const samples = std::visit([](auto &splspan) { return std::as_writable_bytes(splspan); }, bufferListItem->mSamples); @@ -897,16 +906,16 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons auto const gotBytes = bufferListItem->mCallback(bufferListItem->mUserData, &samples[byteOffset], gsl::narrow_cast(needBytes)); if(gotBytes < 0) - mFlags.set(VoiceCallbackStopped); + mFlags.set(VoiceFlag::CallbackStopped); else if(gsl::narrow_cast(gotBytes) < needBytes) { - mFlags.set(VoiceCallbackStopped); + mFlags.set(VoiceFlag::CallbackStopped); mNumCallbackBlocks += gsl::narrow_cast(gotBytes)/mBytesPerBlock; } else mNumCallbackBlocks = gsl::narrow_cast(needBlocks); } - auto const numSamples = usize{mNumCallbackBlocks} * mSamplesPerBlock; + auto const numSamples = std::size_t{mNumCallbackBlocks} * mSamplesPerBlock; auto const bufferSamples = resampleBuffer.first(srcBufferSize) .subspan(srcSampleDelay); LoadBufferCallback(bufferListItem, bufferOffset, numSamples, chan, mFrameStep, @@ -940,8 +949,8 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons auto const loadEnd = samplesLoaded + dstBufferSize; if(samplesToMix > samplesLoaded && samplesToMix <= loadEnd) [[likely]] { - auto const dstOffset = usize{samplesToMix - samplesLoaded}; - auto const srcOffset = usize{(dstOffset*increment + fracPos) >> MixerFracBits}; + auto const dstOffset = std::size_t{samplesToMix - samplesLoaded}; + auto const srcOffset = (dstOffset*increment + fracPos) >> MixerFracBits; std::ranges::copy(device->mResampleData | std::views::drop(srcOffset) | std::views::take(prevSamples.size()), prevSamples.begin()); } @@ -985,7 +994,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons { return samples.first(samplesToMix); }); } - if(mFlags.test(VoiceIsAmbisonic)) + if(mFlags.test(VoiceFlag::IsAmbisonic)) { auto chandata = mChans.begin(); for(auto const samplespan : mixingSamples) @@ -996,13 +1005,13 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons } } - auto const counter = mFlags.test(VoiceIsFading) ? std::min(samplesToMix, 64u) : 0u; + auto const counter = mFlags.test(VoiceFlag::IsFading) ? std::min(samplesToMix, 64u) : 0u; if(!counter) { /* No fading, just overwrite the old/current params. */ for(auto &chandata : mChans) { - if(auto &parms = chandata.mDryParams; !mFlags.test(VoiceHasHrtf)) + if(auto &parms = chandata.mDryParams; !mFlags.test(VoiceFlag::HasHrtf)) parms.Gains.Current = parms.Gains.Target; else parms.Hrtf.Old = parms.Hrtf.Target; @@ -1027,7 +1036,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons auto const samples = DoFilters(parms.LowPass, parms.HighPass, FilterBuf, samplespan, mDirect.FilterActive); - if(mFlags.test(VoiceHasHrtf)) + if(mFlags.test(VoiceFlag::HasHrtf)) { auto const targetGain = parms.Hrtf.Target.Gain * gsl::narrow_cast(vstate == Playing); @@ -1038,7 +1047,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons { auto const targetGains = (vstate == Playing) ? std::span{parms.Gains.Target} : std::span{SilentTarget}; - if(mFlags.test(VoiceHasNfc)) + if(mFlags.test(VoiceFlag::HasNfc)) DoNfcMix(samples, mDirect.Buffer, parms, targetGains, counter, outPos, device); else MixSamples(samples, mDirect.Buffer, parms.Gains.Current, targetGains, counter, @@ -1064,7 +1073,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons ++chandata; } - mFlags.set(VoiceIsFading); + mFlags.set(VoiceFlag::IsFading); /* Don't update positions and buffers if we were stopping. */ if(vstate == Stopping) [[unlikely]] @@ -1082,7 +1091,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons auto buffers_done = 0u; if(bufferListItem && bufPosInt > 0) [[likely]] { - if(mFlags.test(VoiceIsStatic)) + if(mFlags.test(VoiceFlag::IsStatic)) { if(bufferLoopItem) { @@ -1103,7 +1112,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons bufferListItem = nullptr; } } - else if(mFlags.test(VoiceIsCallback)) + else if(mFlags.test(VoiceFlag::IsCallback)) { /* Handle callback buffer source */ auto const endOffset = mCallbackBlockOffset @@ -1113,8 +1122,8 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons mCallbackBlockOffset = endOffset; else if(blocksDone < mNumCallbackBlocks) { - auto const byteOffset = blocksDone * usize{mBytesPerBlock}; - auto const byteEnd = mNumCallbackBlocks * usize{mBytesPerBlock}; + auto const byteOffset = blocksDone * std::size_t{mBytesPerBlock}; + auto const byteEnd = mNumCallbackBlocks * std::size_t{mBytesPerBlock}; auto const data = std::visit([](auto &splspan) { return std::as_writable_bytes(splspan); }, bufferListItem->mSamples); std::ranges::copy(data | std::views::take(byteEnd) | std::views::drop(byteOffset), @@ -1160,7 +1169,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons /* Send any events now, after the position/buffer info was updated. */ auto const enabledevt = context->mEnabledEvts.load(std::memory_order_acquire); - if(buffers_done > 0 && enabledevt.test(al::to_underlying(AsyncEnableBits::BufferCompleted))) + if(buffers_done > 0 && enabledevt.test(AsyncEnableBits::BufferCompleted)) { auto *ring = context->mAsyncEvents.get(); if(auto const evt_vec = ring->getWriteVector(); !evt_vec[0].empty()) @@ -1178,7 +1187,7 @@ void Voice::mix(State const vstate, ContextBase *const context, nanoseconds cons * ensures any residual noise fades to 0 amplitude. */ mPlayState.store(Stopping, std::memory_order_release); - if(enabledevt.test(al::to_underlying(AsyncEnableBits::SourceState))) + if(enabledevt.test(AsyncEnableBits::SourceState)) SendSourceStoppedEvent(context, sourceID); } } @@ -1221,17 +1230,35 @@ void Voice::prepare(DeviceBase *device) }; if(mFmtChannels == FmtSuperStereo) { - switch(UhjDecodeQuality) + if(std::holds_alternative(device->mPostProcess)) { - case UhjQualityType::IIR: - std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjStereoDecoderIIR::Tag{}); - break; - case UhjQualityType::FIR256: - std::tie(mDecoder,mDecoderPadding)=init_decoder(UhjStereoDecoder::Tag{}); - break; - case UhjQualityType::FIR512: - std::tie(mDecoder,mDecoderPadding)=init_decoder(UhjStereoDecoder::Tag{}); - break; + switch(TsmeDecodeQuality) + { + case TsmeQualityType::IIR: + std::tie(mDecoder, mDecoderPadding) = init_decoder(TsmeStereoDecoderIIR::Tag{}); + break; + case TsmeQualityType::FIR256: + std::tie(mDecoder, mDecoderPadding) = init_decoder(TsmeStereoDecoder256::Tag{}); + break; + case TsmeQualityType::FIR512: + std::tie(mDecoder, mDecoderPadding) = init_decoder(TsmeStereoDecoder512::Tag{}); + break; + } + } + else + { + switch(UhjDecodeQuality) + { + case UhjQualityType::IIR: + std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjStereoDecoderIIR::Tag{}); + break; + case UhjQualityType::FIR256: + std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjStereoDecoder256::Tag{}); + break; + case UhjQualityType::FIR512: + std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjStereoDecoder512::Tag{}); + break; + } } } else if(IsUHJ(mFmtChannels)) @@ -1242,10 +1269,10 @@ void Voice::prepare(DeviceBase *device) std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjDecoderIIR::Tag{}); break; case UhjQualityType::FIR256: - std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjDecoder::Tag{}); + std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjDecoder256::Tag{}); break; case UhjQualityType::FIR512: - std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjDecoder::Tag{}); + std::tie(mDecoder, mDecoderPadding) = init_decoder(UhjDecoder512::Tag{}); break; } } @@ -1287,7 +1314,7 @@ void Voice::prepare(DeviceBase *device) mChans[0].mAmbiLFScale = DecoderBase::sWLFScale; mChans[1].mAmbiLFScale = DecoderBase::sXYLFScale; mChans[2].mAmbiLFScale = DecoderBase::sXYLFScale; - mFlags.set(VoiceIsAmbisonic); + mFlags.set(VoiceFlag::IsAmbisonic); } /* Don't need to set the VoiceIsAmbisonic flag if the device is not higher * order than the voice. No HF scaling is necessary to mix it. @@ -1314,7 +1341,7 @@ void Voice::prepare(DeviceBase *device) SendParams{}); return true; }); - mFlags.set(VoiceIsAmbisonic); + mFlags.set(VoiceFlag::IsAmbisonic); } else { @@ -1325,6 +1352,6 @@ void Voice::prepare(DeviceBase *device) std::ranges::fill(chandata.mWetParams | std::views::take(device->NumAuxSends), SendParams{}); }); - mFlags.reset(VoiceIsAmbisonic); + mFlags.reset(VoiceFlag::IsAmbisonic); } } diff --git a/3rdparty/openal/core/voice.h b/3rdparty/openal/core/voice.h index 05173ce7d780..07ab62f04226 100644 --- a/3rdparty/openal/core/voice.h +++ b/3rdparty/openal/core/voice.h @@ -3,17 +3,17 @@ #include #include -#include #include #include #include #include #include -#include "alnumeric.h" #include "ambidefs.h" +#include "bitset.hpp" #include "bufferline.h" #include "buffer_storage.h" +#include "decoderbase.hpp" #include "devformat.h" #include "filters/biquad.h" #include "filters/nfc.h" @@ -21,7 +21,6 @@ #include "mixer/defs.h" #include "mixer/hrtfdefs.h" #include "resampler_limits.h" -#include "uhjfilter.h" #include "vector.h" struct ContextBase; @@ -162,16 +161,16 @@ struct VoicePropsItem : VoiceProps { std::atomic next{nullptr}; }; -enum : unsigned { - VoiceIsStatic, - VoiceIsCallback, - VoiceIsAmbisonic, - VoiceCallbackStopped, - VoiceIsFading, - VoiceHasHrtf, - VoiceHasNfc, +enum class VoiceFlag : u8::value_t { + IsStatic, + IsCallback, + IsAmbisonic, + CallbackStopped, + IsFading, + HasHrtf, + HasNfc, - VoiceFlagCount + MaxValue = HasNfc }; struct Voice { @@ -229,7 +228,7 @@ struct Voice { InterpState mResampleState; - std::bitset mFlags; + al::bitset mFlags; unsigned mNumCallbackBlocks{0u}; unsigned mCallbackBlockOffset{0u}; diff --git a/axmol/platform/win32/Application-win32.cpp b/axmol/platform/win32/Application-win32.cpp index 838139e44cc0..46427b7f1b73 100644 --- a/axmol/platform/win32/Application-win32.cpp +++ b/axmol/platform/win32/Application-win32.cpp @@ -35,6 +35,8 @@ THE SOFTWARE. #include "yasio/wtimer_hres.hpp" #include "ntcvt/ntcvt.hpp" +#include + /** @brief This function change the PVRFrame show/hide setting in register. @param bEnable If true show the PVRFrame window, otherwise hide. diff --git a/axmol/platform/winrt/Application-winrt.cpp b/axmol/platform/winrt/Application-winrt.cpp index 4949bf9d9bc5..61fd36a6cc30 100644 --- a/axmol/platform/winrt/Application-winrt.cpp +++ b/axmol/platform/winrt/Application-winrt.cpp @@ -39,6 +39,8 @@ THE SOFTWARE. #include #include +#include + using namespace Windows::UI::Core; using namespace Windows::Foundation;