From d625c772dd4ab74548105e540040a1ed38d0c4df Mon Sep 17 00:00:00 2001 From: Reece Date: Fri, 18 Jun 2021 01:07:30 +0100 Subject: [PATCH] Amend for new AuroraRuntime version Possibly missed some merge errors --- al/event.cpp | 2 +- alc/alc.cpp | 2 + alc/alcmain.h | 2 + alc/alconfig.cpp | 11 +++--- common/almalloc.cpp | 2 +- common/threads.cpp | 17 +++++--- common/threads.h | 5 ++- config/config.h | 2 +- core/helpers.cpp | 10 +---- core/hrtf.cpp | 47 +++------------------- core/logging.cpp | 95 --------------------------------------------- 11 files changed, 35 insertions(+), 160 deletions(-) diff --git a/al/event.cpp b/al/event.cpp index fd4667f7..f44ce7bc 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -201,7 +201,7 @@ START_API_FUNC /* Wait to ensure the event handler sees the changed flags before * returning. */ - std::lock_guard{context->mEventCbLock}; + std::lock_guard annoyingWarningGoAway{context->mEventCbLock}; } } END_API_FUNC diff --git a/alc/alc.cpp b/alc/alc.cpp index e564fcab..6ee37e4f 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1078,10 +1078,12 @@ void alc_initconfig(void) CPUCapFlags = caps & capfilter; } +#if 0 if(auto priopt = ConfigValueInt(nullptr, nullptr, "rt-prio")) RTPrioLevel = *priopt; if(auto limopt = ConfigValueBool(nullptr, nullptr, "rt-time-limit")) AllowRTTimeLimit = *limopt; +#endif aluInit(); Voice::InitMixer(ConfigValueStr(nullptr, nullptr, "resampler")); diff --git a/alc/alcmain.h b/alc/alcmain.h index de9bb6b3..502f0a18 100644 --- a/alc/alcmain.h +++ b/alc/alcmain.h @@ -362,7 +362,9 @@ struct ALCdevice : public al::intrusive_ref { #define RECORD_THREAD_NAME "alsoft-record" +#if 0 extern int RTPrioLevel; +#endif void SetRTPriority(void); const ALCchar *DevFmtTypeString(DevFmtType type) noexcept; diff --git a/alc/alconfig.cpp b/alc/alconfig.cpp index a032e77a..fed9dd3f 100644 --- a/alc/alconfig.cpp +++ b/alc/alconfig.cpp @@ -279,18 +279,19 @@ void ReadALConfig() AuString configBuffer; AuString pathA; - Aurora::FS::GetSystemDomain("OpenAL", pathA); - pathA += "configuration.ini"; + Aurora::IO::FS::GetSystemDomain(pathA); + pathA += "/OpenAL/configuration.ini"; - if (!Aurora::FS::ReadString(pathA, configBuffer)) + if (!Aurora::IO::FS::ReadString(pathA, configBuffer)) { - if (!Aurora::FS::ReadString("openal.ini", configBuffer)) + if (!Aurora::IO::FS::ReadString("openal.ini", configBuffer)) { return; } } - LoadConfigFromFile(std::istringstream(configBuffer)); + std::istringstream a{ configBuffer }; + LoadConfigFromFile(a); } diff --git a/common/almalloc.cpp b/common/almalloc.cpp index fda0b071..6799f716 100644 --- a/common/almalloc.cpp +++ b/common/almalloc.cpp @@ -7,7 +7,7 @@ void *al_malloc(size_t alignment, size_t size) { - return Aurora::Memory::SAlloc(size, alignment); + return Aurora::Memory::FAlloc(size, alignment); } void *al_calloc(size_t alignment, size_t size) diff --git a/common/threads.cpp b/common/threads.cpp index e0f2578a..47b028ea 100644 --- a/common/threads.cpp +++ b/common/threads.cpp @@ -1,27 +1,33 @@ /** * Aurora Engine semaphore wrapper reimplementation for OpenAL * Copyright (C) Reece Wilson 2021 - * License: MIT + * License: Unlicense */ #include "config.h" #include "threads.h" +using namespace Aurora::Threading; + void althrd_setname(const char *name) { - // NO OP + Threads::GetThread()->SetName(name); +} + +void SetRTPriority(void) +{ + Threads::GetThread()->SetPrio(Threads::EThreadPrio::ePrioRT); } namespace al { semaphore::semaphore(unsigned int initial) { - _semaphore = Aurora::Threading::SemaphoreNew(initial); + _semaphore = Primitives::SemaphoreUnique(initial); } semaphore::~semaphore() { - Aurora::Threading::SemaphoreDestroy(_semaphore); } void semaphore::post() @@ -38,5 +44,4 @@ namespace al { return _semaphore->TryLock(); } -} - +} \ No newline at end of file diff --git a/common/threads.h b/common/threads.h index 29e47fef..67576988 100644 --- a/common/threads.h +++ b/common/threads.h @@ -1,10 +1,11 @@ /** * OpenAL semaphore wrapper reimplementation for the Aurora Engine * Copyright (C) Reece Wilson 2021 - * License: MIT + * License: Unlicense */ #pragma once +void SetRTPriority(void); void althrd_setname(const char *name); namespace al @@ -23,6 +24,6 @@ namespace al bool try_wait() noexcept; private: - Aurora::Threading::ISemaphore* _semaphore; + Aurora::Threading::Primitives::SemaphoreUnique_t _semaphore; }; } \ No newline at end of file diff --git a/config/config.h b/config/config.h index d6e2a4b7..f5d42096 100644 --- a/config/config.h +++ b/config/config.h @@ -4,4 +4,4 @@ #define FORCE_ALIGN #include -#include \ No newline at end of file +#include \ No newline at end of file diff --git a/core/helpers.cpp b/core/helpers.cpp index 3cc07ae7..8563e58d 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -1,6 +1,4 @@ - #include "config.h" - #include "helpers.h" #include @@ -22,6 +20,7 @@ #include "strutils.h" #include "vector.h" +using namespace Aurora::Console::Logging; void al_print(LogLevel level, FILE *logfile, const char *fmt, ...) { @@ -42,10 +41,5 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...) va_end(args2); va_end(args); - Aurora::Console::Logging::LogGame(str); -} - -void SetRTPriority(void) -{ - + LogGame(str); } \ No newline at end of file diff --git a/core/hrtf.cpp b/core/hrtf.cpp index c2a6a1d0..b4ecf684 100644 --- a/core/hrtf.cpp +++ b/core/hrtf.cpp @@ -1103,44 +1103,6 @@ bool checkName(const std::string &name) return std::find_if(enum_names.cbegin(), enum_names.cend(), match_name) != enum_names.cend(); } -<<<<<<< HEAD:alc/hrtf.cpp -======= -void AddFileEntry(const std::string &filename) -{ - /* Check if this file has already been enumerated. */ - auto enum_iter = std::find_if(EnumeratedHrtfs.cbegin(), EnumeratedHrtfs.cend(), - [&filename](const HrtfEntry &entry) -> bool - { return entry.mFilename == filename; }); - if(enum_iter != EnumeratedHrtfs.cend()) - { - TRACE("Skipping duplicate file entry %s\n", filename.c_str()); - return; - } - - /* TODO: Get a human-readable name from the HRTF data (possibly coming in a - * format update). */ - size_t namepos{filename.find_last_of('/')+1}; - if(!namepos) namepos = filename.find_last_of('\\')+1; - - size_t extpos{filename.find_last_of('.')}; - if(extpos <= namepos) extpos = std::string::npos; - - const std::string basename{(extpos == std::string::npos) ? - filename.substr(namepos) : filename.substr(namepos, extpos-namepos)}; - std::string newname{basename}; - int count{1}; - while(checkName(newname)) - { - newname = basename; - newname += " #"; - newname += std::to_string(++count); - } - EnumeratedHrtfs.emplace_back(HrtfEntry{newname, filename}); - const HrtfEntry &entry = EnumeratedHrtfs.back(); - - TRACE("Adding file entry \"%s\"\n", entry.mFilename.c_str()); -} - /* Unfortunate that we have to duplicate AddFileEntry to take a memory buffer * for input instead of opening the given filename. */ @@ -1190,10 +1152,11 @@ al::vector EnumerateHrtf(al::optional pathopt) if(pathopt) { AuString pathA; - Aurora::FS::GetSystemDomain("OpenAL", pathA); + Aurora::IO::FS::GetSystemDomain(pathA); + pathA += "/OpenAL/"; AuList files; - Aurora::FS::FilesInDirectory(pathA, files); + Aurora::IO::FS::FilesInDirectory(pathA, files); for (const auto& file : files) { @@ -1207,8 +1170,10 @@ al::vector EnumerateHrtf(al::optional pathopt) al::vector list; list.reserve(EnumeratedHrtfs.size()); - for(auto &entry : EnumeratedHrtfs) + for (auto& entry : EnumeratedHrtfs) + { list.emplace_back(entry.mDispName); + } return list; } diff --git a/core/logging.cpp b/core/logging.cpp index dd7f53c7..e69de29b 100644 --- a/core/logging.cpp +++ b/core/logging.cpp @@ -1,95 +0,0 @@ - -#include "config.h" - -#include "logging.h" - -#include -#include -#include - -#include "strutils.h" -#include "vector.h" - - -#ifdef _WIN32 - -#define WIN32_LEAN_AND_MEAN -#include - -void al_print(LogLevel level, FILE *logfile, const char *fmt, ...) -{ - al::vector dynmsg; - char stcmsg[256]; - char *str{stcmsg}; - - std::va_list args, args2; - va_start(args, fmt); - va_copy(args2, args); - int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)}; - if UNLIKELY(msglen >= 0 && static_cast(msglen) >= sizeof(stcmsg)) - { - dynmsg.resize(static_cast(msglen) + 1u); - str = dynmsg.data(); - msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2); - } - va_end(args2); - va_end(args); - - std::wstring wstr{utf8_to_wstr(str)}; - if(gLogLevel >= level) - { - fputws(wstr.c_str(), logfile); - fflush(logfile); - } - OutputDebugStringW(wstr.c_str()); -} - -#else - -#ifdef __ANDROID__ -#include -#endif - -void al_print(LogLevel level, FILE *logfile, const char *fmt, ...) -{ - al::vector dynmsg; - char stcmsg[256]; - char *str{stcmsg}; - - std::va_list args, args2; - va_start(args, fmt); - va_copy(args2, args); - int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)}; - if UNLIKELY(msglen >= 0 && static_cast(msglen) >= sizeof(stcmsg)) - { - dynmsg.resize(static_cast(msglen) + 1u); - str = dynmsg.data(); - msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2); - } - va_end(args2); - va_end(args); - - if(gLogLevel >= level) - { - std::fputs(str, logfile); - std::fflush(logfile); - } -#ifdef __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; - }; - __android_log_print(android_severity(level), "openal", "%s", str); -#endif -} - -#endif