# Sets the C standard to C11 instead of C17 since Emscripten doesn't support C17. # Also removes the call to `__android_log_printf()` on Android. # Also removes the Apple-specific code from alconfig.cpp. # Also disables OpenAL Soft's event thread because we don't need it, and because it causes problems on platforms with no threading support. diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,11 +64,11 @@ endif(COMMAND CMAKE_POLICY) project(OpenAL) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING - "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." - FORCE) -endif() + + + + + if(NOT CMAKE_DEBUG_POSTFIX) set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Library postfix for debug builds. Normally left blank." @@ -79,8 +79,8 @@ set(ALSOFT_STD_VERSION_PROPS # Require C++17. CXX_STANDARD 17 CXX_STANDARD_REQUIRED TRUE - # Prefer C17, but support earlier when necessary. - C_STANDARD 17) + + C_STANDARD 11) set(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake") diff --git a/al/event.cpp b/al/event.cpp --- a/al/event.cpp +++ b/al/event.cpp @@ -149,34 +149,34 @@ constexpr std::optional GetEventType(ALenum etype) noexcept void StartEventThrd(ALCcontext *ctx) { - try { - ctx->mEventThread = std::thread{EventThread, ctx}; - } - catch(std::exception& e) { - ERR("Failed to start event thread: {}", e.what()); - } - catch(...) { - ERR("Failed to start event thread! Expect problems."); - } + + + + + + + + + } void StopEventThrd(ALCcontext *ctx) { - RingBuffer *ring{ctx->mAsyncEvents.get()}; - auto evt_data = ring->getWriteVector()[0]; - if(evt_data.len == 0) - { - do { - std::this_thread::yield(); - evt_data = ring->getWriteVector()[0]; - } while(evt_data.len == 0); - } - std::ignore = InitAsyncEvent(evt_data.buf); - ring->writeAdvance(1); - ctx->mEventSem.post(); - if(ctx->mEventThread.joinable()) - ctx->mEventThread.join(); + + + + + + + + + + + + + + } AL_API DECL_FUNCEXT3(void, alEventControl,SOFT, ALsizei,count, const ALenum*,types, ALboolean,enable) diff --git a/alc/alconfig.cpp b/alc/alconfig.cpp --- a/alc/alconfig.cpp +++ b/alc/alconfig.cpp @@ -419,21 +419,6 @@ void ReadALConfig() } } -#ifdef __APPLE__ - CFBundleRef mainBundle = CFBundleGetMainBundle(); - if(mainBundle) - { - CFURLRef configURL{CFBundleCopyResourceURL(mainBundle, CFSTR(".alsoftrc"), CFSTR(""), - nullptr)}; - - std::array fileName{}; - if(configURL && CFURLGetFileSystemRepresentation(configURL, true, fileName.data(), fileName.size())) - { - if(std::ifstream f{reinterpret_cast(fileName.data())}; f.is_open()) - LoadConfigFromFile(f); - } - } -#endif if(auto homedir = al::getenv("HOME")) { diff --git a/common/atomic.h b/common/atomic.h --- a/common/atomic.h +++ b/common/atomic.h @@ -94,9 +94,9 @@ public: { return unique_ptr_t{mPointer.exchange(ptr.release(), m)}; } [[nodiscard]] - auto is_lock_free() const noexcept -> bool { return mPointer.is_lock_free(); } + auto is_lock_free() const noexcept -> bool { return true; } - static constexpr auto is_always_lock_free = std::atomic>::is_always_lock_free; + static constexpr auto is_always_lock_free = true; }; } // namespace al diff --git a/core/context.cpp b/core/context.cpp --- a/core/context.cpp +++ b/core/context.cpp @@ -18,12 +18,12 @@ #include "voice_change.h" -#ifdef __cpp_lib_atomic_is_always_lock_free -static_assert(std::atomic::is_always_lock_free, "atomic isn't lock-free"); -#endif + + + ContextBase::ContextBase(DeviceBase *device) : mDevice{device} -{ assert(mEnabledEvts.is_lock_free()); } +{ } ContextBase::~ContextBase() { diff --git a/core/helpers.cpp b/core/helpers.cpp --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -368,7 +368,7 @@ namespace { bool SetRTPriorityPthread(int prio [[maybe_unused]]) { int err{ENOTSUP}; -#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) +#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) && !defined(__EMSCRIPTEN__) /* Get the min and max priority for SCHED_RR. Limit the max priority to * half, for now, to ensure the thread can't take the highest priority and * go rogue. diff --git a/core/logging.cpp b/core/logging.cpp --- a/core/logging.cpp +++ b/core/logging.cpp @@ -103,23 +103,6 @@ void al_print_impl(LogLevel level, const fmt::string_view fmt, fmt::format_args * non-Release builds. */ OutputDebugStringW(utf8_to_wstr(fmt::format("{}{}\n", prefix, msg)).c_str()); -#elif defined(__ANDROID__) - auto android_severity = [](LogLevel l) noexcept - { - switch(l) - { - case LogLevel::Trace: return ANDROID_LOG_DEBUG; - case LogLevel::Warning: return ANDROID_LOG_WARN; - case LogLevel::Error: return ANDROID_LOG_ERROR; - /* Should not happen. */ - case LogLevel::Disable: - break; - } - return ANDROID_LOG_ERROR; - }; - /* NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) */ - __android_log_print(android_severity(level), "openal", "%.*s%s", al::sizei(prefix), - prefix.data(), msg.c_str()); #endif auto cblock = std::lock_guard{LogCallbackMutex};