From c20ab7d6d89681c5435c11c5d5e128c0ac367047 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 13 Nov 2023 20:13:27 -0700 Subject: [PATCH 1/5] Ensure GNUInstallDirs cache vars are included before first used --- CMakeLists.txt | 8 ++++++++ cmake/Config.cmake | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc9a268e5..27e5de5fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,6 +301,14 @@ endif() sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES ${SFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "TRUE to automatically install pkg-config files so other projects can find SFML") if(SFML_INSTALL_PKGCONFIG_FILES) + # set pkgconfig install directory + # this could be e.g. macports on mac or msys2 on windows etc. + set(SFML_PKGCONFIG_DIR "/${CMAKE_INSTALL_LIBDIR}/pkgconfig") + + if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) + set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig") + endif() + sfml_set_option(SFML_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${SFML_PKGCONFIG_DIR}" PATH "Install directory for SFML's pkg-config .pc files") foreach(sfml_module IN ITEMS all system window graphics audio network) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 48bf1d03d..d753f7ac3 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -73,14 +73,6 @@ else() return() endif() -# set pkgconfig install directory -# this could be e.g. macports on mac or msys2 on windows etc. -set(SFML_PKGCONFIG_DIR "/${CMAKE_INSTALL_LIBDIR}/pkgconfig") - -if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) - set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig") -endif() - # detect the compiler and its version # Note: The detection is order is important because: # - Visual Studio can both use MSVC and Clang From 1f345d7d25ae243f148c11ada98366f107b8c1a5 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Tue, 14 Nov 2023 10:51:27 -0700 Subject: [PATCH 2/5] Fix incorrect variable expansion --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27e5de5fe..155902c3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -411,9 +411,9 @@ else() set_target_properties(SFML PROPERTIES INSTALL_NAME_DIR "@rpath") if(NOT CMAKE_SKIP_BUILD_RPATH) if (CMAKE_VERSION VERSION_LESS 3.9) - set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) + set_target_properties(SFML PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) else() - set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE) + set_target_properties(SFML PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE) endif() endif() From c7d1112234114a80b0753962f7f69a631e9d4ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Tue, 14 Nov 2023 22:42:06 +0100 Subject: [PATCH 3/5] Abort looping in SoundStream::streamData if an OpenAL error occurs that would have caused it to never terminate. Backports #2026 and fixes #1831 for SFML 2 --- src/SFML/Audio/ALCheck.cpp | 21 +++++++++++++++++++++ src/SFML/Audio/ALCheck.hpp | 11 +++++++++++ src/SFML/Audio/SoundStream.cpp | 9 +++++++++ 3 files changed, 41 insertions(+) diff --git a/src/SFML/Audio/ALCheck.cpp b/src/SFML/Audio/ALCheck.cpp index 563a50b72..84e511bf2 100644 --- a/src/SFML/Audio/ALCheck.cpp +++ b/src/SFML/Audio/ALCheck.cpp @@ -27,6 +27,7 @@ //////////////////////////////////////////////////////////// #include #include +#include #include #if defined(__APPLE__) @@ -37,6 +38,15 @@ #endif #endif +namespace +{ + // A nested named namespace is used here to allow unity builds of SFML. + namespace AlCheckImpl + { + sf::ThreadLocalPtr lastError(AL_NO_ERROR); + } +} + namespace sf { namespace priv @@ -49,6 +59,8 @@ void alCheckError(const char* file, unsigned int line, const char* expression) if (errorCode != AL_NO_ERROR) { + AlCheckImpl::lastError = &errorCode; + std::string fileString = file; std::string error = "Unknown error"; std::string description = "No description"; @@ -101,6 +113,15 @@ void alCheckError(const char* file, unsigned int line, const char* expression) } } + +//////////////////////////////////////////////////////////// +ALenum alGetLastErrorImpl() +{ + ALenum lastError = AlCheckImpl::lastError ? *AlCheckImpl::lastError : AL_NO_ERROR; + AlCheckImpl::lastError = AL_NO_ERROR; + return lastError; +} + } // namespace priv } // namespace sf diff --git a/src/SFML/Audio/ALCheck.hpp b/src/SFML/Audio/ALCheck.hpp index 09c3fec1f..e4dd8dab8 100644 --- a/src/SFML/Audio/ALCheck.hpp +++ b/src/SFML/Audio/ALCheck.hpp @@ -55,11 +55,13 @@ namespace priv // If in debug mode, perform a test on every call // The do-while loop is needed so that alCheck can be used as a single statement in if/else branches #define alCheck(expr) do { expr; sf::priv::alCheckError(__FILE__, __LINE__, #expr); } while (false) + #define alGetLastError sf::priv::alGetLastErrorImpl #else // Else, we don't add any overhead #define alCheck(expr) (expr) + #define alGetLastError alGetError #endif @@ -74,6 +76,15 @@ namespace priv //////////////////////////////////////////////////////////// void alCheckError(const char* file, unsigned int line, const char* expression); + +//////////////////////////////////////////////////////////// +/// Get the last OpenAL error on this thread +/// +/// \return The last OpenAL error on this thread +/// +//////////////////////////////////////////////////////////// +ALenum alGetLastErrorImpl(); + } // namespace priv } // namespace sf diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 11ce46c85..f2f04eafd 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -404,6 +404,15 @@ void SoundStream::streamData() } } + // Check if any error has occurred + if (alGetLastError() != AL_NO_ERROR) + { + // Abort streaming (exit main loop) + Lock lock(m_threadMutex); + m_isStreaming = false; + break; + } + // Leave some time for the other threads if the stream is still playing if (SoundSource::getStatus() != Stopped) sleep(m_processingInterval); From c1c65b53ec2c13e25c83fed5fee9c22562736a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Thu, 16 Nov 2023 21:26:46 +0100 Subject: [PATCH 4/5] Update changelog for SFML 2.6.x --- changelog.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index ead194401..db2f95beb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,18 @@ # Changelog +## Unreleased + +### General + +- Ensure GNUInstallDirs cache vars are included before first used (#2778, #2779) +- [macOS] Fix incorrect variable expansion (#2780) + +### Audio + +**Bugfixes** + +- Abort looping in SoundStream::streamData if an OpenAL error occurs (#1831, #2781) + ## SFML 2.6.1 Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.6.1 @@ -16,16 +29,16 @@ Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.6.1 **Bugfixes** -- Fix macOS resize event bug (#2618) -- Skip ClientMessage events with other window ID unless it is for IM (#2651) +- [macOS] Fix macOS resize event bug (#2618) +- [Linux] Skip ClientMessage events with other window ID unless it is for IM (#2651) ### Graphics **Bugfixes** - Ensure OpenGL extensions are loaded before querying maximum texture size (#2603) -- Fixed RenderTexture being upside down on Android (#2730) -- Fix warnings in Linux OpenGL ES codepaths (#2747) +- [Android] Fixed RenderTexture being upside down on Android (#2730) +- [Linux] Fix warnings in Linux OpenGL ES codepaths (#2747) ### Audio From c9d065a054eb3abe1f86d91b61f2290061a74008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sun, 10 Dec 2023 15:10:07 +0100 Subject: [PATCH 5/5] Issue an error when using a MinGW UCRT version --- CMakeLists.txt | 2 ++ cmake/Config.cmake | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 155902c3b..52041b069 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,6 +195,8 @@ if(SFML_USE_SYSTEM_DEPS) endforeach() list(REMOVE_DUPLICATES CMAKE_IGNORE_PATH) +elseif(SFML_COMPILER_GCC AND GCC_COMPILER_VERSION MATCHES "ucrt") + message(FATAL_ERROR "The pre-compiled SFML dependencies for MinGW are not compatible with the UCRT. Either switch to the MSVCRT or build the dependencies yourself.") endif() # Visual C++: remove warnings regarding SL security and algorithms on pointers diff --git a/cmake/Config.cmake b/cmake/Config.cmake index d753f7ac3..51ac8b0b8 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -8,6 +8,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") # detect the architecture (note: this test won't work for cross-compilation) include(CheckTypeSize) check_type_size(void* SIZEOF_VOID_PTR) + if(${SIZEOF_VOID_PTR} STREQUAL "4") set(ARCH_32BITS 1) elseif(${SIZEOF_VOID_PTR} STREQUAL "8") @@ -18,25 +19,31 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") endif() elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(SFML_OS_UNIX 1) + if(ANDROID) set(SFML_OS_ANDROID 1) + # use the OpenGL ES implementation on Android set(OPENGL_ES 1) else() set(SFML_OS_LINUX 1) + # don't use the OpenGL ES implementation on Linux set(OPENGL_ES 0) endif() elseif(CMAKE_SYSTEM_NAME MATCHES "^k?FreeBSD$") set(SFML_OS_FREEBSD 1) + # don't use the OpenGL ES implementation on FreeBSD set(OPENGL_ES 0) elseif(CMAKE_SYSTEM_NAME MATCHES "^OpenBSD$") set(SFML_OS_OPENBSD 1) + # don't use the OpenGL ES implementation on OpenBSD set(OPENGL_ES 0) elseif(CMAKE_SYSTEM_NAME MATCHES "^NetBSD$") set(SFML_OS_NETBSD 1) + # don't use the OpenGL ES implementation on NetBSD set(OPENGL_ES 0) elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") @@ -54,6 +61,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") # detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.) EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW) STRING(REGEX REPLACE "10\\.([0-9]+).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}") + if(${MACOSX_VERSION} LESS 7) message(FATAL_ERROR "Unsupported version of OS X: ${MACOSX_VERSION_RAW}") return() @@ -64,6 +72,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android") # use the OpenGL ES implementation on Android set(OPENGL_ES 1) + # comparing CMAKE_SYSTEM_NAME with "CYGWIN" generates a false warning depending on the CMake version # let's avoid it so the actual error is more visible elseif(${CYGWIN}) @@ -99,11 +108,11 @@ if(MSVC) elseif(MSVC_VERSION LESS_EQUAL 1939) set(SFML_MSVC_VERSION 17) endif() - - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(SFML_COMPILER_CLANG_CL 1) - endif() - + + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(SFML_COMPILER_CLANG_CL 1) + endif() + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(SFML_COMPILER_CLANG 1)