diff --git a/Source/RMG-Core/CMakeLists.txt b/Source/RMG-Core/CMakeLists.txt index c5abf5b4..4dbd2fdf 100644 --- a/Source/RMG-Core/CMakeLists.txt +++ b/Source/RMG-Core/CMakeLists.txt @@ -43,6 +43,7 @@ set(RMG_CORE_SOURCES Callback.cpp Settings.cpp Archive.cpp + Library.cpp Netplay.cpp Plugins.cpp Version.cpp @@ -58,18 +59,6 @@ set(RMG_CORE_SOURCES Rom.cpp ) -if (WIN32) - list(APPEND RMG_CORE_SOURCES - osal/osal_dynlib_win32.cpp - osal/osal_files_win32.cpp - ) -else(WIN32) - list(APPEND RMG_CORE_SOURCES - osal/osal_dynlib_unix.cpp - osal/osal_files_unix.cpp - ) -endif(WIN32) - if (DISCORD_RPC) list(APPEND RMG_CORE_SOURCES DiscordRpc.cpp diff --git a/Source/RMG-Core/CachedRomHeaderAndSettings.cpp b/Source/RMG-Core/CachedRomHeaderAndSettings.cpp index dad5ace9..0265b5de 100644 --- a/Source/RMG-Core/CachedRomHeaderAndSettings.cpp +++ b/Source/RMG-Core/CachedRomHeaderAndSettings.cpp @@ -11,8 +11,7 @@ #include "Directories.hpp" #include "RomSettings.hpp" #include "RomHeader.hpp" - -#include "osal/osal_files.hpp" +#include "File.hpp" #include #include @@ -54,7 +53,7 @@ struct l_CacheEntry { std::filesystem::path fileName; - osal_files_file_time fileTime; + uint64_t fileTime; CoreRomType type; CoreRomHeader header; @@ -77,7 +76,7 @@ static std::filesystem::path get_cache_file_name() std::filesystem::path file; file = CoreGetUserCacheDirectory(); - file += OSAL_FILES_DIR_SEPERATOR_STR; + file += CORE_DIR_SEPERATOR_STR; file += "RomHeaderAndSettingsCache.cache"; return file; @@ -85,7 +84,7 @@ static std::filesystem::path get_cache_file_name() static std::vector::iterator get_cache_entry_iter(std::filesystem::path file, bool checkFileTime = true) { - osal_files_file_time fileTime = osal_files_get_file_time(file); + uint64_t fileTime = CoreGetFileTime(file); auto predicate = [file, fileTime, checkFileTime](const auto& entry) { @@ -298,7 +297,7 @@ bool CoreAddCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType t } cacheEntry.fileName = file; - cacheEntry.fileTime = osal_files_get_file_time(file); + cacheEntry.fileTime = CoreGetFileTime(file); cacheEntry.type = type; cacheEntry.header = header; cacheEntry.settings = settings; diff --git a/Source/RMG-Core/Cheats.cpp b/Source/RMG-Core/Cheats.cpp index 9021b85d..55bab413 100644 --- a/Source/RMG-Core/Cheats.cpp +++ b/Source/RMG-Core/Cheats.cpp @@ -15,7 +15,6 @@ #include "Cheats.hpp" #include "Error.hpp" -#include "osal/osal_files.hpp" #include "m64p/Api.hpp" #ifdef USE_LIBFMT @@ -118,9 +117,9 @@ static std::filesystem::path get_shared_cheat_file_path(CoreRomHeader romHeader, std::filesystem::path cheatFilePath; cheatFilePath = CoreGetSharedDataDirectory(); - cheatFilePath += OSAL_FILES_DIR_SEPERATOR_STR; + cheatFilePath += CORE_DIR_SEPERATOR_STR; cheatFilePath += "Cheats"; - cheatFilePath += OSAL_FILES_DIR_SEPERATOR_STR; + cheatFilePath += CORE_DIR_SEPERATOR_STR; cheatFilePath += get_cheat_file_name(romHeader, romSettings); return cheatFilePath; @@ -132,15 +131,15 @@ static std::filesystem::path get_user_cheat_file_path(CoreRomHeader romHeader, C std::filesystem::path cheatFilePath; oldCheatFilePath = CoreGetUserDataDirectory(); - oldCheatFilePath += OSAL_FILES_DIR_SEPERATOR_STR; + oldCheatFilePath += CORE_DIR_SEPERATOR_STR; oldCheatFilePath += "Cheats-User"; - oldCheatFilePath += OSAL_FILES_DIR_SEPERATOR_STR; + oldCheatFilePath += CORE_DIR_SEPERATOR_STR; oldCheatFilePath += get_cheat_file_name(romHeader, romSettings); cheatFilePath = CoreGetUserConfigDirectory(); - cheatFilePath += OSAL_FILES_DIR_SEPERATOR_STR; + cheatFilePath += CORE_DIR_SEPERATOR_STR; cheatFilePath += "Cheats-User"; - cheatFilePath += OSAL_FILES_DIR_SEPERATOR_STR; + cheatFilePath += CORE_DIR_SEPERATOR_STR; cheatFilePath += get_cheat_file_name(romHeader, romSettings); // try to make the user cheats directory diff --git a/Source/RMG-Core/Core.cpp b/Source/RMG-Core/Core.cpp index bf4a44ed..e60824bc 100644 --- a/Source/RMG-Core/Core.cpp +++ b/Source/RMG-Core/Core.cpp @@ -16,11 +16,11 @@ #endif // DISCORD_RPC #include "Callback.hpp" #include "Settings.hpp" +#include "Library.hpp" #include "Plugins.hpp" #include "Error.hpp" #include "Core.hpp" -#include "osal/osal_dynlib.hpp" #include "m64p/Api.hpp" #include "m64p/api/version.h" @@ -32,7 +32,7 @@ // Local Variables // -static osal_dynlib_lib_handle l_CoreLibHandle; +static CoreLibraryHandle l_CoreLibHandle; static char l_CoreContextString[20]; // @@ -45,7 +45,7 @@ static std::filesystem::path find_core_lib(void) { std::filesystem::path path = entry.path(); if (path.has_extension() && - path.extension() == OSAL_DYNLIB_LIB_EXT_STR) + path.extension() == CORE_LIBRARY_EXT_STR) { return path; } @@ -104,11 +104,11 @@ bool CoreInit(void) return false; } - l_CoreLibHandle = osal_dynlib_open(core_file); + l_CoreLibHandle = CoreOpenLibrary(core_file); if (l_CoreLibHandle == nullptr) { - error = "osal_dynlib_open Failed: "; - error += osal_dynlib_strerror(); + error = "CoreOpenLibrary Failed: "; + error += CoreGetLibraryError(); CoreSetError(error); return false; } @@ -193,5 +193,5 @@ void CoreShutdown(void) m64p::Core.Unhook(); m64p::Config.Unhook(); - osal_dynlib_close(l_CoreLibHandle); + CoreCloseLibrary(l_CoreLibHandle); } diff --git a/Source/RMG-Core/Directories.hpp b/Source/RMG-Core/Directories.hpp index 45fbefa5..aa389b73 100644 --- a/Source/RMG-Core/Directories.hpp +++ b/Source/RMG-Core/Directories.hpp @@ -12,6 +12,12 @@ #include +#ifdef _WIN32 +#define CORE_DIR_SEPERATOR_STR "\\" +#else // Unix +#define CORE_DIR_SEPERATOR_STR "/" +#endif // _WIN32 + // tries to create the needed directories, // returns false when failed bool CoreCreateDirectories(void); diff --git a/Source/RMG-Core/File.cpp b/Source/RMG-Core/File.cpp index 8cc7d534..e4155edd 100644 --- a/Source/RMG-Core/File.cpp +++ b/Source/RMG-Core/File.cpp @@ -14,6 +14,13 @@ #include #include +#ifdef _WIN32 +#include +#include +#else +#include +#endif + // // Exported Functions // @@ -77,3 +84,47 @@ bool CoreWriteFile(std::filesystem::path file, std::vector& buffer) fileStream.close(); return true; } + +uint64_t CoreGetFileTime(std::filesystem::path file) +{ +#ifdef _WIN32 + BOOL ret; + HANDLE file_handle; + FILETIME file_time; + ULARGE_INTEGER ularge_int; + + file_handle = CreateFileW(file.wstring().c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + if (file_handle == INVALID_HANDLE_VALUE) + { + return -1; + } + + ret = GetFileTime(file_handle, nullptr, nullptr, &file_time); + if (ret != TRUE) + { + return -1; + } + + ret = CloseHandle(file_handle); + if (ret != TRUE) + { + return -1; + } + + ularge_int.LowPart = file_time.dwLowDateTime; + ularge_int.HighPart = file_time.dwHighDateTime; + + return ularge_int.QuadPart; +#else // Linux + int ret; + struct stat file_stat; + + ret = stat(file.string().c_str(), &file_stat); + if (ret != 0) + { + return -1; + } + + return file_stat.st_mtime; +#endif +} diff --git a/Source/RMG-Core/File.hpp b/Source/RMG-Core/File.hpp index b49272c2..29bb0274 100644 --- a/Source/RMG-Core/File.hpp +++ b/Source/RMG-Core/File.hpp @@ -19,4 +19,7 @@ bool CoreReadFile(std::filesystem::path file, std::vector& outBuffer); // attempts to write the buffer to file bool CoreWriteFile(std::filesystem::path file, std::vector& buffer); +// attempts to retrieve the file time +uint64_t CoreGetFileTime(std::filesystem::path file); + #endif // CORE_FILE_HPP \ No newline at end of file diff --git a/Source/RMG-Core/osal/osal_dynlib_win32.cpp b/Source/RMG-Core/Library.cpp similarity index 59% rename from Source/RMG-Core/osal/osal_dynlib_win32.cpp rename to Source/RMG-Core/Library.cpp index 57ae80d7..da6c6aa2 100644 --- a/Source/RMG-Core/osal/osal_dynlib_win32.cpp +++ b/Source/RMG-Core/Library.cpp @@ -7,25 +7,46 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "osal_dynlib.hpp" +#include "Library.hpp" -osal_dynlib_lib_handle osal_dynlib_open(std::filesystem::path path) +#ifndef _WIN32 +#include +#endif + +// +// Exported Functions +// + +CoreLibraryHandle CoreOpenLibrary(std::filesystem::path path) { +#ifdef _WIN32 return LoadLibraryW(path.wstring().c_str()); +#else // Linux + return dlopen(path.string().c_str(), RTLD_LAZY); +#endif } -osal_dynlib_lib_sym osal_dynlib_sym(osal_dynlib_lib_handle handle, const char* symbol) +CoreLibrarySymbol CoreGetLibrarySymbol(CoreLibraryHandle handle, const char* symbol) { +#ifdef _WIN32 return GetProcAddress(handle, symbol); +#else + return dlsym(handle, symbol); +#endif // Linux } -void osal_dynlib_close(osal_dynlib_lib_handle handle) +void CoreCloseLibrary(CoreLibraryHandle handle) { +#ifdef _WIN32 FreeLibrary(handle); +#else + dlclose(handle); +#endif // Linux } -std::string osal_dynlib_strerror(void) +std::string CoreGetLibraryError(void) { +#ifdef _WIN32 DWORD err = GetLastError(); LPSTR buf = nullptr; @@ -38,4 +59,7 @@ std::string osal_dynlib_strerror(void) LocalFree(buf); return msg; +#else // Linux + return std::string(dlerror()); +#endif } diff --git a/Source/RMG-Core/osal/osal_dynlib.hpp b/Source/RMG-Core/Library.hpp similarity index 58% rename from Source/RMG-Core/osal/osal_dynlib.hpp rename to Source/RMG-Core/Library.hpp index a37ba623..46adae20 100644 --- a/Source/RMG-Core/osal/osal_dynlib.hpp +++ b/Source/RMG-Core/Library.hpp @@ -7,35 +7,35 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef OSAL_DYNLIB_HPP -#define OSAL_DYNLIB_HPP +#ifndef CORE_LIBRARY_HPP +#define CORE_LIBRARY_HPP -#include #include +#include #ifdef _WIN32 #include -typedef HMODULE osal_dynlib_lib_handle; -typedef FARPROC osal_dynlib_lib_sym; -#define OSAL_DYNLIB_LIB_EXT_STR ".dll" +typedef HMODULE CoreLibraryHandle; +typedef FARPROC CoreLibrarySymbol; +#define CORE_LIBRARY_EXT_STR ".dll" #else // Unix -typedef void* osal_dynlib_lib_handle; -typedef void* osal_dynlib_lib_sym; -#define OSAL_DYNLIB_LIB_EXT_STR ".so" +typedef void* CoreLibraryHandle; +typedef void* CoreLibrarySymbol; +#define CORE_LIBRARY_EXT_STR ".so" #endif // _WIN32 // returns library handle for given filename, // return nullptr when invalid library -osal_dynlib_lib_handle osal_dynlib_open(std::filesystem::path path); +CoreLibraryHandle CoreOpenLibrary(std::filesystem::path path); // retrieves symbol handle for given library // handle, returns nullptr when not found -osal_dynlib_lib_sym osal_dynlib_sym(osal_dynlib_lib_handle, const char* symbol); +CoreLibrarySymbol CoreGetLibrarySymbol(CoreLibraryHandle handle, const char* symbol); // closes library handle -void osal_dynlib_close(osal_dynlib_lib_handle); +void CoreCloseLibrary(CoreLibraryHandle); // returns error message -std::string osal_dynlib_strerror(void); +std::string CoreGetLibraryError(void); -#endif // OSAL_DYNLIB_HPP \ No newline at end of file +#endif // CORE_LIBRARY_HPP diff --git a/Source/RMG-Core/Plugins.cpp b/Source/RMG-Core/Plugins.cpp index 078786e9..41c77b5e 100644 --- a/Source/RMG-Core/Plugins.cpp +++ b/Source/RMG-Core/Plugins.cpp @@ -13,12 +13,10 @@ #include "Emulation.hpp" #include "Callback.hpp" #include "Settings.hpp" +#include "Library.hpp" #include "Plugins.hpp" #include "Error.hpp" -#include "osal/osal_dynlib.hpp" -#include "osal/osal_files.hpp" - #include "m64p/PluginApi.hpp" #include "m64p/Api.hpp" @@ -178,9 +176,9 @@ static std::string get_plugin_path(CorePluginType type, std::string settingsValu } path = pluginPath; - path += OSAL_FILES_DIR_SEPERATOR_STR; + path += CORE_DIR_SEPERATOR_STR; path += typeName; - path += OSAL_FILES_DIR_SEPERATOR_STR; + path += CORE_DIR_SEPERATOR_STR; path += settingsValue; return path; @@ -188,12 +186,12 @@ static std::string get_plugin_path(CorePluginType type, std::string settingsValu static bool apply_plugin_settings(std::string pluginSettings[4]) { - std::string error; - std::string settingValue; - m64p::PluginApi* plugin; - CorePluginType pluginType; - osal_dynlib_lib_handle handle; - m64p_error ret; + std::string error; + std::string settingValue; + m64p::PluginApi* plugin; + CorePluginType pluginType; + CoreLibraryHandle handle; + m64p_error ret; for (int i = 0; i < 4; i++) { @@ -240,11 +238,11 @@ static bool apply_plugin_settings(std::string pluginSettings[4]) } // attempt to open the library - handle = osal_dynlib_open(settingValue.c_str()); + handle = CoreOpenLibrary(settingValue.c_str()); if (handle == nullptr) { - error = "apply_plugin_settings osal_dynlib_open Failed: "; - error += osal_dynlib_strerror(); + error = "apply_plugin_settings CoreOpenLibrary Failed: "; + error += CoreGetLibraryError(); CoreSetError(error); return false; } @@ -392,7 +390,7 @@ std::vector CoreGetAllPlugins(void) std::vector plugins; std::string plugin_name; CorePluginType plugin_type; - osal_dynlib_lib_handle handle; + CoreLibraryHandle handle; m64p::PluginApi plugin; for (const auto& entry : std::filesystem::recursive_directory_iterator(CoreGetPluginDirectory())) @@ -400,9 +398,9 @@ std::vector CoreGetAllPlugins(void) std::string path = entry.path().string(); std::string file = entry.path().filename().string(); if (!entry.is_directory() && - path.ends_with(OSAL_DYNLIB_LIB_EXT_STR)) + path.ends_with(CORE_LIBRARY_EXT_STR)) { - handle = osal_dynlib_open(path.c_str()); + handle = CoreOpenLibrary(path.c_str()); if (handle == nullptr || !plugin.Hook(handle)) { // skip invalid libs continue; @@ -412,7 +410,7 @@ std::vector CoreGetAllPlugins(void) plugin_type = get_plugin_type(&plugin); plugin.Unhook(); - osal_dynlib_close(handle); + CoreCloseLibrary(handle); if (plugin_type == CorePluginType::Invalid) { // skip unsupported plugin types diff --git a/Source/RMG-Core/m64p/Macros.hpp b/Source/RMG-Core/m64p/Macros.hpp index 92c619a9..3698ed93 100644 --- a/Source/RMG-Core/m64p/Macros.hpp +++ b/Source/RMG-Core/m64p/Macros.hpp @@ -10,16 +10,16 @@ #ifndef M64P_MACROS_HPP #define M64P_MACROS_HPP -#include "osal/osal_dynlib.hpp" +#include "Library.hpp" -#define HOOK_FUNC_OPT(handle, prevar, var) this->var = (ptr_##prevar##var)osal_dynlib_sym(handle, #prevar #var); +#define HOOK_FUNC_OPT(handle, prevar, var) this->var = (ptr_##prevar##var)CoreGetLibrarySymbol(handle, #prevar #var); #define HOOK_FUNC(handle, prevar, var) \ - this->var = (ptr_##prevar##var)osal_dynlib_sym(handle, #prevar #var); \ + this->var = (ptr_##prevar##var)CoreGetLibrarySymbol(handle, #prevar #var); \ if (this->var == nullptr) \ { \ this->errorMessage += "Failed to hook \"" #prevar #var "\": "; \ - this->errorMessage += osal_dynlib_strerror(); \ + this->errorMessage += CoreGetLibraryError(); \ return false; \ } diff --git a/Source/RMG-Core/osal/osal_dynlib_unix.cpp b/Source/RMG-Core/osal/osal_dynlib_unix.cpp deleted file mode 100644 index b9a2d54e..00000000 --- a/Source/RMG-Core/osal/osal_dynlib_unix.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Rosalie's Mupen GUI - https://github.com/Rosalie241/RMG - * Copyright (C) 2020 Rosalie Wanders - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "osal_dynlib.hpp" - -#include - -osal_dynlib_lib_handle osal_dynlib_open(std::filesystem::path path) -{ - return dlopen(path.string().c_str(), RTLD_LAZY); -} - -osal_dynlib_lib_sym osal_dynlib_sym(osal_dynlib_lib_handle handle, const char* symbol) -{ - return dlsym(handle, symbol); -} - -void osal_dynlib_close(osal_dynlib_lib_handle handle) -{ - dlclose(handle); -} - -std::string osal_dynlib_strerror(void) -{ - return std::string(dlerror()); -} diff --git a/Source/RMG-Core/osal/osal_files.hpp b/Source/RMG-Core/osal/osal_files.hpp deleted file mode 100644 index 410ebf0c..00000000 --- a/Source/RMG-Core/osal/osal_files.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Rosalie's Mupen GUI - https://github.com/Rosalie241/RMG - * Copyright (C) 2020 Rosalie Wanders - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef OSAL_FILES_HPP -#define OSAL_FILES_HPP - -#include - -typedef uint64_t osal_files_file_time; - -#ifdef _WIN32 -#define OSAL_FILES_DIR_SEPERATOR_STR "\\" -#else // Unix -#define OSAL_FILES_DIR_SEPERATOR_STR "/" -#endif // _WIN32 - -// returns file time for given file, -// returns -1 on failure -osal_files_file_time osal_files_get_file_time(std::filesystem::path file); - -#endif // OSAL_FILES_HPP diff --git a/Source/RMG-Core/osal/osal_files_unix.cpp b/Source/RMG-Core/osal/osal_files_unix.cpp deleted file mode 100644 index bddb643c..00000000 --- a/Source/RMG-Core/osal/osal_files_unix.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Rosalie's Mupen GUI - https://github.com/Rosalie241/RMG - * Copyright (C) 2020 Rosalie Wanders - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "osal_files.hpp" - -#include - -osal_files_file_time osal_files_get_file_time(std::filesystem::path file) -{ - int ret; - struct stat file_stat; - - ret = stat(file.string().c_str(), &file_stat); - if (ret != 0) - { - return -1; - } - - return file_stat.st_mtime; -} diff --git a/Source/RMG-Core/osal/osal_files_win32.cpp b/Source/RMG-Core/osal/osal_files_win32.cpp deleted file mode 100644 index 477c4f5a..00000000 --- a/Source/RMG-Core/osal/osal_files_win32.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Rosalie's Mupen GUI - https://github.com/Rosalie241/RMG - * Copyright (C) 2020 Rosalie Wanders - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "osal_files.hpp" - -#include -#include - -osal_files_file_time osal_files_get_file_time(std::filesystem::path file) -{ - BOOL ret; - HANDLE file_handle; - FILETIME file_time; - ULARGE_INTEGER ularge_int; - - file_handle = CreateFileW(file.wstring().c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); - if (file_handle == INVALID_HANDLE_VALUE) - { - return -1; - } - - ret = GetFileTime(file_handle, nullptr, nullptr, &file_time); - if (ret != TRUE) - { - return -1; - } - - ret = CloseHandle(file_handle); - if (ret != TRUE) - { - return -1; - } - - ularge_int.LowPart = file_time.dwLowDateTime; - ularge_int.HighPart = file_time.dwHighDateTime; - - return ularge_int.QuadPart; -} diff --git a/Source/RMG-Input/VRU.cpp b/Source/RMG-Input/VRU.cpp index 9126382a..5713790f 100644 --- a/Source/RMG-Input/VRU.cpp +++ b/Source/RMG-Input/VRU.cpp @@ -12,10 +12,10 @@ #define M64P_PLUGIN_PROTOTYPES 1 #include #include -#include #include #include +#include #include #include <3rdParty/vosk-api/include/vosk_api.h> @@ -67,7 +67,7 @@ static ptr_vosk_recognizer_final_result l_vosk_recognizer_final_result = static ptr_vosk_set_log_level l_vosk_set_log_level = nullptr; static ptr_vosk_recognizer_set_max_alternatives l_vosk_recognizer_set_max_alternatives = nullptr; -static osal_dynlib_lib_handle l_VoskLibHandle = nullptr; +static CoreLibraryHandle l_VoskLibHandle = nullptr; static VoskModel* l_VoskModel = nullptr; static VoskRecognizer* l_VoskRecognizer = nullptr; @@ -98,27 +98,27 @@ static bool hook_vosk(void) std::filesystem::path voskApiPath; voskApiPath = CoreGetLibraryDirectory(); - voskApiPath += "/libvosk" OSAL_DYNLIB_LIB_EXT_STR; + voskApiPath += "/libvosk" CORE_LIBRARY_EXT_STR; - l_VoskLibHandle = osal_dynlib_open(voskApiPath); + l_VoskLibHandle = CoreOpenLibrary(voskApiPath); if (l_VoskLibHandle == nullptr) { debugMessage = "VRU: Failed to open library \""; debugMessage += voskApiPath.string().c_str(); debugMessage += "\": "; - debugMessage += osal_dynlib_strerror(); + debugMessage += CoreGetLibraryError(); PluginDebugMessage(M64MSG_ERROR, debugMessage); return false; } - l_vosk_model_new = (ptr_vosk_model_new) osal_dynlib_sym(l_VoskLibHandle, "vosk_model_new"); - l_vosk_model_free = (ptr_vosk_model_free) osal_dynlib_sym(l_VoskLibHandle, "vosk_model_free"); - l_vosk_recognizer_new_grm = (ptr_vosk_recognizer_new_grm) osal_dynlib_sym(l_VoskLibHandle, "vosk_recognizer_new_grm"); - l_vosk_recognizer_free = (ptr_vosk_recognizer_free) osal_dynlib_sym(l_VoskLibHandle, "vosk_recognizer_free"); - l_vosk_recognizer_accept_waveform = (ptr_vosk_recognizer_accept_waveform) osal_dynlib_sym(l_VoskLibHandle, "vosk_recognizer_accept_waveform"); - l_vosk_recognizer_final_result = (ptr_vosk_recognizer_final_result) osal_dynlib_sym(l_VoskLibHandle, "vosk_recognizer_final_result"); - l_vosk_set_log_level = (ptr_vosk_set_log_level) osal_dynlib_sym(l_VoskLibHandle, "vosk_set_log_level"); - l_vosk_recognizer_set_max_alternatives = (ptr_vosk_recognizer_set_max_alternatives) osal_dynlib_sym(l_VoskLibHandle, "vosk_recognizer_set_max_alternatives"); + l_vosk_model_new = (ptr_vosk_model_new) CoreGetLibrarySymbol(l_VoskLibHandle, "vosk_model_new"); + l_vosk_model_free = (ptr_vosk_model_free) CoreGetLibrarySymbol(l_VoskLibHandle, "vosk_model_free"); + l_vosk_recognizer_new_grm = (ptr_vosk_recognizer_new_grm) CoreGetLibrarySymbol(l_VoskLibHandle, "vosk_recognizer_new_grm"); + l_vosk_recognizer_free = (ptr_vosk_recognizer_free) CoreGetLibrarySymbol(l_VoskLibHandle, "vosk_recognizer_free"); + l_vosk_recognizer_accept_waveform = (ptr_vosk_recognizer_accept_waveform) CoreGetLibrarySymbol(l_VoskLibHandle, "vosk_recognizer_accept_waveform"); + l_vosk_recognizer_final_result = (ptr_vosk_recognizer_final_result) CoreGetLibrarySymbol(l_VoskLibHandle, "vosk_recognizer_final_result"); + l_vosk_set_log_level = (ptr_vosk_set_log_level) CoreGetLibrarySymbol(l_VoskLibHandle, "vosk_set_log_level"); + l_vosk_recognizer_set_max_alternatives = (ptr_vosk_recognizer_set_max_alternatives) CoreGetLibrarySymbol(l_VoskLibHandle, "vosk_recognizer_set_max_alternatives"); if (l_vosk_model_new == nullptr || l_vosk_model_free == nullptr || @@ -148,7 +148,7 @@ static void unhook_vosk(void) l_vosk_set_log_level = nullptr; l_vosk_recognizer_set_max_alternatives = nullptr; - osal_dynlib_close(l_VoskLibHandle); + CoreCloseLibrary(l_VoskLibHandle); } static bool setup_vosk_model(void)