diff options
author | Deal(一线灵) <[email protected]> | 2023-05-31 15:24:11 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2023-05-31 07:24:11 +0000 |
commit | 3caadcf616074c6bedcd45e8af2854379f08e275 (patch) | |
tree | 1c82f3e74906393c1ba767c4e6c330190c308c5f /CMakeLists.txt | |
parent | cd27f8551dc593cc4fb29e1093ae45a57e6ca58e (diff) |
Improve wasapi backend UWP support (#853)
* Improve wasapi, support uwp build
* Fix compile errors
* [UWP] Support ReadALConfig from app roaming
* [UWP] Post disconnect event when default device changed
* [UWP] Fix appveyor ci
* [WIN32] Default device change notification support
* Fix warnings
* Add event to notify the app when the default device changes
- Event type: AL_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT=0x19A7
- Event callback parameters:
void _onALSoftEvent(ALenum eventType,
ALuint object, // dataFlow: 0(render), 1(capture)
ALuint param, // 0
ALsizei length, // 0
const ALchar* message, // Default device changed:<deviceId>
void* userParam);
* Fix warnings
* Fire default device changed event in mixerProc thread
* Fix compile warning
* [UWP] Improve cmake
* Revert changes
* Notify default device change by system event callback
* Revert insignificant change
* Remove duplicate call
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 84 |
1 files changed, 55 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8df4be2a..02bf81b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") FORCE) endif() endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + set(ALSOFT_UWP TRUE) endif() set(CMAKE_C_VISIBILITY_PRESET hidden) @@ -148,6 +150,8 @@ set(CPP_DEFS ) # C pre-processor, not C++ set(INC_PATHS ) set(C_FLAGS ) set(LINKER_FLAGS ) +set(LINKER_FLAGS_DEBUG ) +set(LINKER_FLAGS_RELEASE ) set(EXTRA_LIBS ) if(WIN32) @@ -1010,37 +1014,39 @@ endif() # Check Windows-only backends if(WIN32) - # Check MMSystem backend - option(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON) - option(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF) - 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) - # 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}) - endif() - - # Check DSound backend - option(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON) - option(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF) - if(ALSOFT_BACKEND_DSOUND) - check_include_file(dsound.h HAVE_DSOUND_H) - if(DXSDK_DIR) - find_path(DSOUND_INCLUDE_DIR NAMES "dsound.h" - PATHS "${DXSDK_DIR}" PATH_SUFFIXES include - DOC "The DirectSound include directory") + if (NOT ALSOFT_UWP) + # Check MMSystem backend + option(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON) + option(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF) + 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) + # 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}) endif() - 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) - if(NOT HAVE_DSOUND_H) - set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIR}) + # Check DSound backend + option(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON) + option(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF) + if(ALSOFT_BACKEND_DSOUND) + check_include_file(dsound.h HAVE_DSOUND_H) + if(DXSDK_DIR) + find_path(DSOUND_INCLUDE_DIR NAMES "dsound.h" + PATHS "${DXSDK_DIR}" PATH_SUFFIXES include + DOC "The DirectSound include directory") + endif() + 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) + + if(NOT HAVE_DSOUND_H) + set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIR}) + endif() endif() endif() endif() @@ -1054,8 +1060,19 @@ if(WIN32) set(HAVE_WASAPI 1) set(BACKENDS "${BACKENDS} WASAPI,") set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h) + if(ALSOFT_UWP) + set_source_files_properties(alc/backends/wasapi.cpp alc/alconfig.cpp PROPERTIES COMPILE_FLAGS /ZW) + endif() endif() endif() + + # Setup properly link flags for UWP + if(ALSOFT_UWP AND HAVE_WASAPI) + # Add compile and link flags required C++/CX + set(C_FLAGS "/Zc:twoPhase-" ${C_FLAGS}) + set(LINKER_FLAGS_DEBUG "/nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib ${LINKER_FLAGS_DEBUG}") + set(LINKER_FLAGS_RELEASE "/nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib ${LINKER_FLAGS_RELEASE}") + endif() endif() if(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM) message(FATAL_ERROR "Failed to enabled required WinMM backend") @@ -1399,6 +1416,15 @@ else() endif() target_link_libraries(${IMPL_TARGET} PRIVATE common ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) + if (WIN32) + set_target_properties(${IMPL_TARGET} PROPERTIES + LINK_FLAGS_DEBUG "${LINKER_FLAGS_DEBUG}" + LINK_FLAGS_RELEASE "${LINKER_FLAGS_RELEASE}" + LINK_FLAGS_MINSIZEREL "${LINKER_FLAGS_RELEASE}" + LINK_FLAGS_RELWITHDEBINFO "${LINKER_FLAGS_RELEASE}" + ) + endif() + if(NOT WIN32 AND NOT APPLE) # FIXME: This doesn't put a dependency on the version script. Changing # the version script will not cause a relink as it should. |