From d2f587ee23f3e538d6d2744b9acae2e15e047db8 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 22 Apr 2021 03:14:31 -0700 Subject: Move helpers.cpp to core --- core/helpers.cpp | 510 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 510 insertions(+) create mode 100644 core/helpers.cpp (limited to 'core/helpers.cpp') diff --git a/core/helpers.cpp b/core/helpers.cpp new file mode 100644 index 00000000..c03c3b62 --- /dev/null +++ b/core/helpers.cpp @@ -0,0 +1,510 @@ + +#include "config.h" + +#include "helpers.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "alcmain.h" +#include "almalloc.h" +#include "alfstream.h" +#include "aloptional.h" +#include "alspan.h" +#include "alstring.h" +#include "logging.h" +#include "strutils.h" +#include "vector.h" + + +/* Mixing thread piority level */ +int RTPrioLevel{1}; + +/* Allow reducing the process's RTTime limit for RTKit. */ +bool AllowRTTimeLimit{true}; + + +#ifdef _WIN32 + +#include + +const PathNamePair &GetProcBinary() +{ + static al::optional procbin; + if(procbin) return *procbin; + + auto fullpath = al::vector(256); + DWORD len; + while((len=GetModuleFileNameW(nullptr, fullpath.data(), static_cast(fullpath.size()))) == fullpath.size()) + fullpath.resize(fullpath.size() << 1); + if(len == 0) + { + ERR("Failed to get process name: error %lu\n", GetLastError()); + procbin = al::make_optional(); + return *procbin; + } + + fullpath.resize(len); + if(fullpath.back() != 0) + fullpath.push_back(0); + + auto sep = std::find(fullpath.rbegin()+1, fullpath.rend(), '\\'); + sep = std::find(fullpath.rbegin()+1, sep, '/'); + if(sep != fullpath.rend()) + { + *sep = 0; + procbin = al::make_optional(wstr_to_utf8(fullpath.data()), + wstr_to_utf8(&*sep + 1)); + } + else + procbin = al::make_optional(std::string{}, wstr_to_utf8(fullpath.data())); + + TRACE("Got binary: %s, %s\n", procbin->path.c_str(), procbin->fname.c_str()); + return *procbin; +} + +namespace { + +void DirectorySearch(const char *path, const char *ext, al::vector *const results) +{ + std::string pathstr{path}; + pathstr += "\\*"; + pathstr += ext; + TRACE("Searching %s\n", pathstr.c_str()); + + std::wstring wpath{utf8_to_wstr(pathstr.c_str())}; + WIN32_FIND_DATAW fdata; + HANDLE hdl{FindFirstFileW(wpath.c_str(), &fdata)}; + if(hdl == INVALID_HANDLE_VALUE) return; + + const auto base = results->size(); + + do { + results->emplace_back(); + std::string &str = results->back(); + str = path; + str += '\\'; + str += wstr_to_utf8(fdata.cFileName); + } while(FindNextFileW(hdl, &fdata)); + FindClose(hdl); + + const al::span newlist{results->data()+base, results->size()-base}; + std::sort(newlist.begin(), newlist.end()); + for(const auto &name : newlist) + TRACE(" got %s\n", name.c_str()); +} + +} // namespace + +al::vector SearchDataFiles(const char *ext, const char *subdir) +{ + auto is_slash = [](int c) noexcept -> int { return (c == '\\' || c == '/'); }; + + static std::mutex search_lock; + std::lock_guard _{search_lock}; + + /* If the path is absolute, use it directly. */ + al::vector results; + if(isalpha(subdir[0]) && subdir[1] == ':' && is_slash(subdir[2])) + { + std::string path{subdir}; + std::replace(path.begin(), path.end(), '/', '\\'); + DirectorySearch(path.c_str(), ext, &results); + return results; + } + if(subdir[0] == '\\' && subdir[1] == '\\' && subdir[2] == '?' && subdir[3] == '\\') + { + DirectorySearch(subdir, ext, &results); + return results; + } + + std::string path; + + /* Search the app-local directory. */ + if(auto localpath = al::getenv(L"ALSOFT_LOCAL_PATH")) + { + path = wstr_to_utf8(localpath->c_str()); + if(is_slash(path.back())) + path.pop_back(); + } + else if(WCHAR *cwdbuf{_wgetcwd(nullptr, 0)}) + { + path = wstr_to_utf8(cwdbuf); + if(is_slash(path.back())) + path.pop_back(); + free(cwdbuf); + } + else + path = "."; + std::replace(path.begin(), path.end(), '/', '\\'); + DirectorySearch(path.c_str(), ext, &results); + + /* Search the local and global data dirs. */ + static const int ids[2]{ CSIDL_APPDATA, CSIDL_COMMON_APPDATA }; + for(int id : ids) + { + WCHAR buffer[MAX_PATH]; + if(SHGetSpecialFolderPathW(nullptr, buffer, id, FALSE) == FALSE) + continue; + + path = wstr_to_utf8(buffer); + if(!is_slash(path.back())) + path += '\\'; + path += subdir; + std::replace(path.begin(), path.end(), '/', '\\'); + + DirectorySearch(path.c_str(), ext, &results); + } + + return results; +} + +void SetRTPriority(void) +{ + if(RTPrioLevel > 0) + { + if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)) + ERR("Failed to set priority level for thread\n"); + } +} + +#else + +#include +#include +#include +#ifdef __FreeBSD__ +#include +#endif +#ifdef __HAIKU__ +#include +#endif +#ifdef HAVE_PROC_PIDPATH +#include +#endif +#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) +#include +#include +#endif +#ifdef HAVE_RTKIT +#include +#include + +#include "core/rtkit.h" +#ifndef RLIMIT_RTTIME +#define RLIMIT_RTTIME 15 +#endif +#endif + +const PathNamePair &GetProcBinary() +{ + static al::optional procbin; + if(procbin) return *procbin; + + al::vector pathname; +#ifdef __FreeBSD__ + size_t pathlen; + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; + if(sysctl(mib, 4, nullptr, &pathlen, nullptr, 0) == -1) + WARN("Failed to sysctl kern.proc.pathname: %s\n", strerror(errno)); + else + { + pathname.resize(pathlen + 1); + sysctl(mib, 4, pathname.data(), &pathlen, nullptr, 0); + pathname.resize(pathlen); + } +#endif +#ifdef HAVE_PROC_PIDPATH + if(pathname.empty()) + { + char procpath[PROC_PIDPATHINFO_MAXSIZE]{}; + const pid_t pid{getpid()}; + if(proc_pidpath(pid, procpath, sizeof(procpath)) < 1) + ERR("proc_pidpath(%d, ...) failed: %s\n", pid, strerror(errno)); + else + pathname.insert(pathname.end(), procpath, procpath+strlen(procpath)); + } +#endif +#ifdef __HAIKU__ + if(pathname.empty()) + { + char procpath[PATH_MAX]; + if(find_path(B_APP_IMAGE_SYMBOL, B_FIND_PATH_IMAGE_PATH, NULL, procpath, sizeof(procpath)) == B_OK) + pathname.insert(pathname.end(), procpath, procpath+strlen(procpath)); + } +#endif +#ifndef __SWITCH__ + if(pathname.empty()) + { + static const char SelfLinkNames[][32]{ + "/proc/self/exe", + "/proc/self/file", + "/proc/curproc/exe", + "/proc/curproc/file" + }; + + pathname.resize(256); + + const char *selfname{}; + ssize_t len{}; + for(const char *name : SelfLinkNames) + { + selfname = name; + len = readlink(selfname, pathname.data(), pathname.size()); + if(len >= 0 || errno != ENOENT) break; + } + + while(len > 0 && static_cast(len) == pathname.size()) + { + pathname.resize(pathname.size() << 1); + len = readlink(selfname, pathname.data(), pathname.size()); + } + if(len <= 0) + { + WARN("Failed to readlink %s: %s\n", selfname, strerror(errno)); + len = 0; + } + + pathname.resize(static_cast(len)); + } +#endif + while(!pathname.empty() && pathname.back() == 0) + pathname.pop_back(); + + auto sep = std::find(pathname.crbegin(), pathname.crend(), '/'); + if(sep != pathname.crend()) + procbin = al::make_optional(std::string(pathname.cbegin(), sep.base()-1), + std::string(sep.base(), pathname.cend())); + else + procbin = al::make_optional(std::string{}, + std::string(pathname.cbegin(), pathname.cend())); + + TRACE("Got binary: \"%s\", \"%s\"\n", procbin->path.c_str(), procbin->fname.c_str()); + return *procbin; +} + +namespace { + +void DirectorySearch(const char *path, const char *ext, al::vector *const results) +{ + TRACE("Searching %s for *%s\n", path, ext); + DIR *dir{opendir(path)}; + if(!dir) return; + + const auto base = results->size(); + const size_t extlen{strlen(ext)}; + + while(struct dirent *dirent{readdir(dir)}) + { + if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0) + continue; + + const size_t len{strlen(dirent->d_name)}; + if(len <= extlen) continue; + if(al::strcasecmp(dirent->d_name+len-extlen, ext) != 0) + continue; + + results->emplace_back(); + std::string &str = results->back(); + str = path; + if(str.back() != '/') + str.push_back('/'); + str += dirent->d_name; + } + closedir(dir); + + const al::span newlist{results->data()+base, results->size()-base}; + std::sort(newlist.begin(), newlist.end()); + for(const auto &name : newlist) + TRACE(" got %s\n", name.c_str()); +} + +} // namespace + +al::vector SearchDataFiles(const char *ext, const char *subdir) +{ + static std::mutex search_lock; + std::lock_guard _{search_lock}; + + al::vector results; + if(subdir[0] == '/') + { + DirectorySearch(subdir, ext, &results); + return results; + } + + /* Search the app-local directory. */ + if(auto localpath = al::getenv("ALSOFT_LOCAL_PATH")) + DirectorySearch(localpath->c_str(), ext, &results); + else + { + al::vector cwdbuf(256); + while(!getcwd(cwdbuf.data(), cwdbuf.size())) + { + if(errno != ERANGE) + { + cwdbuf.clear(); + break; + } + cwdbuf.resize(cwdbuf.size() << 1); + } + if(cwdbuf.empty()) + DirectorySearch(".", ext, &results); + else + { + DirectorySearch(cwdbuf.data(), ext, &results); + cwdbuf.clear(); + } + } + + // Search local data dir + if(auto datapath = al::getenv("XDG_DATA_HOME")) + { + std::string &path = *datapath; + if(path.back() != '/') + path += '/'; + path += subdir; + DirectorySearch(path.c_str(), ext, &results); + } + else if(auto homepath = al::getenv("HOME")) + { + std::string &path = *homepath; + if(path.back() == '/') + path.pop_back(); + path += "/.local/share/"; + path += subdir; + DirectorySearch(path.c_str(), ext, &results); + } + + // Search global data dirs + std::string datadirs{al::getenv("XDG_DATA_DIRS").value_or("/usr/local/share/:/usr/share/")}; + + size_t curpos{0u}; + while(curpos < datadirs.size()) + { + size_t nextpos{datadirs.find(':', curpos)}; + + std::string path{(nextpos != std::string::npos) ? + datadirs.substr(curpos, nextpos++ - curpos) : datadirs.substr(curpos)}; + curpos = nextpos; + + if(path.empty()) continue; + if(path.back() != '/') + path += '/'; + path += subdir; + + DirectorySearch(path.c_str(), ext, &results); + } + + return results; +} + +void SetRTPriority() +{ + if(RTPrioLevel <= 0) + return; + + int err{-ENOTSUP}; +#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) + struct sched_param param{}; + /* Use the minimum real-time priority possible for now (on Linux this + * should be 1 for SCHED_RR). + */ + param.sched_priority = sched_get_priority_min(SCHED_RR); +#ifdef SCHED_RESET_ON_FORK + err = pthread_setschedparam(pthread_self(), SCHED_RR|SCHED_RESET_ON_FORK, ¶m); + if(err == EINVAL) +#endif + err = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); + if(err == 0) return; + + WARN("pthread_setschedparam failed: %s (%d)\n", std::strerror(err), err); +#endif +#ifdef HAVE_RTKIT + if(HasDBus()) + { + dbus::Error error; + if(dbus::ConnectionPtr conn{(*pdbus_bus_get)(DBUS_BUS_SYSTEM, &error.get())}) + { + using ulonglong = unsigned long long; + auto limit_rttime = [](DBusConnection *conn) -> int + { + long long maxrttime{rtkit_get_rttime_usec_max(conn)}; + if(maxrttime <= 0) return static_cast(std::abs(maxrttime)); + const ulonglong umaxtime{static_cast(maxrttime)}; + + struct rlimit rlim{}; + if(getrlimit(RLIMIT_RTTIME, &rlim) != 0) + return errno; + TRACE("RTTime max: %llu (hard: %llu, soft: %llu)\n", umaxtime, + ulonglong{rlim.rlim_max}, ulonglong{rlim.rlim_cur}); + if(rlim.rlim_max > umaxtime) + { + rlim.rlim_max = static_cast(std::min(umaxtime, + std::numeric_limits::max())); + rlim.rlim_cur = std::min(rlim.rlim_cur, rlim.rlim_max); + if(setrlimit(RLIMIT_RTTIME, &rlim) != 0) + return errno; + } + return 0; + }; + + /* Don't stupidly exit if the connection dies while doing this. */ + (*pdbus_connection_set_exit_on_disconnect)(conn.get(), false); + + int nicemin{}; + err = rtkit_get_min_nice_level(conn.get(), &nicemin); + if(err == -ENOENT) + { + err = std::abs(err); + ERR("Could not query RTKit: %s (%d)\n", std::strerror(err), err); + return; + } + int rtmax{rtkit_get_max_realtime_priority(conn.get())}; + TRACE("Maximum real-time priority: %d, minimum niceness: %d\n", rtmax, nicemin); + + err = EINVAL; + if(rtmax > 0) + { + if(AllowRTTimeLimit) + { + err = limit_rttime(conn.get()); + if(err != 0) + WARN("Failed to set RLIMIT_RTTIME for RTKit: %s (%d)\n", + std::strerror(err), err); + } + + /* Use half the maximum real-time priority allowed. */ + TRACE("Making real-time with priority %d\n", (rtmax+1)/2); + err = rtkit_make_realtime(conn.get(), 0, (rtmax+1)/2); + if(err == 0) return; + + err = std::abs(err); + WARN("Failed to set real-time priority: %s (%d)\n", std::strerror(err), err); + } + if(nicemin < 0) + { + TRACE("Making high priority with niceness %d\n", nicemin); + err = rtkit_make_high_priority(conn.get(), 0, nicemin); + if(err == 0) return; + + err = std::abs(err); + WARN("Failed to set high priority: %s (%d)\n", std::strerror(err), err); + } + } + else + WARN("D-Bus connection failed with %s: %s\n", error->name, error->message); + } + else + WARN("D-Bus not available\n"); +#endif + ERR("Could not set elevated priority: %s (%d)\n", std::strerror(err), err); +} + +#endif -- cgit v1.2.3 From 6ae12d0b8543934a320887729f9e82aa1a56865b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 22 Apr 2021 10:13:09 -0700 Subject: Avoid over-long lines --- core/helpers.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'core/helpers.cpp') diff --git a/core/helpers.cpp b/core/helpers.cpp index c03c3b62..a2f1a6c9 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -40,9 +40,12 @@ const PathNamePair &GetProcBinary() if(procbin) return *procbin; auto fullpath = al::vector(256); - DWORD len; - while((len=GetModuleFileNameW(nullptr, fullpath.data(), static_cast(fullpath.size()))) == fullpath.size()) + DWORD len{GetModuleFileNameW(nullptr, fullpath.data(), static_cast(fullpath.size()))}; + while(len == fullpath.size()) + { fullpath.resize(fullpath.size() << 1); + len = GetModuleFileNameW(nullptr, fullpath.data(), static_cast(fullpath.size())); + } if(len == 0) { ERR("Failed to get process name: error %lu\n", GetLastError()); -- cgit v1.2.3 From 061148072f6bbcda20d57a4512e414c833129479 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 27 Apr 2021 16:04:54 -0700 Subject: Update include headers Don't add alc/ to the include paths. --- CMakeLists.txt | 1 - al/auxeffectslot.cpp | 8 ++++---- al/auxeffectslot.h | 6 +++--- al/buffer.cpp | 6 +++--- al/buffer.h | 2 +- al/effect.cpp | 6 +++--- al/effects/autowah.cpp | 2 +- al/effects/chorus.cpp | 2 +- al/effects/compressor.cpp | 2 +- al/effects/convolution.cpp | 4 ++-- al/effects/dedicated.cpp | 4 ++-- al/effects/distortion.cpp | 2 +- al/effects/echo.cpp | 2 +- al/effects/equalizer.cpp | 2 +- al/effects/fshifter.cpp | 2 +- al/effects/modulator.cpp | 2 +- al/effects/null.cpp | 2 +- al/effects/pshifter.cpp | 2 +- al/effects/reverb.cpp | 2 +- al/effects/vmorpher.cpp | 2 +- al/error.cpp | 2 +- al/event.cpp | 6 +++--- al/extension.cpp | 2 +- al/filter.cpp | 4 ++-- al/listener.cpp | 2 +- al/source.cpp | 10 +++++----- al/source.h | 4 ++-- al/state.cpp | 8 ++++---- alc/backends/alsa.cpp | 7 +++---- alc/backends/alsa.h | 2 +- alc/backends/coreaudio.cpp | 13 ++++++------- alc/backends/coreaudio.h | 2 +- alc/backends/dsound.cpp | 8 ++++---- alc/backends/dsound.h | 2 +- alc/backends/jack.cpp | 8 ++++---- alc/backends/jack.h | 2 +- alc/backends/loopback.cpp | 9 ++++----- alc/backends/loopback.h | 2 +- alc/backends/null.cpp | 5 ++--- alc/backends/null.h | 2 +- alc/backends/oboe.h | 2 +- alc/backends/opensl.cpp | 6 +++--- alc/backends/opensl.h | 2 +- alc/backends/oss.cpp | 7 +++---- alc/backends/oss.h | 2 +- alc/backends/portaudio.cpp | 8 ++++---- alc/backends/portaudio.h | 2 +- alc/backends/pulseaudio.cpp | 4 ++-- alc/backends/pulseaudio.h | 2 +- alc/backends/sndio.cpp | 6 +++--- alc/backends/sndio.h | 2 +- alc/backends/wasapi.cpp | 6 +++--- alc/backends/wasapi.h | 2 +- alc/backends/wave.cpp | 7 +++---- alc/backends/wave.h | 2 +- alc/backends/winmm.cpp | 6 +++--- alc/backends/winmm.h | 2 +- alc/effects/autowah.cpp | 4 ++-- alc/effects/base.h | 9 ++++++--- alc/effects/chorus.cpp | 4 ++-- alc/effects/compressor.cpp | 4 ++-- alc/effects/convolution.cpp | 4 ++-- alc/effects/dedicated.cpp | 4 ++-- alc/effects/distortion.cpp | 4 ++-- alc/effects/echo.cpp | 4 ++-- alc/effects/equalizer.cpp | 4 ++-- alc/effects/fshifter.cpp | 4 ++-- alc/effects/modulator.cpp | 4 ++-- alc/effects/null.cpp | 2 +- alc/effects/pshifter.cpp | 4 ++-- alc/effects/reverb.cpp | 4 ++-- alc/effects/vmorpher.cpp | 4 ++-- alc/effectslot.h | 5 ++--- core/helpers.cpp | 5 +++-- 74 files changed, 149 insertions(+), 153 deletions(-) (limited to 'core/helpers.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index 11c3975b..8b286781 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1345,7 +1345,6 @@ target_include_directories(${IMPL_TARGET} ${INC_PATHS} ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR} - ${OpenAL_SOURCE_DIR}/alc ${OpenAL_SOURCE_DIR}/common ) diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 3ee0a46e..eee274b1 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -36,18 +36,18 @@ #include "AL/efx.h" #include "albit.h" -#include "alcmain.h" -#include "alcontext.h" +#include "alc/alcmain.h" +#include "alc/alcontext.h" +#include "alc/alu.h" +#include "alc/inprogext.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" -#include "alu.h" #include "buffer.h" #include "core/except.h" #include "core/fpu_ctrl.h" #include "core/logging.h" #include "effect.h" -#include "inprogext.h" #include "opthelpers.h" diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index 8d7e396b..ca73c757 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -8,11 +8,11 @@ #include "AL/alc.h" #include "AL/efx.h" -#include "alcmain.h" +#include "alc/alcmain.h" +#include "alc/effectslot.h" +#include "alc/effects/base.h" #include "almalloc.h" #include "atomic.h" -#include "effectslot.h" -#include "effects/base.h" #include "intrusive_ptr.h" #include "vector.h" diff --git a/al/buffer.cpp b/al/buffer.cpp index 21f46fc8..aaffddf1 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -43,8 +43,9 @@ #include "albit.h" #include "albyte.h" -#include "alcmain.h" -#include "alcontext.h" +#include "alc/alcmain.h" +#include "alc/alcontext.h" +#include "alc/inprogext.h" #include "almalloc.h" #include "alnumeric.h" #include "aloptional.h" @@ -52,7 +53,6 @@ #include "core/except.h" #include "core/logging.h" #include "core/voice.h" -#include "inprogext.h" #include "opthelpers.h" diff --git a/al/buffer.h b/al/buffer.h index fe37b0af..a78c65c6 100644 --- a/al/buffer.h +++ b/al/buffer.h @@ -6,10 +6,10 @@ #include "AL/al.h" #include "albyte.h" +#include "alc/inprogext.h" #include "almalloc.h" #include "atomic.h" #include "core/buffer_storage.h" -#include "inprogext.h" #include "vector.h" diff --git a/al/effect.cpp b/al/effect.cpp index 645e41df..2c39394f 100644 --- a/al/effect.cpp +++ b/al/effect.cpp @@ -39,14 +39,14 @@ #include "AL/efx.h" #include "albit.h" -#include "alcmain.h" -#include "alcontext.h" +#include "alc/alcmain.h" +#include "alc/alcontext.h" +#include "alc/effects/base.h" #include "almalloc.h" #include "alnumeric.h" #include "alstring.h" #include "core/except.h" #include "core/logging.h" -#include "effects/base.h" #include "opthelpers.h" #include "vector.h" diff --git a/al/effects/autowah.cpp b/al/effects/autowah.cpp index 65d4b702..9abef1f7 100644 --- a/al/effects/autowah.cpp +++ b/al/effects/autowah.cpp @@ -8,7 +8,7 @@ #include "AL/efx.h" -#include "effects/base.h" +#include "alc/effects/base.h" #include "effects.h" namespace { diff --git a/al/effects/chorus.cpp b/al/effects/chorus.cpp index 60152755..704d7230 100644 --- a/al/effects/chorus.cpp +++ b/al/effects/chorus.cpp @@ -4,10 +4,10 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "aloptional.h" #include "core/logging.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/compressor.cpp b/al/effects/compressor.cpp index 94e07431..f5db2a6f 100644 --- a/al/effects/compressor.cpp +++ b/al/effects/compressor.cpp @@ -4,8 +4,8 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/convolution.cpp b/al/effects/convolution.cpp index 4d87b1c4..8e850fd3 100644 --- a/al/effects/convolution.cpp +++ b/al/effects/convolution.cpp @@ -2,10 +2,10 @@ #include "config.h" #include "AL/al.h" -#include "inprogext.h" +#include "alc/inprogext.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/dedicated.cpp b/al/effects/dedicated.cpp index 334d9e56..db57003c 100644 --- a/al/effects/dedicated.cpp +++ b/al/effects/dedicated.cpp @@ -4,10 +4,10 @@ #include #include "AL/al.h" -#include "AL/efx.h" +#include "AL/alext.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/distortion.cpp b/al/effects/distortion.cpp index 8961a4d9..f5d64a9a 100644 --- a/al/effects/distortion.cpp +++ b/al/effects/distortion.cpp @@ -4,8 +4,8 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/echo.cpp b/al/effects/echo.cpp index 79a60521..65f691c6 100644 --- a/al/effects/echo.cpp +++ b/al/effects/echo.cpp @@ -4,8 +4,8 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/equalizer.cpp b/al/effects/equalizer.cpp index 3a7c0a8f..3c039688 100644 --- a/al/effects/equalizer.cpp +++ b/al/effects/equalizer.cpp @@ -4,8 +4,8 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/fshifter.cpp b/al/effects/fshifter.cpp index 444b0260..63621aa6 100644 --- a/al/effects/fshifter.cpp +++ b/al/effects/fshifter.cpp @@ -4,9 +4,9 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "aloptional.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/modulator.cpp b/al/effects/modulator.cpp index 89dcc209..4c4ee485 100644 --- a/al/effects/modulator.cpp +++ b/al/effects/modulator.cpp @@ -4,9 +4,9 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "aloptional.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/null.cpp b/al/effects/null.cpp index 0ac5278f..516446db 100644 --- a/al/effects/null.cpp +++ b/al/effects/null.cpp @@ -4,8 +4,8 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/pshifter.cpp b/al/effects/pshifter.cpp index e6b0b3b0..56059a3c 100644 --- a/al/effects/pshifter.cpp +++ b/al/effects/pshifter.cpp @@ -4,8 +4,8 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/reverb.cpp b/al/effects/reverb.cpp index caa0c81e..3f234b93 100644 --- a/al/effects/reverb.cpp +++ b/al/effects/reverb.cpp @@ -6,8 +6,8 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp index 03eb2c62..076776a9 100644 --- a/al/effects/vmorpher.cpp +++ b/al/effects/vmorpher.cpp @@ -4,9 +4,9 @@ #include "AL/al.h" #include "AL/efx.h" +#include "alc/effects/base.h" #include "aloptional.h" #include "effects.h" -#include "effects/base.h" namespace { diff --git a/al/error.cpp b/al/error.cpp index 444b55aa..b6489a86 100644 --- a/al/error.cpp +++ b/al/error.cpp @@ -35,7 +35,7 @@ #include "AL/al.h" #include "AL/alc.h" -#include "alcontext.h" +#include "alc/alcontext.h" #include "almalloc.h" #include "core/except.h" #include "core/logging.h" diff --git a/al/event.cpp b/al/event.cpp index 843a90e1..5b6c1976 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -18,14 +18,14 @@ #include "AL/alc.h" #include "albyte.h" -#include "alcontext.h" +#include "alc/alcontext.h" +#include "alc/effects/base.h" +#include "alc/inprogext.h" #include "almalloc.h" #include "core/async_event.h" #include "core/except.h" #include "core/logging.h" #include "core/voice_change.h" -#include "effects/base.h" -#include "inprogext.h" #include "opthelpers.h" #include "ringbuffer.h" #include "threads.h" diff --git a/al/extension.cpp b/al/extension.cpp index 7346a5c6..bd903a6f 100644 --- a/al/extension.cpp +++ b/al/extension.cpp @@ -27,7 +27,7 @@ #include "AL/al.h" #include "AL/alc.h" -#include "alcontext.h" +#include "alc/alcontext.h" #include "alstring.h" #include "core/except.h" #include "opthelpers.h" diff --git a/al/filter.cpp b/al/filter.cpp index c3391193..09249c81 100644 --- a/al/filter.cpp +++ b/al/filter.cpp @@ -37,8 +37,8 @@ #include "AL/efx.h" #include "albit.h" -#include "alcmain.h" -#include "alcontext.h" +#include "alc/alcmain.h" +#include "alc/alcontext.h" #include "almalloc.h" #include "alnumeric.h" #include "core/except.h" diff --git a/al/listener.cpp b/al/listener.cpp index edc1ed06..00626a20 100644 --- a/al/listener.cpp +++ b/al/listener.cpp @@ -29,7 +29,7 @@ #include "AL/alc.h" #include "AL/efx.h" -#include "alcontext.h" +#include "alc/alcontext.h" #include "almalloc.h" #include "atomic.h" #include "core/except.h" diff --git a/al/source.cpp b/al/source.cpp index ca234a05..25d84f9f 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -46,16 +46,17 @@ #include "AL/efx.h" #include "albit.h" -#include "alcmain.h" -#include "alcontext.h" +#include "alc/alcmain.h" +#include "alc/alcontext.h" +#include "alc/alu.h" +#include "alc/backends/base.h" +#include "alc/inprogext.h" #include "almalloc.h" #include "alnumeric.h" #include "aloptional.h" #include "alspan.h" -#include "alu.h" #include "atomic.h" #include "auxeffectslot.h" -#include "backends/base.h" #include "buffer.h" #include "core/ambidefs.h" #include "core/bformatdec.h" @@ -66,7 +67,6 @@ #include "core/voice_change.h" #include "event.h" #include "filter.h" -#include "inprogext.h" #include "math_defs.h" #include "opthelpers.h" #include "ringbuffer.h" diff --git a/al/source.h b/al/source.h index 2063068a..dd3f56a7 100644 --- a/al/source.h +++ b/al/source.h @@ -11,11 +11,11 @@ #include "AL/al.h" #include "AL/alc.h" -#include "alcontext.h" +#include "alc/alcontext.h" +#include "alc/alu.h" #include "aldeque.h" #include "almalloc.h" #include "alnumeric.h" -#include "alu.h" #include "atomic.h" #include "core/voice.h" #include "math_defs.h" diff --git a/al/state.cpp b/al/state.cpp index 950d64fc..b0b05972 100644 --- a/al/state.cpp +++ b/al/state.cpp @@ -32,17 +32,17 @@ #include "AL/alc.h" #include "AL/alext.h" -#include "alcmain.h" -#include "alcontext.h" +#include "alc/alcmain.h" +#include "alc/alcontext.h" +#include "alc/alu.h" +#include "alc/inprogext.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" -#include "alu.h" #include "atomic.h" #include "core/except.h" #include "core/voice.h" #include "event.h" -#include "inprogext.h" #include "opthelpers.h" #include "strutils.h" diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index a6c7e178..f6f318eb 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/alsa.h" +#include "alsa.h" #include #include @@ -36,12 +36,11 @@ #include #include "albyte.h" -#include "alcmain.h" -#include "alconfig.h" +#include "alc/alconfig.h" #include "almalloc.h" #include "alnumeric.h" #include "aloptional.h" -#include "alu.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "dynload.h" diff --git a/alc/backends/alsa.h b/alc/backends/alsa.h index 1a28e6b9..b256dcf5 100644 --- a/alc/backends/alsa.h +++ b/alc/backends/alsa.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_ALSA_H #define BACKENDS_ALSA_H -#include "backends/base.h" +#include "base.h" struct AlsaBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp index 45c814bf..81ce32bc 100644 --- a/alc/backends/coreaudio.cpp +++ b/alc/backends/coreaudio.cpp @@ -20,23 +20,22 @@ #include "config.h" -#include "backends/coreaudio.h" +#include "coreaudio.h" -#include +#include #include #include #include +#include #include -#include "alcmain.h" -#include "alu.h" -#include "ringbuffer.h" +#include "alnumeric.h" #include "core/converter.h" +#include "core/device.h" #include "core/logging.h" -#include "backends/base.h" +#include "ringbuffer.h" -#include #include #include diff --git a/alc/backends/coreaudio.h b/alc/backends/coreaudio.h index 19e50eab..1252edde 100644 --- a/alc/backends/coreaudio.h +++ b/alc/backends/coreaudio.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_COREAUDIO_H #define BACKENDS_COREAUDIO_H -#include "backends/base.h" +#include "base.h" struct CoreAudioBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp index 928ff507..401f8165 100644 --- a/alc/backends/dsound.cpp +++ b/alc/backends/dsound.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/dsound.h" +#include "dsound.h" #define WIN32_LEAN_AND_MEAN #include @@ -44,9 +44,9 @@ #include #include -#include "alcmain.h" -#include "alu.h" +#include "alnumeric.h" #include "comptr.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "dynload.h" @@ -175,7 +175,7 @@ struct DSoundPlayback final : public BackendBase { int mixerProc(); - void open(const ALCchar *name) override; + void open(const char *name) override; bool reset() override; void start() override; void stop() override; diff --git a/alc/backends/dsound.h b/alc/backends/dsound.h index 3b5b344b..787f227a 100644 --- a/alc/backends/dsound.h +++ b/alc/backends/dsound.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_DSOUND_H #define BACKENDS_DSOUND_H -#include "backends/base.h" +#include "base.h" struct DSoundBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp index b7b35217..54bd19e6 100644 --- a/alc/backends/jack.cpp +++ b/alc/backends/jack.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/jack.h" +#include "jack.h" #include #include @@ -31,9 +31,9 @@ #include #include -#include "alcmain.h" -#include "alu.h" -#include "alconfig.h" +#include "alc/alconfig.h" +#include "alnumeric.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "dynload.h" diff --git a/alc/backends/jack.h b/alc/backends/jack.h index 6f81a209..b83f24dd 100644 --- a/alc/backends/jack.h +++ b/alc/backends/jack.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_JACK_H #define BACKENDS_JACK_H -#include "backends/base.h" +#include "base.h" struct JackBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/loopback.cpp b/alc/backends/loopback.cpp index bafe8cc8..bf4ab246 100644 --- a/alc/backends/loopback.cpp +++ b/alc/backends/loopback.cpp @@ -20,10 +20,9 @@ #include "config.h" -#include "backends/loopback.h" +#include "loopback.h" -#include "alcmain.h" -#include "alu.h" +#include "core/device.h" namespace { @@ -31,7 +30,7 @@ namespace { struct LoopbackBackend final : public BackendBase { LoopbackBackend(DeviceBase *device) noexcept : BackendBase{device} { } - void open(const ALCchar *name) override; + void open(const char *name) override; bool reset() override; void start() override; void stop() override; @@ -40,7 +39,7 @@ struct LoopbackBackend final : public BackendBase { }; -void LoopbackBackend::open(const ALCchar *name) +void LoopbackBackend::open(const char *name) { mDevice->DeviceName = name; } diff --git a/alc/backends/loopback.h b/alc/backends/loopback.h index 1a031a1f..cb42b3c8 100644 --- a/alc/backends/loopback.h +++ b/alc/backends/loopback.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_LOOPBACK_H #define BACKENDS_LOOPBACK_H -#include "backends/base.h" +#include "base.h" struct LoopbackBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/null.cpp b/alc/backends/null.cpp index 763d4d2e..5a8fc255 100644 --- a/alc/backends/null.cpp +++ b/alc/backends/null.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/null.h" +#include "null.h" #include #include @@ -30,9 +30,8 @@ #include #include -#include "alcmain.h" +#include "core/device.h" #include "almalloc.h" -#include "alu.h" #include "core/helpers.h" #include "threads.h" diff --git a/alc/backends/null.h b/alc/backends/null.h index c9d1b3b3..7048cad6 100644 --- a/alc/backends/null.h +++ b/alc/backends/null.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_NULL_H #define BACKENDS_NULL_H -#include "backends/base.h" +#include "base.h" struct NullBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/oboe.h b/alc/backends/oboe.h index 228ec807..a39c2445 100644 --- a/alc/backends/oboe.h +++ b/alc/backends/oboe.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_OBOE_H #define BACKENDS_OBOE_H -#include "backends/base.h" +#include "base.h" struct OboeBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp index af656470..7be7f031 100644 --- a/alc/backends/opensl.cpp +++ b/alc/backends/opensl.cpp @@ -21,7 +21,7 @@ #include "config.h" -#include "backends/opensl.h" +#include "opensl.h" #include #include @@ -33,8 +33,8 @@ #include #include "albit.h" -#include "alcmain.h" -#include "alu.h" +#include "alnumeric.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "opthelpers.h" diff --git a/alc/backends/opensl.h b/alc/backends/opensl.h index 36586bbb..b8162447 100644 --- a/alc/backends/opensl.h +++ b/alc/backends/opensl.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_OSL_H #define BACKENDS_OSL_H -#include "backends/base.h" +#include "base.h" struct OSLBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp index d769a1eb..6d4fa261 100644 --- a/alc/backends/oss.cpp +++ b/alc/backends/oss.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/oss.h" +#include "oss.h" #include #include @@ -41,13 +41,12 @@ #include #include -#include "alcmain.h" -#include "alconfig.h" #include "albyte.h" +#include "alc/alconfig.h" #include "almalloc.h" #include "alnumeric.h" #include "aloptional.h" -#include "alu.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "ringbuffer.h" diff --git a/alc/backends/oss.h b/alc/backends/oss.h index 798da456..4f2c00b9 100644 --- a/alc/backends/oss.h +++ b/alc/backends/oss.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_OSS_H #define BACKENDS_OSS_H -#include "backends/base.h" +#include "base.h" struct OSSBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp index 8f41b12a..2d5cd36d 100644 --- a/alc/backends/portaudio.cpp +++ b/alc/backends/portaudio.cpp @@ -20,15 +20,15 @@ #include "config.h" -#include "backends/portaudio.h" +#include "portaudio.h" #include #include #include -#include "alcmain.h" -#include "alu.h" -#include "alconfig.h" +#include "alc/alconfig.h" +#include "alnumeric.h" +#include "core/device.h" #include "core/logging.h" #include "dynload.h" #include "ringbuffer.h" diff --git a/alc/backends/portaudio.h b/alc/backends/portaudio.h index 34bb8d1b..c35ccff2 100644 --- a/alc/backends/portaudio.h +++ b/alc/backends/portaudio.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_PORTAUDIO_H #define BACKENDS_PORTAUDIO_H -#include "backends/base.h" +#include "base.h" struct PortBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index da1ffcb0..23bcecad 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -21,7 +21,7 @@ #include "config.h" -#include "backends/pulseaudio.h" +#include "pulseaudio.h" #include #include @@ -43,7 +43,7 @@ #include #include "albyte.h" -#include "alconfig.h" +#include "alc/alconfig.h" #include "almalloc.h" #include "alnumeric.h" #include "aloptional.h" diff --git a/alc/backends/pulseaudio.h b/alc/backends/pulseaudio.h index 60ebbc36..6690fe8a 100644 --- a/alc/backends/pulseaudio.h +++ b/alc/backends/pulseaudio.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_PULSEAUDIO_H #define BACKENDS_PULSEAUDIO_H -#include "backends/base.h" +#include "base.h" class PulseBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp index c7c42210..2d8b424c 100644 --- a/alc/backends/sndio.cpp +++ b/alc/backends/sndio.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/sndio.h" +#include "sndio.h" #include #include @@ -29,8 +29,8 @@ #include #include -#include "alcmain.h" -#include "alu.h" +#include "alnumeric.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "ringbuffer.h" diff --git a/alc/backends/sndio.h b/alc/backends/sndio.h index 9b93199f..d9433191 100644 --- a/alc/backends/sndio.h +++ b/alc/backends/sndio.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_SNDIO_H #define BACKENDS_SNDIO_H -#include "backends/base.h" +#include "base.h" struct SndIOBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 114c69e0..d38fc25d 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/wasapi.h" +#include "wasapi.h" #define WIN32_LEAN_AND_MEAN #include @@ -56,10 +56,10 @@ #include #include "albit.h" -#include "alcmain.h" -#include "alu.h" +#include "alnumeric.h" #include "comptr.h" #include "core/converter.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "ringbuffer.h" diff --git a/alc/backends/wasapi.h b/alc/backends/wasapi.h index fa4b811e..bb2671ee 100644 --- a/alc/backends/wasapi.h +++ b/alc/backends/wasapi.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_WASAPI_H #define BACKENDS_WASAPI_H -#include "backends/base.h" +#include "base.h" struct WasapiBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp index 434a5fb1..259cbc62 100644 --- a/alc/backends/wave.cpp +++ b/alc/backends/wave.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/wave.h" +#include "wave.h" #include #include @@ -35,11 +35,10 @@ #include "albit.h" #include "albyte.h" -#include "alcmain.h" -#include "alconfig.h" +#include "alc/alconfig.h" #include "almalloc.h" #include "alnumeric.h" -#include "alu.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "opthelpers.h" diff --git a/alc/backends/wave.h b/alc/backends/wave.h index 926e2198..e768d336 100644 --- a/alc/backends/wave.h +++ b/alc/backends/wave.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_WAVE_H #define BACKENDS_WAVE_H -#include "backends/base.h" +#include "base.h" struct WaveBackendFactory final : public BackendFactory { public: diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp index c346a828..42aee313 100644 --- a/alc/backends/winmm.cpp +++ b/alc/backends/winmm.cpp @@ -20,7 +20,7 @@ #include "config.h" -#include "backends/winmm.h" +#include "winmm.h" #include #include @@ -38,8 +38,8 @@ #include #include -#include "alcmain.h" -#include "alu.h" +#include "alnumeric.h" +#include "core/device.h" #include "core/helpers.h" #include "core/logging.h" #include "ringbuffer.h" diff --git a/alc/backends/winmm.h b/alc/backends/winmm.h index a376b8a4..45a706aa 100644 --- a/alc/backends/winmm.h +++ b/alc/backends/winmm.h @@ -1,7 +1,7 @@ #ifndef BACKENDS_WINMM_H #define BACKENDS_WINMM_H -#include "backends/base.h" +#include "base.h" struct WinMMBackendFactory final : public BackendFactory { public: diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp index 6016b8ab..9c2ec335 100644 --- a/alc/effects/autowah.cpp +++ b/alc/effects/autowah.cpp @@ -26,6 +26,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -35,8 +37,6 @@ #include "core/devformat.h" #include "core/device.h" #include "core/mixer.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" diff --git a/alc/effects/base.h b/alc/effects/base.h index 6c31ae0c..1fb339aa 100644 --- a/alc/effects/base.h +++ b/alc/effects/base.h @@ -1,18 +1,21 @@ #ifndef EFFECTS_BASE_H #define EFFECTS_BASE_H -#include +#include #include "albyte.h" -#include "alcmain.h" #include "almalloc.h" #include "alspan.h" #include "atomic.h" +#include "core/bufferline.h" #include "intrusive_ptr.h" +struct BufferStorage; struct ContextBase; +struct DeviceBase; struct EffectSlot; -struct BufferStorage; +struct MixParams; +struct RealMixParams; /** Target gain for the reverb decay feedback reaching the decay time. */ diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 50cf1e40..3a1b9ae4 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -26,6 +26,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -36,8 +38,6 @@ #include "core/mixer.h" #include "core/mixer/defs.h" #include "core/resampler_limits.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" #include "opthelpers.h" diff --git a/alc/effects/compressor.cpp b/alc/effects/compressor.cpp index 9a6f9b5d..030bfe08 100644 --- a/alc/effects/compressor.cpp +++ b/alc/effects/compressor.cpp @@ -37,6 +37,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -46,8 +48,6 @@ #include "core/device.h" #include "core/mixer.h" #include "core/mixer/defs.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" struct ContextBase; diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index fd68ea41..ca5a7321 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -19,9 +19,11 @@ #include "albyte.h" #include "alcomplex.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" +#include "base.h" #include "core/ambidefs.h" #include "core/bufferline.h" #include "core/buffer_storage.h" @@ -31,8 +33,6 @@ #include "core/filters/splitter.h" #include "core/fmt_traits.h" #include "core/mixer.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" #include "polyphase_resampler.h" diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp index 6afd7baa..e7ea89e0 100644 --- a/alc/effects/dedicated.cpp +++ b/alc/effects/dedicated.cpp @@ -25,14 +25,14 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alspan.h" #include "core/bufferline.h" #include "core/devformat.h" #include "core/device.h" #include "core/mixer.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" struct ContextBase; diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp index a3f287c0..26b4df8e 100644 --- a/alc/effects/distortion.cpp +++ b/alc/effects/distortion.cpp @@ -25,6 +25,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -35,8 +37,6 @@ #include "core/filters/biquad.h" #include "core/mixer.h" #include "core/mixer/defs.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp index 4fccabfe..4cdef37c 100644 --- a/alc/effects/echo.cpp +++ b/alc/effects/echo.cpp @@ -26,6 +26,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -35,8 +37,6 @@ #include "core/device.h" #include "core/filters/biquad.h" #include "core/mixer.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "opthelpers.h" #include "vector.h" diff --git a/alc/effects/equalizer.cpp b/alc/effects/equalizer.cpp index aedf537e..800330a3 100644 --- a/alc/effects/equalizer.cpp +++ b/alc/effects/equalizer.cpp @@ -27,6 +27,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alspan.h" #include "core/ambidefs.h" @@ -36,8 +38,6 @@ #include "core/device.h" #include "core/filters/biquad.h" #include "core/mixer.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index e19809bb..c25aab82 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -27,6 +27,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "alcomplex.h" #include "almalloc.h" #include "alnumeric.h" @@ -37,8 +39,6 @@ #include "core/device.h" #include "core/mixer.h" #include "core/mixer/defs.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp index ded35805..a518ff63 100644 --- a/alc/effects/modulator.cpp +++ b/alc/effects/modulator.cpp @@ -25,6 +25,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -35,8 +37,6 @@ #include "core/device.h" #include "core/filters/biquad.h" #include "core/mixer.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" diff --git a/alc/effects/null.cpp b/alc/effects/null.cpp index 1413909f..cda1420e 100644 --- a/alc/effects/null.cpp +++ b/alc/effects/null.cpp @@ -5,8 +5,8 @@ #include "almalloc.h" #include "alspan.h" +#include "base.h" #include "core/bufferline.h" -#include "effects/base.h" #include "intrusive_ptr.h" struct ContextBase; diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index 5bf813e5..26115605 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -27,6 +27,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "alcomplex.h" #include "almalloc.h" #include "alnumeric.h" @@ -36,8 +38,6 @@ #include "core/device.h" #include "core/mixer.h" #include "core/mixer/defs.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 0db27210..d6f1dbbf 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -28,6 +28,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -40,8 +42,6 @@ #include "core/filters/splitter.h" #include "core/mixer.h" #include "core/mixer/defs.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" #include "opthelpers.h" diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp index c3790e30..6c419ba2 100644 --- a/alc/effects/vmorpher.cpp +++ b/alc/effects/vmorpher.cpp @@ -38,6 +38,8 @@ #include #include +#include "alc/effects/base.h" +#include "alc/effectslot.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -47,8 +49,6 @@ #include "core/devformat.h" #include "core/device.h" #include "core/mixer.h" -#include "effects/base.h" -#include "effectslot.h" #include "intrusive_ptr.h" #include "math_defs.h" diff --git a/alc/effectslot.h b/alc/effectslot.h index c1eb1cc3..cbb1a2f5 100644 --- a/alc/effectslot.h +++ b/alc/effectslot.h @@ -1,14 +1,13 @@ #ifndef EFFECTSLOT_H #define EFFECTSLOT_H -#include +#include #include "almalloc.h" -#include "alcmain.h" +#include "core/device.h" #include "effects/base.h" #include "intrusive_ptr.h" - struct EffectSlot; struct WetBuffer; diff --git a/core/helpers.cpp b/core/helpers.cpp index a2f1a6c9..94219544 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -10,9 +10,9 @@ #include #include #include +#include #include -#include "alcmain.h" #include "almalloc.h" #include "alfstream.h" #include "aloptional.h" @@ -199,7 +199,8 @@ void SetRTPriority(void) #include #include -#include "core/rtkit.h" +#include "dbus_wrap.h" +#include "rtkit.h" #ifndef RLIMIT_RTTIME #define RLIMIT_RTTIME 15 #endif -- cgit v1.2.3 From bab6e929801e5f620c624430ec1ac6213e265995 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 28 Apr 2021 09:02:37 -0700 Subject: Avoid shadowing a variable name --- core/helpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/helpers.cpp') diff --git a/core/helpers.cpp b/core/helpers.cpp index 94219544..dcb785c9 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -437,9 +437,9 @@ void SetRTPriority() if(dbus::ConnectionPtr conn{(*pdbus_bus_get)(DBUS_BUS_SYSTEM, &error.get())}) { using ulonglong = unsigned long long; - auto limit_rttime = [](DBusConnection *conn) -> int + auto limit_rttime = [](DBusConnection *c) -> int { - long long maxrttime{rtkit_get_rttime_usec_max(conn)}; + long long maxrttime{rtkit_get_rttime_usec_max(c)}; if(maxrttime <= 0) return static_cast(std::abs(maxrttime)); const ulonglong umaxtime{static_cast(maxrttime)}; -- cgit v1.2.3 From 834800c817b3a7b799fc387b51777d555494f91a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 21 Nov 2021 20:29:20 -0800 Subject: Downgrade some ERRs to WARNs --- alc/backends/alsa.cpp | 4 ++-- core/helpers.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'core/helpers.cpp') diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index 0ad84692..9c78b6c6 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -750,10 +750,10 @@ bool AlsaPlayback::reset() || !mDevice->Flags.test(FrequencyRequest)) { if(snd_pcm_hw_params_set_rate_resample(mPcmHandle, hp.get(), 0) < 0) - ERR("Failed to disable ALSA resampler\n"); + WARN("Failed to disable ALSA resampler\n"); } else if(snd_pcm_hw_params_set_rate_resample(mPcmHandle, hp.get(), 1) < 0) - ERR("Failed to enable ALSA resampler\n"); + WARN("Failed to enable ALSA resampler\n"); CHECK(snd_pcm_hw_params_set_rate_near(mPcmHandle, hp.get(), &rate, nullptr)); /* set period time (implicitly constrains period/buffer parameters) */ if((err=snd_pcm_hw_params_set_period_time_near(mPcmHandle, hp.get(), &periodLen, nullptr)) < 0) diff --git a/core/helpers.cpp b/core/helpers.cpp index dcb785c9..97e0caa0 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -508,7 +508,7 @@ void SetRTPriority() else WARN("D-Bus not available\n"); #endif - ERR("Could not set elevated priority: %s (%d)\n", std::strerror(err), err); + WARN("Could not set elevated priority: %s (%d)\n", std::strerror(err), err); } #endif -- cgit v1.2.3 From 6f60e7a452083bfd30dc9b678133bc4ef4b67c2a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 17 Jan 2022 20:12:35 -0800 Subject: Handle the rt-prio config options as the priority level --- alsoftrc.sample | 12 ++-- core/helpers.cpp | 193 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 117 insertions(+), 88 deletions(-) (limited to 'core/helpers.cpp') diff --git a/alsoftrc.sample b/alsoftrc.sample index 1664381d..e2a45579 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -183,12 +183,12 @@ #resampler = linear ## rt-prio: (global) -# Sets real-time priority for the mixing thread. Not all drivers may use this -# (eg. PortAudio) as they already control the priority of the mixing thread. -# 0 and negative values will disable it. Note that this may constitute a -# security risk since a real-time priority thread can indefinitely block -# normal-priority threads if it fails to wait. Disable this if it turns out to -# be a problem. +# Sets the real-time priority value for the mixing thread. Not all drivers may +# use this (eg. PortAudio) as those APIs already control the priority of the +# mixing thread. 0 and negative values will disable real-time priority. Note +# that this may constitute a security risk since a real-time priority thread +# can indefinitely block normal-priority threads if it fails to wait. Disable +# this if it turns out to be a problem. #rt-prio = 1 ## rt-time-limit: (global) diff --git a/core/helpers.cpp b/core/helpers.cpp index 97e0caa0..c9edb479 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -15,6 +15,7 @@ #include "almalloc.h" #include "alfstream.h" +#include "alnumeric.h" #include "aloptional.h" #include "alspan.h" #include "alstring.h" @@ -409,106 +410,134 @@ al::vector SearchDataFiles(const char *ext, const char *subdir) return results; } -void SetRTPriority() -{ - if(RTPrioLevel <= 0) - return; +namespace { - int err{-ENOTSUP}; +bool SetRTPriorityPthread(int prio) +{ + int err{ENOTSUP}; #if defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) - struct sched_param param{}; - /* Use the minimum real-time priority possible for now (on Linux this - * should be 1 for SCHED_RR). + /* 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. */ - param.sched_priority = sched_get_priority_min(SCHED_RR); + int rtmin{sched_get_priority_min(SCHED_RR)}; + int rtmax{sched_get_priority_max(SCHED_RR)}; + rtmax = (rtmax-rtmin)/2 + rtmin; + + struct sched_param param{}; + param.sched_priority = clampi(prio, rtmin, rtmax); #ifdef SCHED_RESET_ON_FORK err = pthread_setschedparam(pthread_self(), SCHED_RR|SCHED_RESET_ON_FORK, ¶m); if(err == EINVAL) #endif err = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); - if(err == 0) return; + if(err == 0) return true; +#endif WARN("pthread_setschedparam failed: %s (%d)\n", std::strerror(err), err); -#endif + return false; +} + +bool SetRTPriorityRTKit(int prio) +{ #ifdef HAVE_RTKIT - if(HasDBus()) + if(!HasDBus()) { - dbus::Error error; - if(dbus::ConnectionPtr conn{(*pdbus_bus_get)(DBUS_BUS_SYSTEM, &error.get())}) + WARN("D-Bus not available\n"); + return false; + } + dbus::Error error; + dbus::ConnectionPtr conn{(*pdbus_bus_get)(DBUS_BUS_SYSTEM, &error.get())}; + if(!conn) + { + WARN("D-Bus connection failed with %s: %s\n", error->name, error->message); + return false; + } + + /* Don't stupidly exit if the connection dies while doing this. */ + (*pdbus_connection_set_exit_on_disconnect)(conn.get(), false); + + auto limit_rttime = [](DBusConnection *c) -> int + { + using ulonglong = unsigned long long; + long long maxrttime{rtkit_get_rttime_usec_max(c)}; + if(maxrttime <= 0) return static_cast(std::abs(maxrttime)); + const ulonglong umaxtime{static_cast(maxrttime)}; + + struct rlimit rlim{}; + if(getrlimit(RLIMIT_RTTIME, &rlim) != 0) + return errno; + + TRACE("RTTime max: %llu (hard: %llu, soft: %llu)\n", umaxtime, ulonglong{rlim.rlim_max}, + ulonglong{rlim.rlim_cur}); + if(rlim.rlim_max > umaxtime) { - using ulonglong = unsigned long long; - auto limit_rttime = [](DBusConnection *c) -> int - { - long long maxrttime{rtkit_get_rttime_usec_max(c)}; - if(maxrttime <= 0) return static_cast(std::abs(maxrttime)); - const ulonglong umaxtime{static_cast(maxrttime)}; - - struct rlimit rlim{}; - if(getrlimit(RLIMIT_RTTIME, &rlim) != 0) - return errno; - TRACE("RTTime max: %llu (hard: %llu, soft: %llu)\n", umaxtime, - ulonglong{rlim.rlim_max}, ulonglong{rlim.rlim_cur}); - if(rlim.rlim_max > umaxtime) - { - rlim.rlim_max = static_cast(std::min(umaxtime, - std::numeric_limits::max())); - rlim.rlim_cur = std::min(rlim.rlim_cur, rlim.rlim_max); - if(setrlimit(RLIMIT_RTTIME, &rlim) != 0) - return errno; - } - return 0; - }; - - /* Don't stupidly exit if the connection dies while doing this. */ - (*pdbus_connection_set_exit_on_disconnect)(conn.get(), false); - - int nicemin{}; - err = rtkit_get_min_nice_level(conn.get(), &nicemin); - if(err == -ENOENT) - { - err = std::abs(err); - ERR("Could not query RTKit: %s (%d)\n", std::strerror(err), err); - return; - } - int rtmax{rtkit_get_max_realtime_priority(conn.get())}; - TRACE("Maximum real-time priority: %d, minimum niceness: %d\n", rtmax, nicemin); + rlim.rlim_max = static_cast(umaxtime); + rlim.rlim_cur = std::min(rlim.rlim_cur, rlim.rlim_max); + if(setrlimit(RLIMIT_RTTIME, &rlim) != 0) + return errno; + } + return 0; + }; - err = EINVAL; - if(rtmax > 0) - { - if(AllowRTTimeLimit) - { - err = limit_rttime(conn.get()); - if(err != 0) - WARN("Failed to set RLIMIT_RTTIME for RTKit: %s (%d)\n", - std::strerror(err), err); - } - - /* Use half the maximum real-time priority allowed. */ - TRACE("Making real-time with priority %d\n", (rtmax+1)/2); - err = rtkit_make_realtime(conn.get(), 0, (rtmax+1)/2); - if(err == 0) return; - - err = std::abs(err); - WARN("Failed to set real-time priority: %s (%d)\n", std::strerror(err), err); - } - if(nicemin < 0) - { - TRACE("Making high priority with niceness %d\n", nicemin); - err = rtkit_make_high_priority(conn.get(), 0, nicemin); - if(err == 0) return; + int nicemin{}; + int err{rtkit_get_min_nice_level(conn.get(), &nicemin)}; + if(err == -ENOENT) + { + err = std::abs(err); + ERR("Could not query RTKit: %s (%d)\n", std::strerror(err), err); + return false; + } + int rtmax{rtkit_get_max_realtime_priority(conn.get())}; + TRACE("Maximum real-time priority: %d, minimum niceness: %d\n", rtmax, nicemin); - err = std::abs(err); - WARN("Failed to set high priority: %s (%d)\n", std::strerror(err), err); - } + if(rtmax > 0) + { + if(AllowRTTimeLimit) + { + err = limit_rttime(conn.get()); + if(err != 0) + WARN("Failed to set RLIMIT_RTTIME for RTKit: %s (%d)\n", + std::strerror(err), err); } - else - WARN("D-Bus connection failed with %s: %s\n", error->name, error->message); + + /* Limit the maximum real-time priority to half. */ + rtmax = (rtmax+1)/2; + prio = clampi(prio, 1, rtmax); + + TRACE("Making real-time with priority %d (max: %d)\n", prio, rtmax); + err = rtkit_make_realtime(conn.get(), 0, prio); + if(err == 0) return true; + + err = std::abs(err); + WARN("Failed to set real-time priority: %s (%d)\n", std::strerror(err), err); } - else - WARN("D-Bus not available\n"); + if(nicemin < 0) + { + TRACE("Making high priority with niceness %d\n", nicemin); + err = rtkit_make_high_priority(conn.get(), 0, nicemin); + if(err == 0) return true; + + err = std::abs(err); + WARN("Failed to set high priority: %s (%d)\n", std::strerror(err), err); + } +#else + WARN("D-Bus not supported\n"); #endif - WARN("Could not set elevated priority: %s (%d)\n", std::strerror(err), err); + return false; +} + +} // namespace + +void SetRTPriority() +{ + if(RTPrioLevel <= 0) + return; + + if(SetRTPriorityPthread(RTPrioLevel)) + return; + if(SetRTPriorityRTKit(RTPrioLevel)) + return; } #endif -- cgit v1.2.3 From 5306c9d42460001670a90a8f091cef47c0aede2c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 18 Jan 2022 14:32:15 -0800 Subject: Set niceness as a fallback only on Linux If pthread_setschedparam and rtkit_make_realtime both fail, lowering niceness can also work to boost priority. However, this only works on Linux and other OSs that implement a per-thread niceness (POSIX standard has it per-process, which isn't desirable behavior here). --- core/helpers.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core/helpers.cpp') diff --git a/core/helpers.cpp b/core/helpers.cpp index c9edb479..3cc7bf8f 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -512,6 +512,12 @@ bool SetRTPriorityRTKit(int prio) err = std::abs(err); WARN("Failed to set real-time priority: %s (%d)\n", std::strerror(err), err); } + /* Don't try to set the niceness for non-Linux systems. Standard POSIX has + * niceness as a per-process attribute, while the intent here is for the + * audio processing thread only to get a priority boost. Currently only + * Linux is known to have per-thread niceness. + */ +#ifdef __linux__ if(nicemin < 0) { TRACE("Making high priority with niceness %d\n", nicemin); @@ -521,7 +527,10 @@ bool SetRTPriorityRTKit(int prio) err = std::abs(err); WARN("Failed to set high priority: %s (%d)\n", std::strerror(err), err); } +#endif /* __linux__ */ + #else + WARN("D-Bus not supported\n"); #endif return false; -- cgit v1.2.3 From 388f10319b91b043c9a17833eb437bde33e3fa2e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 18 Jan 2022 15:55:51 -0800 Subject: Handle _gettid on FreeBSD And simplify handling D-Bus/RTKit interfaces --- core/dbus_wrap.cpp | 2 +- core/dbus_wrap.h | 36 ++++++++++++------ core/helpers.cpp | 4 +- core/rtkit.cpp | 108 +++++++++++++++++++++++++---------------------------- core/rtkit.h | 9 ----- 5 files changed, 77 insertions(+), 82 deletions(-) (limited to 'core/helpers.cpp') diff --git a/core/dbus_wrap.cpp b/core/dbus_wrap.cpp index 506dd815..7f221706 100644 --- a/core/dbus_wrap.cpp +++ b/core/dbus_wrap.cpp @@ -12,7 +12,7 @@ void *dbus_handle{nullptr}; -#define DECL_FUNC(x) decltype(x) *p##x{}; +#define DECL_FUNC(x) decltype(p##x) p##x{}; DBUS_FUNCTIONS(DECL_FUNC) #undef DECL_FUNC diff --git a/core/dbus_wrap.h b/core/dbus_wrap.h index 298ce09a..09eaacf9 100644 --- a/core/dbus_wrap.h +++ b/core/dbus_wrap.h @@ -7,6 +7,9 @@ #include "dynload.h" +#ifdef HAVE_DYNLOAD + +#include #define DBUS_FUNCTIONS(MAGIC) \ MAGIC(dbus_error_init) \ @@ -25,15 +28,29 @@ MAGIC(dbus_message_iter_get_arg_type) \ MAGIC(dbus_message_iter_get_basic) \ MAGIC(dbus_set_error_from_message) -#ifdef HAVE_DYNLOAD - -#include - extern void *dbus_handle; #define DECL_FUNC(x) extern decltype(x) *p##x; DBUS_FUNCTIONS(DECL_FUNC) #undef DECL_FUNC +#ifndef IN_IDE_PARSER +#define dbus_error_init (*pdbus_error_init) +#define dbus_error_free (*pdbus_error_free) +#define dbus_bus_get (*pdbus_bus_get) +#define dbus_connection_set_exit_on_disconnect (*pdbus_connection_set_exit_on_disconnect) +#define dbus_connection_unref (*pdbus_connection_unref) +#define dbus_connection_send_with_reply_and_block (*pdbus_connection_send_with_reply_and_block) +#define dbus_message_unref (*pdbus_message_unref) +#define dbus_message_new_method_call (*pdbus_message_new_method_call) +#define dbus_message_append_args (*pdbus_message_append_args) +#define dbus_message_iter_init (*pdbus_message_iter_init) +#define dbus_message_iter_next (*pdbus_message_iter_next) +#define dbus_message_iter_recurse (*pdbus_message_iter_recurse) +#define dbus_message_iter_get_arg_type (*pdbus_message_iter_get_arg_type) +#define dbus_message_iter_get_basic (*pdbus_message_iter_get_basic) +#define dbus_set_error_from_message (*pdbus_set_error_from_message) +#endif + void PrepareDBus(); inline auto HasDBus() @@ -45,10 +62,6 @@ inline auto HasDBus() #else -#define DECL_FUNC(x) constexpr auto p##x = &x; -DBUS_FUNCTIONS(DECL_FUNC) -#undef DECL_FUNC - constexpr bool HasDBus() noexcept { return true; } #endif /* HAVE_DYNLOAD */ @@ -56,8 +69,8 @@ constexpr bool HasDBus() noexcept { return true; } namespace dbus { struct Error { - Error() { (*pdbus_error_init)(&mError); } - ~Error() { (*pdbus_error_free)(&mError); } + Error() { dbus_error_init(&mError); } + ~Error() { dbus_error_free(&mError); } DBusError* operator->() { return &mError; } DBusError &get() { return mError; } private: @@ -65,11 +78,10 @@ private: }; struct ConnectionDeleter { - void operator()(DBusConnection *c) { (*pdbus_connection_unref)(c); } + void operator()(DBusConnection *c) { dbus_connection_unref(c); } }; using ConnectionPtr = std::unique_ptr; } // namespace dbus - #endif /* CORE_DBUS_WRAP_H */ diff --git a/core/helpers.cpp b/core/helpers.cpp index 3cc7bf8f..754e66c1 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -447,7 +447,7 @@ bool SetRTPriorityRTKit(int prio) return false; } dbus::Error error; - dbus::ConnectionPtr conn{(*pdbus_bus_get)(DBUS_BUS_SYSTEM, &error.get())}; + dbus::ConnectionPtr conn{dbus_bus_get(DBUS_BUS_SYSTEM, &error.get())}; if(!conn) { WARN("D-Bus connection failed with %s: %s\n", error->name, error->message); @@ -455,7 +455,7 @@ bool SetRTPriorityRTKit(int prio) } /* Don't stupidly exit if the connection dies while doing this. */ - (*pdbus_connection_set_exit_on_disconnect)(conn.get(), false); + dbus_connection_set_exit_on_disconnect(conn.get(), false); auto limit_rttime = [](DBusConnection *c) -> int { diff --git a/core/rtkit.cpp b/core/rtkit.cpp index 8b489e71..9210220e 100644 --- a/core/rtkit.cpp +++ b/core/rtkit.cpp @@ -32,8 +32,6 @@ #include -#ifdef __linux__ - #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -46,24 +44,37 @@ namespace dbus { - constexpr int TypeString{'s'}; - constexpr int TypeVariant{'v'}; - constexpr int TypeInt32{'i'}; - constexpr int TypeUInt32{'u'}; - constexpr int TypeInt64{'x'}; - constexpr int TypeUInt64{'t'}; - constexpr int TypeInvalid{'\0'}; - - struct MessageDeleter { - void operator()(DBusMessage *m) { (*pdbus_message_unref)(m); } - }; - using MessagePtr = std::unique_ptr; + +constexpr int TypeString{'s'}; +constexpr int TypeVariant{'v'}; +constexpr int TypeInt32{'i'}; +constexpr int TypeUInt32{'u'}; +constexpr int TypeInt64{'x'}; +constexpr int TypeUInt64{'t'}; +constexpr int TypeInvalid{'\0'}; + +struct MessageDeleter { + void operator()(DBusMessage *m) { dbus_message_unref(m); } +}; +using MessagePtr = std::unique_ptr; + } // namespace dbus namespace { inline pid_t _gettid() -{ return static_cast(syscall(SYS_gettid)); } +{ +#ifdef __linux__ + return static_cast(syscall(SYS_gettid)); +#elif defined(__FreeBSD__) + long pid{}; + thr_self(&pid); + return static_cast(pid); +#else +#warning gettid not available + return 0; +#endif +} int translate_error(const char *name) { @@ -80,41 +91,41 @@ int translate_error(const char *name) int rtkit_get_int_property(DBusConnection *connection, const char *propname, long long *propval) { - dbus::MessagePtr m{(*pdbus_message_new_method_call)(RTKIT_SERVICE_NAME, RTKIT_OBJECT_PATH, + dbus::MessagePtr m{dbus_message_new_method_call(RTKIT_SERVICE_NAME, RTKIT_OBJECT_PATH, "org.freedesktop.DBus.Properties", "Get")}; if(!m) return -ENOMEM; const char *interfacestr = RTKIT_SERVICE_NAME; - auto ready = (*pdbus_message_append_args)(m.get(), + auto ready = dbus_message_append_args(m.get(), dbus::TypeString, &interfacestr, dbus::TypeString, &propname, dbus::TypeInvalid); if(!ready) return -ENOMEM; dbus::Error error; - dbus::MessagePtr r{(*pdbus_connection_send_with_reply_and_block)(connection, m.get(), -1, + dbus::MessagePtr r{dbus_connection_send_with_reply_and_block(connection, m.get(), -1, &error.get())}; if(!r) return translate_error(error->name); - if((*pdbus_set_error_from_message)(&error.get(), r.get())) + if(dbus_set_error_from_message(&error.get(), r.get())) return translate_error(error->name); int ret{-EBADMSG}; DBusMessageIter iter{}; - (*pdbus_message_iter_init)(r.get(), &iter); - while(int curtype{(*pdbus_message_iter_get_arg_type)(&iter)}) + dbus_message_iter_init(r.get(), &iter); + while(int curtype{dbus_message_iter_get_arg_type(&iter)}) { if(curtype == dbus::TypeVariant) { DBusMessageIter subiter{}; - (*pdbus_message_iter_recurse)(&iter, &subiter); + dbus_message_iter_recurse(&iter, &subiter); - while((curtype=(*pdbus_message_iter_get_arg_type)(&subiter)) != dbus::TypeInvalid) + while((curtype=dbus_message_iter_get_arg_type(&subiter)) != dbus::TypeInvalid) { if(curtype == dbus::TypeInt32) { dbus_int32_t i32{}; - (*pdbus_message_iter_get_basic)(&subiter, &i32); + dbus_message_iter_get_basic(&subiter, &i32); *propval = i32; ret = 0; } @@ -122,15 +133,15 @@ int rtkit_get_int_property(DBusConnection *connection, const char *propname, lon if(curtype == dbus::TypeInt64) { dbus_int64_t i64{}; - (*pdbus_message_iter_get_basic)(&subiter, &i64); + dbus_message_iter_get_basic(&subiter, &i64); *propval = i64; ret = 0; } - (*pdbus_message_iter_next)(&subiter); + dbus_message_iter_next(&subiter); } } - (*pdbus_message_iter_next)(&iter); + dbus_message_iter_next(&iter); } return ret; @@ -138,7 +149,6 @@ int rtkit_get_int_property(DBusConnection *connection, const char *propname, lon } // namespace -extern "C" { int rtkit_get_max_realtime_priority(DBusConnection *connection) { long long retval{}; @@ -165,25 +175,27 @@ int rtkit_make_realtime(DBusConnection *connection, pid_t thread, int priority) { if(thread == 0) thread = _gettid(); + if(thread == 0) + return -ENOTSUP; - dbus::MessagePtr m{(*pdbus_message_new_method_call)(RTKIT_SERVICE_NAME, RTKIT_OBJECT_PATH, + dbus::MessagePtr m{dbus_message_new_method_call(RTKIT_SERVICE_NAME, RTKIT_OBJECT_PATH, "org.freedesktop.RealtimeKit1", "MakeThreadRealtime")}; if(!m) return -ENOMEM; auto u64 = static_cast(thread); auto u32 = static_cast(priority); - auto ready = (*pdbus_message_append_args)(m.get(), + auto ready = dbus_message_append_args(m.get(), dbus::TypeUInt64, &u64, dbus::TypeUInt32, &u32, dbus::TypeInvalid); if(!ready) return -ENOMEM; dbus::Error error; - dbus::MessagePtr r{(*pdbus_connection_send_with_reply_and_block)(connection, m.get(), -1, + dbus::MessagePtr r{dbus_connection_send_with_reply_and_block(connection, m.get(), -1, &error.get())}; if(!r) return translate_error(error->name); - if((*pdbus_set_error_from_message)(&error.get(), r.get())) + if(dbus_set_error_from_message(&error.get(), r.get())) return translate_error(error->name); return 0; @@ -193,48 +205,28 @@ int rtkit_make_high_priority(DBusConnection *connection, pid_t thread, int nice_ { if(thread == 0) thread = _gettid(); + if(thread == 0) + return -ENOTSUP; - dbus::MessagePtr m{(*pdbus_message_new_method_call)(RTKIT_SERVICE_NAME, RTKIT_OBJECT_PATH, + dbus::MessagePtr m{dbus_message_new_method_call(RTKIT_SERVICE_NAME, RTKIT_OBJECT_PATH, "org.freedesktop.RealtimeKit1", "MakeThreadHighPriority")}; if(!m) return -ENOMEM; auto u64 = static_cast(thread); auto s32 = static_cast(nice_level); - auto ready = (*pdbus_message_append_args)(m.get(), + auto ready = dbus_message_append_args(m.get(), dbus::TypeUInt64, &u64, dbus::TypeInt32, &s32, dbus::TypeInvalid); if(!ready) return -ENOMEM; dbus::Error error; - dbus::MessagePtr r{(*pdbus_connection_send_with_reply_and_block)(connection, m.get(), -1, + dbus::MessagePtr r{dbus_connection_send_with_reply_and_block(connection, m.get(), -1, &error.get())}; if(!r) return translate_error(error->name); - if((*pdbus_set_error_from_message)(&error.get(), r.get())) + if(dbus_set_error_from_message(&error.get(), r.get())) return translate_error(error->name); return 0; } -} // extern "C" - -#else - -extern "C" { -int rtkit_make_realtime(DBusConnection *connection, pid_t thread, int priority) -{ return -ENOTSUP; } - -int rtkit_make_high_priority(DBusConnection *connection, pid_t thread, int nice_level) -{ return -ENOTSUP; } - -int rtkit_get_max_realtime_priority(DBusConnection *connection) -{ return -ENOTSUP; } - -int rtkit_get_min_nice_level(DBusConnection *connection, int *min_nice_level) -{ return -ENOTSUP; } - -long long rtkit_get_rttime_usec_max(DBusConnection *connection) -{ return -ENOTSUP; } -} // extern "C" - -#endif diff --git a/core/rtkit.h b/core/rtkit.h index 96e81d4a..d4994e27 100644 --- a/core/rtkit.h +++ b/core/rtkit.h @@ -32,10 +32,6 @@ #include "dbus_wrap.h" -#ifdef __cplusplus -extern "C" { -#endif - /* This is the reference implementation for a client for * RealtimeKit. You don't have to use this, but if do, just copy these * sources into your repository */ @@ -72,9 +68,4 @@ int rtkit_get_min_nice_level(DBusConnection *system_bus, int *min_nice_level); */ long long rtkit_get_rttime_usec_max(DBusConnection *system_bus); - -#ifdef __cplusplus -} -#endif - #endif -- cgit v1.2.3 From 42bacc399ba799c840a3be6986b3008ece2561d7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 23 Feb 2022 02:39:17 -0800 Subject: Fix an unused parameter warning ... when either pthread_setschedparam or RTKit aren't available. --- core/helpers.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/helpers.cpp') diff --git a/core/helpers.cpp b/core/helpers.cpp index 754e66c1..e4a94fe5 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "almalloc.h" #include "alfstream.h" @@ -432,8 +433,11 @@ bool SetRTPriorityPthread(int prio) #endif err = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); if(err == 0) return true; -#endif +#else + + std::ignore = prio; +#endif WARN("pthread_setschedparam failed: %s (%d)\n", std::strerror(err), err); return false; } @@ -531,6 +535,7 @@ bool SetRTPriorityRTKit(int prio) #else + std::ignore = prio; WARN("D-Bus not supported\n"); #endif return false; -- cgit v1.2.3 From c870e550fa37d10e8a9d7d15ef1d6370d1e0399e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 9 May 2022 12:38:12 -0700 Subject: Don't enable RTKit/D-Bus support on Windows --- CMakeLists.txt | 63 +++++++++++++++++++++++++++++--------------------------- core/helpers.cpp | 23 ++++++++++----------- 2 files changed, 44 insertions(+), 42 deletions(-) (limited to 'core/helpers.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index ea646617..d3945e95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -677,39 +677,42 @@ set(CORE_OBJS core/voice_change.h) set(HAVE_RTKIT 0) -option(ALSOFT_REQUIRE_RTKIT "Require RTKit/D-Bus support" FALSE) -find_package(DBus1 QUIET) -if(NOT DBus1_FOUND AND PkgConfig_FOUND) - pkg_check_modules(DBUS dbus-1) -endif() -if(DBus1_FOUND OR DBUS_FOUND) - option(ALSOFT_RTKIT "Enable RTKit support" ON) - if(ALSOFT_RTKIT) - set(HAVE_RTKIT 1) - set(CORE_OBJS ${CORE_OBJS} core/dbus_wrap.cpp core/dbus_wrap.h core/rtkit.cpp core/rtkit.h) - if(NOT DBus1_FOUND) - set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS}) - set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER}) - if(NOT WIN32 AND NOT HAVE_DLFCN_H) - set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES}) +if(NOT WIN32) + option(ALSOFT_REQUIRE_RTKIT "Require RTKit/D-Bus support" FALSE) + find_package(DBus1 QUIET) + if(NOT DBus1_FOUND AND PkgConfig_FOUND) + pkg_check_modules(DBUS dbus-1) + endif() + if(DBus1_FOUND OR DBUS_FOUND) + option(ALSOFT_RTKIT "Enable RTKit support" ON) + if(ALSOFT_RTKIT) + set(HAVE_RTKIT 1) + set(CORE_OBJS ${CORE_OBJS} core/dbus_wrap.cpp core/dbus_wrap.h + core/rtkit.cpp core/rtkit.h) + if(NOT DBus1_FOUND) + set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS}) + set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER}) + if(NOT HAVE_DLFCN_H) + set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES}) + endif() + elseif(HAVE_DLFCN_H) + set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS}) + set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS}) + else() + set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES}) endif() - elseif(WIN32 OR HAVE_DLFCN_H) - set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS}) - set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS}) - else() - set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES}) endif() + else() + set(MISSING_VARS "") + if(NOT DBus1_INCLUDE_DIRS) + set(MISSING_VARS "${MISSING_VARS} DBus1_INCLUDE_DIRS") + endif() + if(NOT DBus1_LIBRARIES) + set(MISSING_VARS "${MISSING_VARS} DBus1_LIBRARIES") + endif() + message(STATUS "Could NOT find DBus1 (missing:${MISSING_VARS})") + unset(MISSING_VARS) endif() -else() - set(MISSING_VARS "") - if(NOT DBus1_INCLUDE_DIRS) - set(MISSING_VARS "${MISSING_VARS} DBus1_INCLUDE_DIRS") - endif() - if(NOT DBus1_LIBRARIES) - set(MISSING_VARS "${MISSING_VARS} DBus1_LIBRARIES") - endif() - message(STATUS "Could NOT find DBus1 (missing:${MISSING_VARS})") - unset(MISSING_VARS) endif() if(ALSOFT_REQUIRE_RTKIT AND NOT HAVE_RTKIT) message(FATAL_ERROR "Failed to enabled required RTKit support") diff --git a/core/helpers.cpp b/core/helpers.cpp index e4a94fe5..c7e45a8b 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -461,6 +461,17 @@ bool SetRTPriorityRTKit(int prio) /* Don't stupidly exit if the connection dies while doing this. */ dbus_connection_set_exit_on_disconnect(conn.get(), false); + int nicemin{}; + int err{rtkit_get_min_nice_level(conn.get(), &nicemin)}; + if(err == -ENOENT) + { + err = std::abs(err); + ERR("Could not query RTKit: %s (%d)\n", std::strerror(err), err); + return false; + } + int rtmax{rtkit_get_max_realtime_priority(conn.get())}; + TRACE("Maximum real-time priority: %d, minimum niceness: %d\n", rtmax, nicemin); + auto limit_rttime = [](DBusConnection *c) -> int { using ulonglong = unsigned long long; @@ -483,18 +494,6 @@ bool SetRTPriorityRTKit(int prio) } return 0; }; - - int nicemin{}; - int err{rtkit_get_min_nice_level(conn.get(), &nicemin)}; - if(err == -ENOENT) - { - err = std::abs(err); - ERR("Could not query RTKit: %s (%d)\n", std::strerror(err), err); - return false; - } - int rtmax{rtkit_get_max_realtime_priority(conn.get())}; - TRACE("Maximum real-time priority: %d, minimum niceness: %d\n", rtmax, nicemin); - if(rtmax > 0) { if(AllowRTTimeLimit) -- cgit v1.2.3 From e0d26ba25ab84f5a04a6ad2ef497cd0e93684a40 Mon Sep 17 00:00:00 2001 From: ilya-fedin Date: Sat, 14 May 2022 00:55:17 +0400 Subject: Search the installation data directory (#693) That allows the logic to work on non-FHS distros like NixOS --- CMakeLists.txt | 5 +++++ config.h.in | 3 +++ core/helpers.cpp | 14 ++++++++++++++ 3 files changed, 22 insertions(+) (limited to 'core/helpers.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index d3945e95..ebfcc4e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,11 @@ option(ALSOFT_UPDATE_BUILD_VERSION "Update git build version info" ON) option(ALSOFT_EAX "Enable legacy EAX extensions" ${WIN32}) +option(ALSOFT_SEARCH_INSTALL_DATADIR "Search the installation data directory" OFF) +if(ALSOFT_SEARCH_INSTALL_DATADIR) + set(ALSOFT_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}) +endif() + if(DEFINED SHARE_INSTALL_DIR) message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead") set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}") diff --git a/config.h.in b/config.h.in index 416b87d4..477d8c77 100644 --- a/config.h.in +++ b/config.h.in @@ -114,3 +114,6 @@ /* Define if we have pthread_set_name_np() */ #cmakedefine HAVE_PTHREAD_SET_NAME_NP + +/* Define the installation data directory */ +#cmakedefine ALSOFT_INSTALL_DATADIR "@ALSOFT_INSTALL_DATADIR@" diff --git a/core/helpers.cpp b/core/helpers.cpp index c7e45a8b..6d0863ca 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -408,6 +408,20 @@ al::vector SearchDataFiles(const char *ext, const char *subdir) DirectorySearch(path.c_str(), ext, &results); } +#ifdef ALSOFT_INSTALL_DATADIR + // Search the installation data directory + { + std::string path{ALSOFT_INSTALL_DATADIR}; + if(!path.empty()) + { + if(path.back() != '/') + path += '/'; + path += subdir; + DirectorySearch(path.c_str(), ext, &results); + } + } +#endif + return results; } -- cgit v1.2.3 From 1b28a24f6e917380536d882384aba388e331329e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 22 Jul 2022 17:29:50 -0700 Subject: Don't assume rlim_t is unsigned --- core/helpers.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'core/helpers.cpp') diff --git a/core/helpers.cpp b/core/helpers.cpp index 6d0863ca..dea7fdf5 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -497,11 +497,12 @@ bool SetRTPriorityRTKit(int prio) if(getrlimit(RLIMIT_RTTIME, &rlim) != 0) return errno; - TRACE("RTTime max: %llu (hard: %llu, soft: %llu)\n", umaxtime, ulonglong{rlim.rlim_max}, - ulonglong{rlim.rlim_cur}); + TRACE("RTTime max: %llu (hard: %llu, soft: %llu)\n", umaxtime, + static_cast(rlim.rlim_max), static_cast(rlim.rlim_cur)); if(rlim.rlim_max > umaxtime) { - rlim.rlim_max = static_cast(umaxtime); + rlim.rlim_max = static_cast(std::min(umaxtime, + std::numeric_limits::max())); rlim.rlim_cur = std::min(rlim.rlim_cur, rlim.rlim_max); if(setrlimit(RLIMIT_RTTIME, &rlim) != 0) return errno; -- cgit v1.2.3 From fa52ceaf2683371c7910047b0d17c486a556299e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 30 Dec 2022 21:28:39 -0800 Subject: Simplify constructing the process path and executable name --- core/helpers.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'core/helpers.cpp') diff --git a/core/helpers.cpp b/core/helpers.cpp index dea7fdf5..1670561a 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -59,16 +59,15 @@ const PathNamePair &GetProcBinary() if(fullpath.back() != 0) fullpath.push_back(0); + std::replace(fullpath.begin(), fullpath.end(), '/', '\\'); auto sep = std::find(fullpath.rbegin()+1, fullpath.rend(), '\\'); - sep = std::find(fullpath.rbegin()+1, sep, '/'); if(sep != fullpath.rend()) { *sep = 0; - procbin = al::make_optional(wstr_to_utf8(fullpath.data()), - wstr_to_utf8(&*sep + 1)); + procbin.emplace(wstr_to_utf8(fullpath.data()), wstr_to_utf8(al::to_address(sep.base()))); } else - procbin = al::make_optional(std::string{}, wstr_to_utf8(fullpath.data())); + procbin.emplace(std::string{}, wstr_to_utf8(fullpath.data())); TRACE("Got binary: %s, %s\n", procbin->path.c_str(), procbin->fname.c_str()); return *procbin; @@ -285,11 +284,10 @@ const PathNamePair &GetProcBinary() auto sep = std::find(pathname.crbegin(), pathname.crend(), '/'); if(sep != pathname.crend()) - procbin = al::make_optional(std::string(pathname.cbegin(), sep.base()-1), + procbin.emplace(std::string(pathname.cbegin(), sep.base()-1), std::string(sep.base(), pathname.cend())); else - procbin = al::make_optional(std::string{}, - std::string(pathname.cbegin(), pathname.cend())); + procbin.emplace(std::string{}, std::string(pathname.cbegin(), pathname.cend())); TRACE("Got binary: \"%s\", \"%s\"\n", procbin->path.c_str(), procbin->fname.c_str()); return *procbin; -- cgit v1.2.3 From 974d1b9e6d174f1680604b2872911110f6a0e41c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 13 Jan 2023 01:25:20 -0800 Subject: Avoid unnecessary uses of make_optional --- al/buffer.cpp | 46 ++++++++++++++++++++++----------------------- al/effects/chorus.cpp | 4 ++-- al/effects/fshifter.cpp | 6 +++--- al/effects/modulator.cpp | 6 +++--- al/effects/vmorpher.cpp | 8 ++++---- al/source.cpp | 30 ++++++++++++++--------------- al/state.cpp | 14 +++++++------- alc/alc.cpp | 40 +++++++++++++++++++-------------------- alc/alconfig.cpp | 12 ++++++------ alc/backends/pulseaudio.cpp | 6 ++++-- common/strutils.cpp | 4 ++-- core/ambdec.cpp | 2 +- core/cpu_caps.cpp | 2 +- core/helpers.cpp | 2 +- 14 files changed, 92 insertions(+), 90 deletions(-) (limited to 'core/helpers.cpp') diff --git a/al/buffer.cpp b/al/buffer.cpp index 93daf4f5..6bf3ecbc 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -288,8 +288,8 @@ al::optional AmbiLayoutFromEnum(ALenum layout) { switch(layout) { - case AL_FUMA_SOFT: return al::make_optional(AmbiLayout::FuMa); - case AL_ACN_SOFT: return al::make_optional(AmbiLayout::ACN); + case AL_FUMA_SOFT: return AmbiLayout::FuMa; + case AL_ACN_SOFT: return AmbiLayout::ACN; } return al::nullopt; } @@ -307,9 +307,9 @@ al::optional AmbiScalingFromEnum(ALenum scale) { switch(scale) { - case AL_FUMA_SOFT: return al::make_optional(AmbiScaling::FuMa); - case AL_SN3D_SOFT: return al::make_optional(AmbiScaling::SN3D); - case AL_N3D_SOFT: return al::make_optional(AmbiScaling::N3D); + case AL_FUMA_SOFT: return AmbiScaling::FuMa; + case AL_SN3D_SOFT: return AmbiScaling::SN3D; + case AL_N3D_SOFT: return AmbiScaling::N3D; } return al::nullopt; } @@ -329,18 +329,18 @@ al::optional FmtFromUserFmt(UserFmtChannels chans) { switch(chans) { - case UserFmtMono: return al::make_optional(FmtMono); - case UserFmtStereo: return al::make_optional(FmtStereo); - case UserFmtRear: return al::make_optional(FmtRear); - case UserFmtQuad: return al::make_optional(FmtQuad); - case UserFmtX51: return al::make_optional(FmtX51); - case UserFmtX61: return al::make_optional(FmtX61); - case UserFmtX71: return al::make_optional(FmtX71); - case UserFmtBFormat2D: return al::make_optional(FmtBFormat2D); - case UserFmtBFormat3D: return al::make_optional(FmtBFormat3D); - case UserFmtUHJ2: return al::make_optional(FmtUHJ2); - case UserFmtUHJ3: return al::make_optional(FmtUHJ3); - case UserFmtUHJ4: return al::make_optional(FmtUHJ4); + case UserFmtMono: return FmtMono; + case UserFmtStereo: return FmtStereo; + case UserFmtRear: return FmtRear; + case UserFmtQuad: return FmtQuad; + case UserFmtX51: return FmtX51; + case UserFmtX61: return FmtX61; + case UserFmtX71: return FmtX71; + case UserFmtBFormat2D: return FmtBFormat2D; + case UserFmtBFormat3D: return FmtBFormat3D; + case UserFmtUHJ2: return FmtUHJ2; + case UserFmtUHJ3: return FmtUHJ3; + case UserFmtUHJ4: return FmtUHJ4; } return al::nullopt; } @@ -348,12 +348,12 @@ al::optional FmtFromUserFmt(UserFmtType type) { switch(type) { - case UserFmtUByte: return al::make_optional(FmtUByte); - case UserFmtShort: return al::make_optional(FmtShort); - case UserFmtFloat: return al::make_optional(FmtFloat); - case UserFmtDouble: return al::make_optional(FmtDouble); - case UserFmtMulaw: return al::make_optional(FmtMulaw); - case UserFmtAlaw: return al::make_optional(FmtAlaw); + case UserFmtUByte: return FmtUByte; + case UserFmtShort: return FmtShort; + case UserFmtFloat: return FmtFloat; + case UserFmtDouble: return FmtDouble; + case UserFmtMulaw: return FmtMulaw; + case UserFmtAlaw: return FmtAlaw; /* ADPCM not handled here. */ case UserFmtIMA4: break; case UserFmtMSADPCM: break; diff --git a/al/effects/chorus.cpp b/al/effects/chorus.cpp index 1651ebb9..a05ec10b 100644 --- a/al/effects/chorus.cpp +++ b/al/effects/chorus.cpp @@ -31,8 +31,8 @@ inline al::optional WaveformFromEnum(ALenum type) { switch(type) { - case AL_CHORUS_WAVEFORM_SINUSOID: return al::make_optional(ChorusWaveform::Sinusoid); - case AL_CHORUS_WAVEFORM_TRIANGLE: return al::make_optional(ChorusWaveform::Triangle); + case AL_CHORUS_WAVEFORM_SINUSOID: return ChorusWaveform::Sinusoid; + case AL_CHORUS_WAVEFORM_TRIANGLE: return ChorusWaveform::Triangle; } return al::nullopt; } diff --git a/al/effects/fshifter.cpp b/al/effects/fshifter.cpp index 400c0bf4..9ca28775 100644 --- a/al/effects/fshifter.cpp +++ b/al/effects/fshifter.cpp @@ -24,9 +24,9 @@ al::optional DirectionFromEmum(ALenum value) { switch(value) { - case AL_FREQUENCY_SHIFTER_DIRECTION_DOWN: return al::make_optional(FShifterDirection::Down); - case AL_FREQUENCY_SHIFTER_DIRECTION_UP: return al::make_optional(FShifterDirection::Up); - case AL_FREQUENCY_SHIFTER_DIRECTION_OFF: return al::make_optional(FShifterDirection::Off); + case AL_FREQUENCY_SHIFTER_DIRECTION_DOWN: return FShifterDirection::Down; + case AL_FREQUENCY_SHIFTER_DIRECTION_UP: return FShifterDirection::Up; + case AL_FREQUENCY_SHIFTER_DIRECTION_OFF: return FShifterDirection::Off; } return al::nullopt; } diff --git a/al/effects/modulator.cpp b/al/effects/modulator.cpp index e917e3a0..070b0998 100644 --- a/al/effects/modulator.cpp +++ b/al/effects/modulator.cpp @@ -24,9 +24,9 @@ al::optional WaveformFromEmum(ALenum value) { switch(value) { - case AL_RING_MODULATOR_SINUSOID: return al::make_optional(ModulatorWaveform::Sinusoid); - case AL_RING_MODULATOR_SAWTOOTH: return al::make_optional(ModulatorWaveform::Sawtooth); - case AL_RING_MODULATOR_SQUARE: return al::make_optional(ModulatorWaveform::Square); + case AL_RING_MODULATOR_SINUSOID: return ModulatorWaveform::Sinusoid; + case AL_RING_MODULATOR_SAWTOOTH: return ModulatorWaveform::Sawtooth; + case AL_RING_MODULATOR_SQUARE: return ModulatorWaveform::Square; } return al::nullopt; } diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp index e1b7a698..e26c6fe3 100644 --- a/al/effects/vmorpher.cpp +++ b/al/effects/vmorpher.cpp @@ -23,7 +23,7 @@ namespace { al::optional PhenomeFromEnum(ALenum val) { #define HANDLE_PHENOME(x) case AL_VOCAL_MORPHER_PHONEME_ ## x: \ - return al::make_optional(VMorpherPhenome::x) + return VMorpherPhenome::x switch(val) { HANDLE_PHENOME(A); @@ -104,9 +104,9 @@ al::optional WaveformFromEmum(ALenum value) { switch(value) { - case AL_VOCAL_MORPHER_WAVEFORM_SINUSOID: return al::make_optional(VMorpherWaveform::Sinusoid); - case AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE: return al::make_optional(VMorpherWaveform::Triangle); - case AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH: return al::make_optional(VMorpherWaveform::Sawtooth); + case AL_VOCAL_MORPHER_WAVEFORM_SINUSOID: return VMorpherWaveform::Sinusoid; + case AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE: return VMorpherWaveform::Triangle; + case AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH: return VMorpherWaveform::Sawtooth; } return al::nullopt; } diff --git a/al/source.cpp b/al/source.cpp index 5d95ba8a..1e4a5a50 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -839,8 +839,8 @@ al::optional StereoModeFromEnum(ALenum mode) { switch(mode) { - case AL_NORMAL_SOFT: return al::make_optional(SourceStereo::Normal); - case AL_SUPER_STEREO_SOFT: return al::make_optional(SourceStereo::Enhanced); + case AL_NORMAL_SOFT: return SourceStereo::Normal; + case AL_SUPER_STEREO_SOFT: return SourceStereo::Enhanced; } WARN("Unsupported stereo mode: 0x%04x\n", mode); return al::nullopt; @@ -859,9 +859,9 @@ al::optional SpatializeModeFromEnum(ALenum mode) { switch(mode) { - case AL_FALSE: return al::make_optional(SpatializeMode::Off); - case AL_TRUE: return al::make_optional(SpatializeMode::On); - case AL_AUTO_SOFT: return al::make_optional(SpatializeMode::Auto); + case AL_FALSE: return SpatializeMode::Off; + case AL_TRUE: return SpatializeMode::On; + case AL_AUTO_SOFT: return SpatializeMode::Auto; } WARN("Unsupported spatialize mode: 0x%04x\n", mode); return al::nullopt; @@ -881,9 +881,9 @@ al::optional DirectModeFromEnum(ALenum mode) { switch(mode) { - case AL_FALSE: return al::make_optional(DirectMode::Off); - case AL_DROP_UNMATCHED_SOFT: return al::make_optional(DirectMode::DropMismatch); - case AL_REMIX_UNMATCHED_SOFT: return al::make_optional(DirectMode::RemixMismatch); + case AL_FALSE: return DirectMode::Off; + case AL_DROP_UNMATCHED_SOFT: return DirectMode::DropMismatch; + case AL_REMIX_UNMATCHED_SOFT: return DirectMode::RemixMismatch; } WARN("Unsupported direct mode: 0x%04x\n", mode); return al::nullopt; @@ -903,13 +903,13 @@ al::optional DistanceModelFromALenum(ALenum model) { switch(model) { - case AL_NONE: return al::make_optional(DistanceModel::Disable); - case AL_INVERSE_DISTANCE: return al::make_optional(DistanceModel::Inverse); - case AL_INVERSE_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::InverseClamped); - case AL_LINEAR_DISTANCE: return al::make_optional(DistanceModel::Linear); - case AL_LINEAR_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::LinearClamped); - case AL_EXPONENT_DISTANCE: return al::make_optional(DistanceModel::Exponent); - case AL_EXPONENT_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::ExponentClamped); + case AL_NONE: return DistanceModel::Disable; + case AL_INVERSE_DISTANCE: return DistanceModel::Inverse; + case AL_INVERSE_DISTANCE_CLAMPED: return DistanceModel::InverseClamped; + case AL_LINEAR_DISTANCE: return DistanceModel::Linear; + case AL_LINEAR_DISTANCE_CLAMPED: return DistanceModel::LinearClamped; + case AL_EXPONENT_DISTANCE: return DistanceModel::Exponent; + case AL_EXPONENT_DISTANCE_CLAMPED: return DistanceModel::ExponentClamped; } return al::nullopt; } diff --git a/al/state.cpp b/al/state.cpp index d1c5605d..11202374 100644 --- a/al/state.cpp +++ b/al/state.cpp @@ -107,13 +107,13 @@ al::optional DistanceModelFromALenum(ALenum model) { switch(model) { - case AL_NONE: return al::make_optional(DistanceModel::Disable); - case AL_INVERSE_DISTANCE: return al::make_optional(DistanceModel::Inverse); - case AL_INVERSE_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::InverseClamped); - case AL_LINEAR_DISTANCE: return al::make_optional(DistanceModel::Linear); - case AL_LINEAR_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::LinearClamped); - case AL_EXPONENT_DISTANCE: return al::make_optional(DistanceModel::Exponent); - case AL_EXPONENT_DISTANCE_CLAMPED: return al::make_optional(DistanceModel::ExponentClamped); + case AL_NONE: return DistanceModel::Disable; + case AL_INVERSE_DISTANCE: return DistanceModel::Inverse; + case AL_INVERSE_DISTANCE_CLAMPED: return DistanceModel::InverseClamped; + case AL_LINEAR_DISTANCE: return DistanceModel::Linear; + case AL_LINEAR_DISTANCE_CLAMPED: return DistanceModel::LinearClamped; + case AL_EXPONENT_DISTANCE: return DistanceModel::Exponent; + case AL_EXPONENT_DISTANCE_CLAMPED: return DistanceModel::ExponentClamped; } return al::nullopt; } diff --git a/alc/alc.cpp b/alc/alc.cpp index 37b85255..654f3fb2 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1428,7 +1428,7 @@ al::optional DecomposeDevFormat(ALenum format) for(const auto &item : list) { if(item.format == format) - return al::make_optional(DevFmtPair{item.channels, item.type}); + return al::make_optional({item.channels, item.type}); } return al::nullopt; @@ -1438,13 +1438,13 @@ al::optional DevFmtTypeFromEnum(ALCenum type) { switch(type) { - case ALC_BYTE_SOFT: return al::make_optional(DevFmtByte); - case ALC_UNSIGNED_BYTE_SOFT: return al::make_optional(DevFmtUByte); - case ALC_SHORT_SOFT: return al::make_optional(DevFmtShort); - case ALC_UNSIGNED_SHORT_SOFT: return al::make_optional(DevFmtUShort); - case ALC_INT_SOFT: return al::make_optional(DevFmtInt); - case ALC_UNSIGNED_INT_SOFT: return al::make_optional(DevFmtUInt); - case ALC_FLOAT_SOFT: return al::make_optional(DevFmtFloat); + case ALC_BYTE_SOFT: return DevFmtByte; + case ALC_UNSIGNED_BYTE_SOFT: return DevFmtUByte; + case ALC_SHORT_SOFT: return DevFmtShort; + case ALC_UNSIGNED_SHORT_SOFT: return DevFmtUShort; + case ALC_INT_SOFT: return DevFmtInt; + case ALC_UNSIGNED_INT_SOFT: return DevFmtUInt; + case ALC_FLOAT_SOFT: return DevFmtFloat; } WARN("Unsupported format type: 0x%04x\n", type); return al::nullopt; @@ -1468,13 +1468,13 @@ al::optional DevFmtChannelsFromEnum(ALCenum channels) { switch(channels) { - case ALC_MONO_SOFT: return al::make_optional(DevFmtMono); - case ALC_STEREO_SOFT: return al::make_optional(DevFmtStereo); - case ALC_QUAD_SOFT: return al::make_optional(DevFmtQuad); - case ALC_5POINT1_SOFT: return al::make_optional(DevFmtX51); - case ALC_6POINT1_SOFT: return al::make_optional(DevFmtX61); - case ALC_7POINT1_SOFT: return al::make_optional(DevFmtX71); - case ALC_BFORMAT3D_SOFT: return al::make_optional(DevFmtAmbi3D); + case ALC_MONO_SOFT: return DevFmtMono; + case ALC_STEREO_SOFT: return DevFmtStereo; + case ALC_QUAD_SOFT: return DevFmtQuad; + case ALC_5POINT1_SOFT: return DevFmtX51; + case ALC_6POINT1_SOFT: return DevFmtX61; + case ALC_7POINT1_SOFT: return DevFmtX71; + case ALC_BFORMAT3D_SOFT: return DevFmtAmbi3D; } WARN("Unsupported format channels: 0x%04x\n", channels); return al::nullopt; @@ -1501,8 +1501,8 @@ al::optional DevAmbiLayoutFromEnum(ALCenum layout) { switch(layout) { - case ALC_FUMA_SOFT: return al::make_optional(DevAmbiLayout::FuMa); - case ALC_ACN_SOFT: return al::make_optional(DevAmbiLayout::ACN); + case ALC_FUMA_SOFT: return DevAmbiLayout::FuMa; + case ALC_ACN_SOFT: return DevAmbiLayout::ACN; } WARN("Unsupported ambisonic layout: 0x%04x\n", layout); return al::nullopt; @@ -1521,9 +1521,9 @@ al::optional DevAmbiScalingFromEnum(ALCenum scaling) { switch(scaling) { - case ALC_FUMA_SOFT: return al::make_optional(DevAmbiScaling::FuMa); - case ALC_SN3D_SOFT: return al::make_optional(DevAmbiScaling::SN3D); - case ALC_N3D_SOFT: return al::make_optional(DevAmbiScaling::N3D); + case ALC_FUMA_SOFT: return DevAmbiScaling::FuMa; + case ALC_SN3D_SOFT: return DevAmbiScaling::SN3D; + case ALC_N3D_SOFT: return DevAmbiScaling::N3D; } WARN("Unsupported ambisonic scaling: 0x%04x\n", scaling); return al::nullopt; diff --git a/alc/alconfig.cpp b/alc/alconfig.cpp index 7c1eec6d..14b2580d 100644 --- a/alc/alconfig.cpp +++ b/alc/alconfig.cpp @@ -486,36 +486,36 @@ void ReadALConfig() al::optional ConfigValueStr(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(val); + return val; return al::nullopt; } al::optional ConfigValueInt(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(static_cast(std::strtol(val, nullptr, 0))); + return static_cast(std::strtol(val, nullptr, 0)); return al::nullopt; } al::optional ConfigValueUInt(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(static_cast(std::strtoul(val, nullptr, 0))); + return static_cast(std::strtoul(val, nullptr, 0)); return al::nullopt; } al::optional ConfigValueFloat(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(std::strtof(val, nullptr)); + return std::strtof(val, nullptr); return al::nullopt; } al::optional ConfigValueBool(const char *devName, const char *blockName, const char *keyName) { if(const char *val{GetConfigValue(devName, blockName, keyName)}) - return al::make_optional(al::strcasecmp(val, "on") == 0 || al::strcasecmp(val, "yes") == 0 - || al::strcasecmp(val, "true")==0 || atoi(val) != 0); + return al::strcasecmp(val, "on") == 0 || al::strcasecmp(val, "yes") == 0 + || al::strcasecmp(val, "true")==0 || atoi(val) != 0; return al::nullopt; } diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index 5eef8f87..f79e49b0 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -836,7 +836,8 @@ void PulsePlayback::open(const char *name) pa_stream_set_moved_callback(mStream, &PulsePlayback::streamMovedCallbackC, this); mFrameSize = static_cast(pa_frame_size(pa_stream_get_sample_spec(mStream))); - mDeviceName = pulse_name ? al::make_optional(pulse_name) : al::nullopt; + if(pulse_name) mDeviceName.emplace(pulse_name); + else mDeviceName.reset(); if(!dev_name) { pa_operation *op{pa_context_get_sink_info_by_name(mContext, @@ -1251,7 +1252,8 @@ void PulseCapture::open(const char *name) pa_stream_set_moved_callback(mStream, &PulseCapture::streamMovedCallbackC, this); pa_stream_set_state_callback(mStream, &PulseCapture::streamStateCallbackC, this); - mDeviceName = pulse_name ? al::make_optional(pulse_name) : al::nullopt; + if(pulse_name) mDeviceName.emplace(pulse_name); + else mDeviceName.reset(); if(mDevice->DeviceName.empty()) { pa_operation *op{pa_context_get_source_info_by_name(mContext, diff --git a/common/strutils.cpp b/common/strutils.cpp index 18c4947a..d0418eff 100644 --- a/common/strutils.cpp +++ b/common/strutils.cpp @@ -47,7 +47,7 @@ al::optional getenv(const char *envname) { const char *str{std::getenv(envname)}; if(str && str[0] != '\0') - return al::make_optional(str); + return str; return al::nullopt; } @@ -56,7 +56,7 @@ al::optional getenv(const WCHAR *envname) { const WCHAR *str{_wgetenv(envname)}; if(str && str[0] != L'\0') - return al::make_optional(str); + return str; return al::nullopt; } #endif diff --git a/core/ambdec.cpp b/core/ambdec.cpp index 83c521c0..52a1df05 100644 --- a/core/ambdec.cpp +++ b/core/ambdec.cpp @@ -81,7 +81,7 @@ al::optional AmbDecConf::load(const char *fname) noexcept { al::ifstream f{fname}; if(!f.is_open()) - return al::make_optional(std::string("Failed to open file \"")+fname+"\""); + return std::string("Failed to open file \"")+fname+"\""; ReaderScope scope{ReaderScope::Global}; size_t speaker_pos{0}; diff --git a/core/cpu_caps.cpp b/core/cpu_caps.cpp index 0325cd49..103d2437 100644 --- a/core/cpu_caps.cpp +++ b/core/cpu_caps.cpp @@ -137,5 +137,5 @@ al::optional GetCPUInfo() #endif #endif - return al::make_optional(ret); + return ret; } diff --git a/core/helpers.cpp b/core/helpers.cpp index 1670561a..99cf009c 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -51,7 +51,7 @@ const PathNamePair &GetProcBinary() if(len == 0) { ERR("Failed to get process name: error %lu\n", GetLastError()); - procbin = al::make_optional(); + procbin.emplace(); return *procbin; } -- cgit v1.2.3