forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new port FAudio, an "accuracy-focused XAudio reimplementation for open platforms". Use the PLATFORM_WIN32 cmake flag on Windows, otherwise use the sdl2 dependency. MSVC build PR is here: FNA-XNA/FAudio#333 , followup PR to fix alignment is here: FNA-XNA/FAudio#334 , MSYS2 package is here: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-faudio/PKGBUILD . Signed-off-by: Rafael Kitover <[email protected]>
- Loading branch information
Showing
7 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/src/FAudio_internal.h b/src/FAudio_internal.h | ||
index 20538b8..eaa21f7 100644 | ||
--- a/src/FAudio_internal.h | ||
+++ b/src/FAudio_internal.h | ||
@@ -211,8 +211,8 @@ extern void FAudio_Log(char const *msg); | ||
#endif | ||
|
||
/* Alignment macro for gcc/clang/msvc */ | ||
-#if defined(__GNUC__) || defined(__clang__) | ||
-#define ALIGN(type, boundary) type __attribute_((aligned(boundary))) | ||
+#if defined(__clang__) || defined(__GNUC__) | ||
+#define ALIGN(type, boundary) type __attribute__((aligned(boundary))) | ||
#elif defined(_MSC_VER) | ||
#define ALIGN(type, boundary) __declspec(align(boundary)) type | ||
#else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index a741caa..a71a494 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -104,7 +104,7 @@ add_library(FAudio | ||
) | ||
|
||
if(PLATFORM_WIN32) | ||
- target_link_libraries(FAudio PRIVATE -ldxguid -luuid -lwinmm -lole32 -ladvapi32 -luser32 -lmfplat -lmfreadwrite -lmfuuid -lpropsys) | ||
+ target_link_libraries(FAudio PRIVATE dxguid uuid winmm ole32 advapi32 user32 mfplat mfreadwrite mfuuid propsys) | ||
target_compile_definitions(FAudio PUBLIC FAUDIO_WIN32_PLATFORM) | ||
target_compile_definitions(FAudio PRIVATE HAVE_WMADEC=1) | ||
set(PLATFORM_CFLAGS "-DFAUDIO_WIN32_PLATFORM") | ||
diff --git a/src/FAudio_internal.h b/src/FAudio_internal.h | ||
index 0d35951..20538b8 100644 | ||
--- a/src/FAudio_internal.h | ||
+++ b/src/FAudio_internal.h | ||
@@ -37,8 +37,8 @@ | ||
#include <assert.h> | ||
#include <inttypes.h> | ||
|
||
-#include <windef.h> | ||
-#include <winbase.h> | ||
+#define WIN32_LEAN_AND_MEAN | ||
+#include <windows.h> | ||
|
||
#define FAudio_malloc malloc | ||
#define FAudio_realloc realloc | ||
@@ -210,6 +210,15 @@ extern void FAudio_Log(char const *msg); | ||
#define restrict | ||
#endif | ||
|
||
+/* Alignment macro for gcc/clang/msvc */ | ||
+#if defined(__GNUC__) || defined(__clang__) | ||
+#define ALIGN(type, boundary) type __attribute_((aligned(boundary))) | ||
+#elif defined(_MSC_VER) | ||
+#define ALIGN(type, boundary) __declspec(align(boundary)) type | ||
+#else | ||
+#define ALIGN(type, boundary) type | ||
+#endif | ||
+ | ||
/* Threading Types */ | ||
|
||
typedef void* FAudioThread; | ||
diff --git a/src/FAudio_internal_simd.c b/src/FAudio_internal_simd.c | ||
index b21d49a..296b2cc 100644 | ||
--- a/src/FAudio_internal_simd.c | ||
+++ b/src/FAudio_internal_simd.c | ||
@@ -903,7 +903,7 @@ void FAudio_INTERNAL_ResampleMono_NEON( | ||
cur_frac = vdupq_n_s32( | ||
(uint32_t) (cur_scalar & FIXED_FRACTION_MASK) - DOUBLE_TO_FIXED(0.5) | ||
); | ||
- int32_t __attribute__((aligned(16))) data[4] = | ||
+ ALIGN(int32_t, 16) data[4] = | ||
{ | ||
0, | ||
(uint32_t) (resampleStep & FIXED_FRACTION_MASK), | ||
@@ -1077,7 +1077,7 @@ void FAudio_INTERNAL_ResampleStereo_NEON( | ||
cur_frac = vdupq_n_s32( | ||
(uint32_t) (cur_scalar & FIXED_FRACTION_MASK) - DOUBLE_TO_FIXED(0.5) | ||
); | ||
- int32_t __attribute__((aligned(16))) data[4] = | ||
+ ALIGN(int32_t, 16) data[4] = | ||
{ | ||
0, | ||
0, | ||
diff --git a/src/FAudio_platform_win32.c b/src/FAudio_platform_win32.c | ||
index 08ad24f..cd07e5d 100644 | ||
--- a/src/FAudio_platform_win32.c | ||
+++ b/src/FAudio_platform_win32.c | ||
@@ -43,6 +43,14 @@ | ||
#include <mmdeviceapi.h> | ||
|
||
DEFINE_GUID(CLSID_CWMADecMediaObject, 0x2eeb4adf, 0x4578, 0x4d10, 0xbc, 0xa7, 0xbb, 0x95, 0x5f, 0x56, 0x32, 0x0a); | ||
+ | ||
+#ifdef _MSC_VER | ||
+DEFINE_GUID(IID_IAudioClient, 0x1CB9AD4C, 0xDBFA, 0x4c32, 0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2); | ||
+DEFINE_GUID(IID_IAudioRenderClient, 0xF294ACFC, 0x3146, 0x4483, 0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2); | ||
+DEFINE_GUID(IID_IMMDeviceEnumerator, 0xA95664D2, 0x9614, 0x4F35, 0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6); | ||
+DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E); | ||
+#endif | ||
+ | ||
DEFINE_MEDIATYPE_GUID(MFAudioFormat_XMAudio2, FAUDIO_FORMAT_XMAUDIO2); | ||
|
||
static CRITICAL_SECTION faudio_cs = { NULL, -1, 0, 0, 0, 0 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO FNA-XNA/faudio | ||
REF "${VERSION}" | ||
SHA512 c5b6a6b672095bc2a3d303cee591a8bceecef3ccba417b2023f6ae927143e0524495daea2d4cc2880b09de632a805e291db5894d7cb910535743b2025f14b712 | ||
HEAD_REF master | ||
PATCHES | ||
msvc-build.patch | ||
clang-alignment.patch | ||
) | ||
|
||
unset(options) | ||
if(VCPKG_TARGET_IS_WINDOWS) | ||
list(APPEND options -DPLATFORM_WIN32=TRUE) | ||
endif() | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS | ||
${options} | ||
) | ||
|
||
vcpkg_cmake_install() | ||
vcpkg_copy_pdbs() | ||
vcpkg_fixup_pkgconfig() | ||
|
||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share") | ||
|
||
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/FAudio) | ||
|
||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
|
||
vcpkg_install_copyright( | ||
COMMENT "FAudio is licensed under the zlib license." | ||
FILE_LIST | ||
"${SOURCE_PATH}/LICENSE" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The package faudio provides CMake targets: | ||
|
||
find_package(FAudio CONFIG REQUIRED) | ||
target_link_libraries(main PRIVATE FAudio::FAudio) | ||
|
||
The package faudio provides pkg-config modules: | ||
|
||
# Accuracy-focused XAudio reimplementation for open platforms | ||
FAudio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "faudio", | ||
"version-string": "24.03", | ||
"description": "FAudio - accuracy-focused XAudio reimplementation for open platforms", | ||
"homepage": "https://fna-xna.github.io/", | ||
"license": "Zlib", | ||
"supports": "!uwp", | ||
"dependencies": [ | ||
{ | ||
"name": "sdl2", | ||
"platform": "!windows" | ||
}, | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"versions": [ | ||
{ | ||
"git-tree": "0067e0806a6eb19c0073da7c143d377400729816", | ||
"version-string": "24.03", | ||
"port-version": 0 | ||
} | ||
] | ||
} |