mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-06 18:12:55 +02:00

I don't think we need the event thread when all we're doing is rendering to OpenAL Soft's loopback driver. Besides, the event thread was causing crashes in Emscripten builds.
144 lines
4.1 KiB
Diff
144 lines
4.1 KiB
Diff
# 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
|
|
@@ -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<AsyncEnableBits> 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<AsyncKillThread>(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<unsigned char,PATH_MAX> fileName{};
|
|
- if(configURL && CFURLGetFileSystemRepresentation(configURL, true, fileName.data(), fileName.size()))
|
|
- {
|
|
- if(std::ifstream f{reinterpret_cast<char*>(fileName.data())}; f.is_open())
|
|
- LoadConfigFromFile(f);
|
|
- }
|
|
- }
|
|
-#endif
|
|
|
|
if(auto homedir = al::getenv("HOME"))
|
|
{
|
|
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};
|